@langchain/classic 1.0.27 → 1.0.28

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 (298) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/agents/agent.cjs.map +1 -1
  3. package/dist/agents/agent.js.map +1 -1
  4. package/dist/agents/executor.cjs.map +1 -1
  5. package/dist/agents/executor.js.map +1 -1
  6. package/dist/agents/openai_functions/index.cjs.map +1 -1
  7. package/dist/agents/openai_functions/index.d.cts.map +1 -1
  8. package/dist/agents/openai_functions/index.d.ts.map +1 -1
  9. package/dist/agents/openai_functions/index.js.map +1 -1
  10. package/dist/agents/openai_tools/index.cjs.map +1 -1
  11. package/dist/agents/openai_tools/index.d.cts +2 -2
  12. package/dist/agents/openai_tools/index.d.cts.map +1 -1
  13. package/dist/agents/openai_tools/index.d.ts +2 -2
  14. package/dist/agents/openai_tools/index.d.ts.map +1 -1
  15. package/dist/agents/openai_tools/index.js.map +1 -1
  16. package/dist/agents/react/index.d.cts +2 -2
  17. package/dist/agents/react/index.d.cts.map +1 -1
  18. package/dist/agents/react/index.d.ts +2 -2
  19. package/dist/agents/react/index.d.ts.map +1 -1
  20. package/dist/agents/structured_chat/index.d.cts +2 -2
  21. package/dist/agents/structured_chat/index.d.cts.map +1 -1
  22. package/dist/agents/structured_chat/index.d.ts +2 -2
  23. package/dist/agents/structured_chat/index.d.ts.map +1 -1
  24. package/dist/agents/tool_calling/index.d.cts +2 -2
  25. package/dist/agents/tool_calling/index.d.cts.map +1 -1
  26. package/dist/agents/tool_calling/index.d.ts +2 -2
  27. package/dist/agents/tool_calling/index.d.ts.map +1 -1
  28. package/dist/agents/tool_calling/output_parser.cjs.map +1 -1
  29. package/dist/agents/tool_calling/output_parser.d.cts.map +1 -1
  30. package/dist/agents/tool_calling/output_parser.js.map +1 -1
  31. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.cts +2 -2
  32. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.cts.map +1 -1
  33. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +2 -2
  34. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts.map +1 -1
  35. package/dist/agents/xml/index.d.cts.map +1 -1
  36. package/dist/agents/xml/index.d.ts.map +1 -1
  37. package/dist/cache/file_system.cjs.map +1 -1
  38. package/dist/cache/file_system.js.map +1 -1
  39. package/dist/chains/analyze_documents_chain.cjs.map +1 -1
  40. package/dist/chains/analyze_documents_chain.js.map +1 -1
  41. package/dist/chains/base.cjs.map +1 -1
  42. package/dist/chains/base.d.cts +2 -2
  43. package/dist/chains/base.d.cts.map +1 -1
  44. package/dist/chains/base.d.ts +2 -2
  45. package/dist/chains/base.d.ts.map +1 -1
  46. package/dist/chains/base.js.map +1 -1
  47. package/dist/chains/chat_vector_db_chain.cjs.map +1 -1
  48. package/dist/chains/chat_vector_db_chain.js.map +1 -1
  49. package/dist/chains/combine_docs_chain.d.cts +2 -2
  50. package/dist/chains/combine_docs_chain.d.cts.map +1 -1
  51. package/dist/chains/combine_docs_chain.d.ts +2 -2
  52. package/dist/chains/combine_docs_chain.d.ts.map +1 -1
  53. package/dist/chains/combine_documents/reduce.cjs.map +1 -1
  54. package/dist/chains/combine_documents/reduce.js.map +1 -1
  55. package/dist/chains/conversational_retrieval_chain.cjs.map +1 -1
  56. package/dist/chains/conversational_retrieval_chain.js.map +1 -1
  57. package/dist/chains/graph_qa/cypher.cjs.map +1 -1
  58. package/dist/chains/graph_qa/cypher.js.map +1 -1
  59. package/dist/chains/llm_chain.cjs.map +1 -1
  60. package/dist/chains/llm_chain.js.map +1 -1
  61. package/dist/chains/load.d.cts +1 -2
  62. package/dist/chains/load.d.cts.map +1 -1
  63. package/dist/chains/load.d.ts +1 -2
  64. package/dist/chains/load.d.ts.map +1 -1
  65. package/dist/chains/openai_functions/base.cjs.map +1 -1
  66. package/dist/chains/openai_functions/base.js.map +1 -1
  67. package/dist/chains/openai_functions/openapi.cjs.map +1 -1
  68. package/dist/chains/openai_functions/openapi.js.map +1 -1
  69. package/dist/chains/openai_moderation.cjs.map +1 -1
  70. package/dist/chains/openai_moderation.js.map +1 -1
  71. package/dist/chains/query_constructor/index.cjs.map +1 -1
  72. package/dist/chains/query_constructor/index.js.map +1 -1
  73. package/dist/chains/question_answering/load.d.cts +1 -2
  74. package/dist/chains/question_answering/load.d.cts.map +1 -1
  75. package/dist/chains/question_answering/load.d.ts +1 -2
  76. package/dist/chains/question_answering/load.d.ts.map +1 -1
  77. package/dist/chains/retrieval.cjs.map +1 -1
  78. package/dist/chains/retrieval.js.map +1 -1
  79. package/dist/chains/retrieval_qa.cjs.map +1 -1
  80. package/dist/chains/retrieval_qa.js.map +1 -1
  81. package/dist/chains/router/utils.cjs.map +1 -1
  82. package/dist/chains/router/utils.js.map +1 -1
  83. package/dist/chains/summarization/load.d.cts +1 -2
  84. package/dist/chains/summarization/load.d.cts.map +1 -1
  85. package/dist/chains/summarization/load.d.ts +1 -2
  86. package/dist/chains/summarization/load.d.ts.map +1 -1
  87. package/dist/chains/vector_db_qa.cjs.map +1 -1
  88. package/dist/chains/vector_db_qa.js.map +1 -1
  89. package/dist/chat_models/universal.cjs +8 -10
  90. package/dist/chat_models/universal.cjs.map +1 -1
  91. package/dist/chat_models/universal.d.cts +3 -5
  92. package/dist/chat_models/universal.d.cts.map +1 -1
  93. package/dist/chat_models/universal.d.ts +3 -5
  94. package/dist/chat_models/universal.d.ts.map +1 -1
  95. package/dist/chat_models/universal.js +8 -10
  96. package/dist/chat_models/universal.js.map +1 -1
  97. package/dist/document_loaders/fs/directory.d.cts.map +1 -1
  98. package/dist/document_loaders/fs/directory.d.ts.map +1 -1
  99. package/dist/document_loaders/fs/json.cjs.map +1 -1
  100. package/dist/document_loaders/fs/json.js.map +1 -1
  101. package/dist/document_transformers/openai_functions.d.cts.map +1 -1
  102. package/dist/evaluation/agents/index.d.cts +1 -0
  103. package/dist/evaluation/agents/trajectory.d.cts +2 -2
  104. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  105. package/dist/evaluation/agents/trajectory.d.ts +2 -2
  106. package/dist/evaluation/agents/trajectory.d.ts.map +1 -1
  107. package/dist/evaluation/base.cjs.map +1 -1
  108. package/dist/evaluation/base.d.cts.map +1 -1
  109. package/dist/evaluation/base.js.map +1 -1
  110. package/dist/evaluation/comparison/index.d.cts +1 -0
  111. package/dist/evaluation/comparison/pairwise.cjs.map +1 -1
  112. package/dist/evaluation/comparison/pairwise.d.cts +3 -3
  113. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  114. package/dist/evaluation/comparison/pairwise.d.ts +3 -3
  115. package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
  116. package/dist/evaluation/comparison/pairwise.js.map +1 -1
  117. package/dist/evaluation/criteria/criteria.cjs.map +1 -1
  118. package/dist/evaluation/criteria/criteria.d.cts +3 -3
  119. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  120. package/dist/evaluation/criteria/criteria.d.ts +3 -3
  121. package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
  122. package/dist/evaluation/criteria/criteria.js.map +1 -1
  123. package/dist/evaluation/criteria/index.d.cts +1 -0
  124. package/dist/evaluation/embedding_distance/index.d.cts +1 -0
  125. package/dist/evaluation/loader.cjs.map +1 -1
  126. package/dist/evaluation/loader.d.cts.map +1 -1
  127. package/dist/evaluation/loader.js.map +1 -1
  128. package/dist/evaluation/qa/index.d.cts +1 -0
  129. package/dist/experimental/autogpt/prompt.d.cts +2 -2
  130. package/dist/experimental/autogpt/prompt.d.cts.map +1 -1
  131. package/dist/experimental/autogpt/prompt.d.ts +2 -2
  132. package/dist/experimental/autogpt/prompt.d.ts.map +1 -1
  133. package/dist/experimental/autogpt/prompt_generator.cjs.map +1 -1
  134. package/dist/experimental/autogpt/prompt_generator.js.map +1 -1
  135. package/dist/experimental/autogpt/schema.cjs.map +1 -1
  136. package/dist/experimental/autogpt/schema.js.map +1 -1
  137. package/dist/experimental/generative_agents/generative_agent_memory.cjs.map +1 -1
  138. package/dist/experimental/generative_agents/generative_agent_memory.js.map +1 -1
  139. package/dist/experimental/masking/parser.cjs.map +1 -1
  140. package/dist/experimental/masking/parser.js.map +1 -1
  141. package/dist/experimental/masking/regex_masking_transformer.cjs.map +1 -1
  142. package/dist/experimental/masking/regex_masking_transformer.js.map +1 -1
  143. package/dist/experimental/openai_assistant/index.cjs.map +1 -1
  144. package/dist/experimental/openai_assistant/index.d.cts +3 -3
  145. package/dist/experimental/openai_assistant/index.d.ts +3 -3
  146. package/dist/experimental/openai_assistant/index.js.map +1 -1
  147. package/dist/experimental/openai_files/index.d.cts +4 -4
  148. package/dist/experimental/openai_files/index.d.ts +4 -4
  149. package/dist/experimental/plan_and_execute/agent_executor.cjs.map +1 -1
  150. package/dist/experimental/plan_and_execute/agent_executor.js.map +1 -1
  151. package/dist/experimental/prompts/custom_format.cjs.map +1 -1
  152. package/dist/experimental/prompts/custom_format.js.map +1 -1
  153. package/dist/experimental/prompts/handlebars.cjs.map +1 -1
  154. package/dist/experimental/prompts/handlebars.d.cts +2 -2
  155. package/dist/experimental/prompts/handlebars.d.cts.map +1 -1
  156. package/dist/experimental/prompts/handlebars.d.ts +2 -2
  157. package/dist/experimental/prompts/handlebars.d.ts.map +1 -1
  158. package/dist/experimental/prompts/handlebars.js.map +1 -1
  159. package/dist/hub/base.cjs.map +1 -1
  160. package/dist/hub/base.d.cts +0 -1
  161. package/dist/hub/base.d.cts.map +1 -1
  162. package/dist/hub/base.d.ts +0 -1
  163. package/dist/hub/base.d.ts.map +1 -1
  164. package/dist/hub/base.js.map +1 -1
  165. package/dist/hub/index.cjs.map +1 -1
  166. package/dist/hub/index.js.map +1 -1
  167. package/dist/load/index.cjs.map +1 -1
  168. package/dist/load/index.js.map +1 -1
  169. package/dist/output_parsers/combining.cjs.map +1 -1
  170. package/dist/output_parsers/combining.js.map +1 -1
  171. package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
  172. package/dist/output_parsers/expression_type_handlers/base.d.cts.map +1 -1
  173. package/dist/output_parsers/expression_type_handlers/base.d.ts.map +1 -1
  174. package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
  175. package/dist/output_parsers/fix.cjs.map +1 -1
  176. package/dist/output_parsers/fix.js.map +1 -1
  177. package/dist/output_parsers/openai_functions.d.cts.map +1 -1
  178. package/dist/output_parsers/openai_functions.d.ts.map +1 -1
  179. package/dist/output_parsers/openai_tools.cjs.map +1 -1
  180. package/dist/output_parsers/openai_tools.js.map +1 -1
  181. package/dist/output_parsers/regex.cjs.map +1 -1
  182. package/dist/output_parsers/regex.js.map +1 -1
  183. package/dist/output_parsers/structured.d.cts +2 -2
  184. package/dist/output_parsers/structured.d.cts.map +1 -1
  185. package/dist/output_parsers/structured.d.ts +2 -2
  186. package/dist/output_parsers/structured.d.ts.map +1 -1
  187. package/dist/retrievers/document_compressors/index.cjs.map +1 -1
  188. package/dist/retrievers/document_compressors/index.js.map +1 -1
  189. package/dist/retrievers/matryoshka_retriever.cjs.map +1 -1
  190. package/dist/retrievers/matryoshka_retriever.d.cts +1 -1
  191. package/dist/retrievers/matryoshka_retriever.d.cts.map +1 -1
  192. package/dist/retrievers/matryoshka_retriever.d.ts +1 -1
  193. package/dist/retrievers/matryoshka_retriever.d.ts.map +1 -1
  194. package/dist/retrievers/matryoshka_retriever.js.map +1 -1
  195. package/dist/retrievers/multi_query.cjs.map +1 -1
  196. package/dist/retrievers/multi_query.js.map +1 -1
  197. package/dist/retrievers/parent_document.cjs.map +1 -1
  198. package/dist/retrievers/parent_document.js.map +1 -1
  199. package/dist/schema/prompt_template.d.cts +1 -2
  200. package/dist/schema/prompt_template.d.cts.map +1 -1
  201. package/dist/schema/prompt_template.d.ts +1 -2
  202. package/dist/schema/prompt_template.d.ts.map +1 -1
  203. package/dist/smith/config.cjs.map +1 -1
  204. package/dist/smith/config.d.cts +1 -1
  205. package/dist/smith/config.d.ts +1 -1
  206. package/dist/smith/config.d.ts.map +1 -1
  207. package/dist/smith/config.js.map +1 -1
  208. package/dist/smith/runner_utils.cjs.map +1 -1
  209. package/dist/smith/runner_utils.d.cts +1 -1
  210. package/dist/smith/runner_utils.d.cts.map +1 -1
  211. package/dist/smith/runner_utils.d.ts +1 -1
  212. package/dist/smith/runner_utils.d.ts.map +1 -1
  213. package/dist/smith/runner_utils.js.map +1 -1
  214. package/dist/sql_db.d.cts +2 -2
  215. package/dist/sql_db.d.cts.map +1 -1
  216. package/dist/sql_db.d.ts +2 -2
  217. package/dist/sql_db.d.ts.map +1 -1
  218. package/dist/storage/encoder_backed.cjs.map +1 -1
  219. package/dist/storage/encoder_backed.js.map +1 -1
  220. package/dist/storage/file_system.cjs.map +1 -1
  221. package/dist/storage/file_system.js.map +1 -1
  222. package/dist/stores/doc/in_memory.cjs.map +1 -1
  223. package/dist/stores/doc/in_memory.js.map +1 -1
  224. package/dist/tools/json.cjs.map +1 -1
  225. package/dist/tools/json.js.map +1 -1
  226. package/dist/tools/webbrowser.cjs.map +1 -1
  227. package/dist/tools/webbrowser.d.cts.map +1 -1
  228. package/dist/tools/webbrowser.d.ts.map +1 -1
  229. package/dist/tools/webbrowser.js.map +1 -1
  230. package/dist/util/document.d.cts +1 -1
  231. package/dist/util/document.d.cts.map +1 -1
  232. package/dist/util/document.d.ts +1 -1
  233. package/dist/util/document.d.ts.map +1 -1
  234. package/dist/util/is-network-error/index.cjs.map +1 -1
  235. package/dist/util/is-network-error/index.js.map +1 -1
  236. package/dist/util/load.cjs.map +1 -1
  237. package/dist/util/load.js.map +1 -1
  238. package/dist/util/openapi.cjs.map +1 -1
  239. package/dist/util/openapi.d.cts +32 -32
  240. package/dist/util/openapi.d.cts.map +1 -1
  241. package/dist/util/openapi.d.ts +32 -32
  242. package/dist/util/openapi.d.ts.map +1 -1
  243. package/dist/util/openapi.js.map +1 -1
  244. package/dist/util/p-retry/index.cjs.map +1 -1
  245. package/dist/util/p-retry/index.js.map +1 -1
  246. package/dist/vectorstores/memory.cjs.map +1 -1
  247. package/dist/vectorstores/memory.js.map +1 -1
  248. package/package.json +25 -48
  249. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/client.d.cts +0 -1494
  250. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/client.d.cts.map +0 -1
  251. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/client.d.ts +0 -1494
  252. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/client.d.ts.map +0 -1
  253. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/_runner.d.cts +0 -1
  254. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/_runner.d.ts +0 -1
  255. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/evaluate_comparative.d.cts +0 -1
  256. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/evaluate_comparative.d.ts +0 -1
  257. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/evaluator.d.cts +0 -66
  258. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/evaluator.d.cts.map +0 -1
  259. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/evaluator.d.ts +0 -66
  260. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/evaluator.d.ts.map +0 -1
  261. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/index.d.cts +0 -1
  262. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/index.d.ts +0 -1
  263. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/string_evaluator.d.cts +0 -1
  264. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/evaluation/string_evaluator.d.ts +0 -1
  265. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/index.d.cts +0 -4
  266. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/index.d.ts +0 -4
  267. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/run_trees.d.cts +0 -145
  268. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/run_trees.d.cts.map +0 -1
  269. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/run_trees.d.ts +0 -145
  270. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/run_trees.d.ts.map +0 -1
  271. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/schemas.d.cts +0 -437
  272. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/schemas.d.cts.map +0 -1
  273. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/schemas.d.ts +0 -437
  274. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/schemas.d.ts.map +0 -1
  275. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/traceable.d.cts +0 -7
  276. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/traceable.d.cts.map +0 -1
  277. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/traceable.d.ts +0 -7
  278. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/traceable.d.ts.map +0 -1
  279. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/types.d.cts +0 -38
  280. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/types.d.cts.map +0 -1
  281. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/types.d.ts +0 -38
  282. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/singletons/types.d.ts.map +0 -1
  283. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/async_caller.d.cts +0 -25
  284. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/async_caller.d.cts.map +0 -1
  285. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/async_caller.d.ts +0 -25
  286. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/async_caller.d.ts.map +0 -1
  287. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/p-queue.d.cts +0 -1
  288. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/p-queue.d.ts +0 -1
  289. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/prompt_cache/index.d.cts +0 -129
  290. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/prompt_cache/index.d.cts.map +0 -1
  291. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/prompt_cache/index.d.ts +0 -129
  292. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/dist/utils/prompt_cache/index.d.ts.map +0 -1
  293. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/evaluation.d.cts +0 -1
  294. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/evaluation.d.ts +0 -1
  295. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/singletons/traceable.d.cts +0 -2
  296. package/dist/node_modules/.pnpm/langsmith@0.5.9_@opentelemetry_api@1.9.0_openai@6.22.0_ws@8.20.0_bufferutil@4.1.0__zod@4.3.6_/node_modules/langsmith/singletons/traceable.d.ts +0 -2
  297. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/index.d.cts +0 -1
  298. package/dist/node_modules/.pnpm/p-queue@6.6.2/node_modules/p-queue/dist/index.d.ts +0 -1
@@ -1 +1 @@
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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AAC;EAClD,CAAC"}
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// oxlint-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,uBAAAA,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,KAAA,EACZ;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,0BAAAA,SAAS,KAAK,MAAM,QAAQ,OAAO,MAAM,CAAC,CAAC;EAClD,CAAC"}
@@ -1 +1 @@
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,KAAA,EACZ;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
+ {"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// oxlint-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,KAAA,EACZ;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 +1 @@
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,uBAAAA,UAA8B;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;WAE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,WADW,MAAMA,iBAAG,QAAQ,KAAK,SAAS,EACvB,KAAK,SAAS,KAAK,QAAQ,QAAQ,GAAG,CAAC;AAChE,OAAK,MAAM,OAAO,QAChB,KAAI,WAAW,KAAA,KAAa,IAAI,WAAW,OAAO,CAChD,OAAM;;;;;;;;CAWZ,aAAa,SAAS,UAA2C;AAC/D,MAAI;AAEF,SAAMA,iBAAG,OAAO,UAAUA,iBAAG,UAAU,OAAOA,iBAAG,UAAU,KAAK;UAC1D;AACN,OAAI;AAEF,UAAMA,iBAAG,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
+ {"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 // oxlint-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":";;;;;;;;;;;;;;;;;;;;;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ACtB,MAAM,cAAc,MAAM,KAAK,cAAc,IAAI;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,QAAQD,iBAAG,OAAO,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC;;;;;;;;CASxE,OAAO,UAAU,QAAyC;EAExD,MAAM,WADW,MAAMA,iBAAG,QAAQ,KAAK,SAAS,EACvB,KAAK,SAAS,KAAK,QAAQ,QAAQ,GAAG,CAAC;AAChE,OAAK,MAAM,OAAO,QAChB,KAAI,WAAW,KAAA,KAAa,IAAI,WAAW,OAAO,CAChD,OAAM;;;;;;;;CAWZ,aAAa,SAAS,UAA2C;AAC/D,MAAI;AAEF,SAAMA,iBAAG,OAAO,UAAUA,iBAAG,UAAU,OAAOA,iBAAG,UAAU,KAAK;UAC1D;AACN,OAAI;AAEF,UAAMA,iBAAG,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 +1 @@
1
- {"version":3,"file":"file_system.js","names":["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,cAAoC,UAA8B;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,MAAMA,KAAG,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,KAAG,UAAU,KAAK,YAAY,IAAI,EAAE,QAAQ;WAC3C,OAAO;AACd,SAAM,IAAI,MACR,+BAA+B,KAAK,YAClC,IACD,CAAC,YAAY,KAAK,UAAU,MAAM,GACpC;;;;;;;CAQL,YAAoB,KAAqB;AACvC,MAAI;GACF,MAAM,eAAe,GAAG,IAAI;AAG5B,OAAI,CAAC,sBAAsB,KAAK,IAAI,CAClC,OAAM,IAAI,MAAM,8BAA8B,MAAM;GAGtD,MAAM,W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 {"version":3,"file":"file_system.js","names":["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 // oxlint-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,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,MAAMA,KAAG,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,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AI,WAAW,OAAO,CAChD,OAAM;;;;;;;;CAWZ,aAAa,SAAS,UAA2C;AAC/D,MAAI;AAEF,SAAMA,KAAG,OAAO,UAAUA,KAAG,UAAU,OAAOA,KAAG,UAAU,KAAK;UAC1D;AACN,OAAI;AAEF,UAAMA,KAAG,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 +1 @@
1
- {"version":3,"file":"in_memory.cjs","names":["Docstore"],"sources":["../../../src/stores/doc/in_memory.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStoreInterface } from \"@langchain/core/stores\";\nimport { Docstore } from \"./base.js\";\n\n/**\n * Class for storing and retrieving documents in memory asynchronously.\n * Extends the Docstore class.\n */\nexport class InMemoryDocstore\n extends Docstore\n implements BaseStoreInterface<string, Document>\n{\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n super();\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n async search(search: string): Promise<Document> {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n async add(texts: Record<string, Document>): Promise<void> {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n\n async mget(keys: string[]): Promise<Document[]> {\n return Promise.all(keys.map((key) => this.search(key)));\n }\n\n async mset(keyValuePairs: [string, Document][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.add({ [key]: value }))\n );\n }\n\n async mdelete(_keys: string[]): Promise<void> {\n throw new Error(\"Not implemented.\");\n }\n\n // eslint-disable-next-line require-yield\n async *yieldKeys(_prefix?: string): AsyncGenerator<string> {\n throw new Error(\"Not implemented\");\n }\n}\n\n/**\n * Class for storing and retrieving documents in memory synchronously.\n */\nexport class SynchronousInMemoryDocstore {\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n search(search: string): Document {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n add(texts: Record<string, Document>): void {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AAQA,IAAa,mBAAb,cACUA,wBAAAA,SAEV;CACE;CAEA,YAAY,MAA8B;AACxC,SAAO;AACP,OAAK,QAAQ,wBAAQ,IAAI,KAAK;;;;;;;CAQhC,MAAM,OAAO,QAAmC;EAC9C,MAAM,SAAS,KAAK,MAAM,IAAI,OAAO;AACrC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,MAAM,OAAO,aAAa;MAE1C,QAAO;;;;;;;CASX,MAAM,IAAI,OAAgD;EACxD,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,MAAM,CAAC;EACnC,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,KAAK,SAAS,EAAE,CAAC;AAEtE,MAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MAAM,wCAAwC,cAAc;AAGxE,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,MAAM,IAAI,KAAK,MAAM;;CAI9B,MAAM,KAAK,MAAqC;AAC9C,SAAO,QAAQ,IAAI,KAAK,KAAK,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC;;CAGzD,MAAM,KAAK,eAAoD;AAC7D,QAAM,QAAQ,IACZ,cAAc,KAAK,CAAC,KAAK,WAAW,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,CAAC,CAChE;;CAGH,MAAM,QAAQ,OAAgC;AAC5C,QAAM,IAAI,MAAM,mBAAmB;;CAIrC,OAAO,UAAU,SAA0C;AACzD,QAAM,IAAI,MAAM,kBAAkB;;;;;;AAOtC,IAAa,8BAAb,MAAyC;CACvC;CAEA,YAAY,MAA8B;AACxC,OAAK,QAAQ,wBAAQ,IAAI,KAAK;;;;;;;CAQhC,OAAO,QAA0B;EAC/B,MAAM,SAAS,KAAK,MAAM,IAAI,OAAO;AACrC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,MAAM,OAAO,aAAa;MAE1C,QAAO;;;;;;;CASX,IAAI,OAAuC;EACzC,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,MAAM,CAAC;EACnC,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,KAAK,SAAS,EAAE,CAAC;AAEtE,MAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MAAM,wCAAwC,cAAc;AAGxE,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,MAAM,IAAI,KAAK,MAAM"}
1
+ {"version":3,"file":"in_memory.cjs","names":["Docstore"],"sources":["../../../src/stores/doc/in_memory.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStoreInterface } from \"@langchain/core/stores\";\nimport { Docstore } from \"./base.js\";\n\n/**\n * Class for storing and retrieving documents in memory asynchronously.\n * Extends the Docstore class.\n */\nexport class InMemoryDocstore\n extends Docstore\n implements BaseStoreInterface<string, Document>\n{\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n super();\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n async search(search: string): Promise<Document> {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n async add(texts: Record<string, Document>): Promise<void> {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n\n async mget(keys: string[]): Promise<Document[]> {\n return Promise.all(keys.map((key) => this.search(key)));\n }\n\n async mset(keyValuePairs: [string, Document][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.add({ [key]: value }))\n );\n }\n\n async mdelete(_keys: string[]): Promise<void> {\n throw new Error(\"Not implemented.\");\n }\n\n // oxlint-disable-next-line require-yield\n async *yieldKeys(_prefix?: string): AsyncGenerator<string> {\n throw new Error(\"Not implemented\");\n }\n}\n\n/**\n * Class for storing and retrieving documents in memory synchronously.\n */\nexport class SynchronousInMemoryDocstore {\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n search(search: string): Document {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n add(texts: Record<string, Document>): void {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;AAQA,IAAa,mBAAb,cACUA,wBAAAA,SAEV;CACE;CAEA,YAAY,MAA8B;AACxC,SAAO;AACP,OAAK,QAAQ,wBAAQ,IAAI,KAAK;;;;;;;CAQhC,MAAM,OAAO,QAAmC;EAC9C,MAAM,SAAS,KAAK,MAAM,IAAI,OAAO;AACrC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,MAAM,OAAO,aAAa;MAE1C,QAAO;;;;;;;CASX,MAAM,IAAI,OAAgD;EACxD,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,MAAM,CAAC;EACnC,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,KAAK,SAAS,EAAE,CAAC;AAEtE,MAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MAAM,wCAAwC,cAAc;AAGxE,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,MAAM,IAAI,KAAK,MAAM;;CAI9B,MAAM,KAAK,MAAqC;AAC9C,SAAO,QAAQ,IAAI,KAAK,KAAK,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC;;CAGzD,MAAM,KAAK,eAAoD;AAC7D,QAAM,QAAQ,IACZ,cAAc,KAAK,CAAC,KAAK,WAAW,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,CAAC,CAChE;;CAGH,MAAM,QAAQ,OAAgC;AAC5C,QAAM,IAAI,MAAM,mBAAmB;;CAIrC,OAAO,UAAU,SAA0C;AACzD,QAAM,IAAI,MAAM,kBAAkB;;;;;;AAOtC,IAAa,8BAAb,MAAyC;CACvC;CAEA,YAAY,MAA8B;AACxC,OAAK,QAAQ,wBAAQ,IAAI,KAAK;;;;;;;CAQhC,OAAO,QAA0B;EAC/B,MAAM,SAAS,KAAK,MAAM,IAAI,OAAO;AACrC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,MAAM,OAAO,aAAa;MAE1C,QAAO;;;;;;;CASX,IAAI,OAAuC;EACzC,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,MAAM,CAAC;EACnC,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,KAAK,SAAS,EAAE,CAAC;AAEtE,MAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MAAM,wCAAwC,cAAc;AAGxE,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,MAAM,IAAI,KAAK,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"in_memory.js","names":[],"sources":["../../../src/stores/doc/in_memory.ts"],"sourcesContent":["import { Document } from \"@langchain/core/documents\";\nimport { BaseStoreInterface } from \"@langchain/core/stores\";\nimport { Docstore } from \"./base.js\";\n\n/**\n * Class for storing and retrieving documents in memory asynchronously.\n * Extends the Docstore class.\n */\nexport class InMemoryDocstore\n extends Docstore\n implements BaseStoreInterface<string, Document>\n{\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n super();\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n async search(search: string): Promise<Document> {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n async add(texts: Record<string, Document>): Promise<void> {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n\n async mget(keys: string[]): Promise<Document[]> {\n return Promise.all(keys.map((key) => this.search(key)));\n }\n\n async mset(keyValuePairs: [string, Document][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.add({ [key]: value }))\n );\n }\n\n async mdelete(_keys: string[]): Promise<void> {\n throw new Error(\"Not implemented.\");\n }\n\n // eslint-disable-next-line require-yield\n async *yieldKeys(_prefix?: string): AsyncGenerator<string> {\n throw new Error(\"Not implemented\");\n }\n}\n\n/**\n * Class for storing and retrieving documents in memory synchronously.\n */\nexport class SynchronousInMemoryDocstore {\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n search(search: string): Document {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n add(texts: Record<string, Document>): void {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAQA,IAAa,mBAAb,cACU,SAEV;CACE;CAEA,YAAY,MAA8B;AACxC,SAAO;AACP,OAAK,QAAQ,wBAAQ,IAAI,KAAK;;;;;;;CAQhC,MAAM,OAAO,QAAmC;EAC9C,MAAM,SAAS,KAAK,MAAM,IAAI,OAAO;AACrC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,MAAM,OAAO,aAAa;MAE1C,QAAO;;;;;;;CASX,MAAM,IAAI,OAAgD;EACxD,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,MAAM,CAA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document } from \"@langchain/core/documents\";\nimport { BaseStoreInterface } from \"@langchain/core/stores\";\nimport { Docstore } from \"./base.js\";\n\n/**\n * Class for storing and retrieving documents in memory asynchronously.\n * Extends the Docstore class.\n */\nexport class InMemoryDocstore\n extends Docstore\n implements BaseStoreInterface<string, Document>\n{\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n super();\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n async search(search: string): Promise<Document> {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n async add(texts: Record<string, Document>): Promise<void> {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n\n async mget(keys: string[]): Promise<Document[]> {\n return Promise.all(keys.map((key) => this.search(key)));\n }\n\n async mset(keyValuePairs: [string, Document][]): Promise<void> {\n await Promise.all(\n keyValuePairs.map(([key, value]) => this.add({ [key]: value }))\n );\n }\n\n async mdelete(_keys: string[]): Promise<void> {\n throw new Error(\"Not implemented.\");\n }\n\n // oxlint-disable-next-line require-yield\n async *yieldKeys(_prefix?: string): AsyncGenerator<string> {\n throw new Error(\"Not implemented\");\n }\n}\n\n/**\n * Class for storing and retrieving documents in memory synchronously.\n */\nexport class SynchronousInMemoryDocstore {\n _docs: Map<string, Document>;\n\n constructor(docs?: Map<string, Document>) {\n this._docs = docs ?? new Map();\n }\n\n /**\n * Searches for a document in the store based on its ID.\n * @param search The ID of the document to search for.\n * @returns The document with the given ID.\n */\n search(search: string): Document {\n const result = this._docs.get(search);\n if (!result) {\n throw new Error(`ID ${search} not found.`);\n } else {\n return result;\n }\n }\n\n /**\n * Adds new documents to the store.\n * @param texts An object where the keys are document IDs and the values are the documents themselves.\n * @returns Void\n */\n add(texts: Record<string, Document>): void {\n const keys = [...this._docs.keys()];\n const overlapping = Object.keys(texts).filter((x) => keys.includes(x));\n\n if (overlapping.length > 0) {\n throw new Error(`Tried to add ids that already exist: ${overlapping}`);\n }\n\n for (const [key, value] of Object.entries(texts)) {\n this._docs.set(key, value);\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAQA,IAAa,mBAAb,cACU,SAEV;CACE;CAEA,YAAY,MAA8B;AACxC,SAAO;AACP,OAAK,QAAQ,wBAAQ,IAAI,KAAK;;;;;;;CAQhC,MAAM,OAAO,QAAmC;EAC9C,MAAM,SAAS,KAAK,MAAM,IAAI,OAAO;AACrC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,MAAM,OAAO,aAAa;MAE1C,QAAO;;;;;;;CASX,MAAM,IAAI,OAAgD;EACxD,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,MAAM,CAAC;EACnC,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,KAAK,SAAS,EAAE,CAAC;AAEtE,MAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MAAM,wCAAwC,cAAc;AAGxE,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,MAAM,IAAI,KAAK,MAAM;;CAI9B,MAAM,KAAK,MAAqC;AAC9C,SAAO,QAAQ,IAAI,KAAK,KAAK,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC;;CAGzD,MAAM,KAAK,eAAoD;AAC7D,QAAM,QAAQ,IACZ,cAAc,KAAK,CAAC,KAAK,WAAW,KAAK,IAAI,GAAG,MAAM,OAAO,CAAC,CAAC,CAChE;;CAGH,MAAM,QAAQ,OAAgC;AAC5C,QAAM,IAAI,MAAM,mBAAmB;;CAIrC,OAAO,UAAU,SAA0C;AACzD,QAAM,IAAI,MAAM,kBAAkB;;;;;;AAOtC,IAAa,8BAAb,MAAyC;CACvC;CAEA,YAAY,MAA8B;AACxC,OAAK,QAAQ,wBAAQ,IAAI,KAAK;;;;;;;CAQhC,OAAO,QAA0B;EAC/B,MAAM,SAAS,KAAK,MAAM,IAAI,OAAO;AACrC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,MAAM,OAAO,aAAa;MAE1C,QAAO;;;;;;;CASX,IAAI,OAAuC;EACzC,MAAM,OAAO,CAAC,GAAG,KAAK,MAAM,MAAM,CAAC;EACnC,MAAM,cAAc,OAAO,KAAK,MAAM,CAAC,QAAQ,MAAM,KAAK,SAAS,EAAE,CAAC;AAEtE,MAAI,YAAY,SAAS,EACvB,OAAM,IAAI,MAAM,wCAAwC,cAAc;AAGxE,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,CAC9C,MAAK,MAAM,IAAI,KAAK,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"json.cjs","names":["Serializable","Tool"],"sources":["../../src/tools/json.ts"],"sourcesContent":["import jsonpointer from \"jsonpointer\";\nimport { Serializable } from \"@langchain/core/load/serializable\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\n\nexport type Json =\n | string\n | number\n | boolean\n | null\n | { [key: string]: Json }\n | Json[];\n\nexport type JsonObject = { [key: string]: Json };\n\n/**\n * Represents a JSON object in the LangChain framework. Provides methods\n * to get keys and values from the JSON object.\n */\nexport class JsonSpec extends Serializable {\n lc_namespace = [\"langchain\", \"tools\", \"json\"];\n\n obj: JsonObject;\n\n maxValueLength = 4000;\n\n constructor(obj: JsonObject, max_value_length = 4000) {\n super(...arguments);\n this.obj = obj;\n this.maxValueLength = max_value_length;\n }\n\n /**\n * Retrieves all keys at a given path in the JSON object.\n * @param input The path to the keys in the JSON object, provided as a string in JSON pointer syntax.\n * @returns A string containing all keys at the given path, separated by commas.\n */\n public getKeys(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n if (typeof res === \"object\" && !Array.isArray(res) && res !== null) {\n return Object.keys(res)\n .map((i) => i.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\"))\n .join(\", \");\n }\n\n throw new Error(\n `Value at ${input} is not a dictionary, get the value directly instead.`\n );\n }\n\n /**\n * Retrieves the value at a given path in the JSON object.\n * @param input The path to the value in the JSON object, provided as a string in JSON pointer syntax.\n * @returns The value at the given path in the JSON object, as a string. If the value is a large dictionary or exceeds the maximum length, a message is returned instead.\n */\n public getValue(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n\n if (res === null || res === undefined) {\n throw new Error(`Value at ${input} is null or undefined.`);\n }\n\n const str = typeof res === \"object\" ? JSON.stringify(res) : res.toString();\n if (\n typeof res === \"object\" &&\n !Array.isArray(res) &&\n str.length > this.maxValueLength\n ) {\n return `Value is a large dictionary, should explore its keys directly.`;\n }\n\n if (str.length > this.maxValueLength) {\n return `${str.slice(0, this.maxValueLength)}...`;\n }\n return str;\n }\n}\n\nexport interface JsonToolFields extends ToolParams {\n jsonSpec: JsonSpec;\n}\n\n/**\n * A tool in the LangChain framework that lists all keys at a given path\n * in a JSON object.\n */\nexport class JsonListKeysTool extends Tool {\n static lc_name() {\n return \"JsonListKeysTool\";\n }\n\n name = \"json_list_keys\";\n\n jsonSpec: JsonSpec;\n\n constructor(jsonSpec: JsonSpec);\n\n constructor(fields: JsonToolFields);\n\n constructor(fields: JsonSpec | JsonToolFields) {\n if (!(\"jsonSpec\" in fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = { jsonSpec: fields };\n }\n super(fields);\n\n this.jsonSpec = fields.jsonSpec;\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getKeys(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to list all keys at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n\n/**\n * A tool in the LangChain framework that retrieves the value at a given\n * path in a JSON object.\n */\nexport class JsonGetValueTool extends Tool {\n static lc_name() {\n return \"JsonGetValueTool\";\n }\n\n name = \"json_get_value\";\n\n constructor(public jsonSpec: JsonSpec) {\n super();\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getValue(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to see value in string format at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAa,WAAb,cAA8BA,kCAAAA,aAAa;CACzC,eAAe;EAAC;EAAa;EAAS;EAAO;CAE7C;CAEA,iBAAiB;CAEjB,YAAY,KAAiB,mBAAmB,KAAM;AACpD,QAAM,GAAG,UAAU;AACnB,OAAK,MAAM;AACX,OAAK,iBAAiB;;;;;;;CAQxB,QAAe,OAAuB;EAEpC,MAAM,MADU,YAAA,QAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AACjC,MAAI,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAC5D,QAAO,OAAO,KAAK,IAAI,CACpB,KAAK,MAAM,EAAE,WAAW,KAAK,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CACzD,KAAK,KAAK;AAGf,QAAM,IAAI,MACR,YAAY,MAAM,uDACnB;;;;;;;CAQH,SAAgB,OAAuB;EAErC,MAAM,MADU,YAAA,QAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AAEjC,MAAI,QAAQ,QAAQ,QAAQ,KAAA,EAC1B,OAAM,IAAI,MAAM,YAAY,MAAM,wBAAwB;EAG5D,MAAM,MAAM,OAAO,QAAQ,WAAW,KAAK,UAAU,IAAI,GAAG,IAAI,UAAU;AAC1E,MACE,OAAO,QAAQ,YACf,CAAC,MAAM,QAAQ,IAAI,IACnB,IAAI,SAAS,KAAK,eAElB,QAAO;AAGT,MAAI,IAAI,SAAS,KAAK,eACpB,QAAO,GAAG,IAAI,MAAM,GAAG,KAAK,eAAe,CAAC;AAE9C,SAAO;;;;;;;AAYX,IAAa,mBAAb,cAAsCC,sBAAAA,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP;CAMA,YAAY,QAAmC;AAC7C,MAAI,EAAE,cAAc,QAElB,UAAS,EAAE,UAAU,QAAQ;AAE/B,QAAM,OAAO;AAEb,OAAK,WAAW,OAAO;;;CAIzB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,QAAQ,MAAM;WAC5B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc;;;;;;;;AAShB,IAAa,mBAAb,cAAsCA,sBAAAA,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,YAAY,UAA2B;AACrC,SAAO;AADU,OAAA,WAAA;;;CAKnB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,SAAS,MAAM;WAC7B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc"}
1
+ {"version":3,"file":"json.cjs","names":["Serializable","Tool"],"sources":["../../src/tools/json.ts"],"sourcesContent":["import jsonpointer from \"jsonpointer\";\nimport { Serializable } from \"@langchain/core/load/serializable\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\n\nexport type Json =\n | string\n | number\n | boolean\n | null\n | { [key: string]: Json }\n | Json[];\n\nexport type JsonObject = { [key: string]: Json };\n\n/**\n * Represents a JSON object in the LangChain framework. Provides methods\n * to get keys and values from the JSON object.\n */\nexport class JsonSpec extends Serializable {\n lc_namespace = [\"langchain\", \"tools\", \"json\"];\n\n obj: JsonObject;\n\n maxValueLength = 4000;\n\n constructor(obj: JsonObject, max_value_length = 4000) {\n super(...arguments);\n this.obj = obj;\n this.maxValueLength = max_value_length;\n }\n\n /**\n * Retrieves all keys at a given path in the JSON object.\n * @param input The path to the keys in the JSON object, provided as a string in JSON pointer syntax.\n * @returns A string containing all keys at the given path, separated by commas.\n */\n public getKeys(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n if (typeof res === \"object\" && !Array.isArray(res) && res !== null) {\n return Object.keys(res)\n .map((i) => i.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\"))\n .join(\", \");\n }\n\n throw new Error(\n `Value at ${input} is not a dictionary, get the value directly instead.`\n );\n }\n\n /**\n * Retrieves the value at a given path in the JSON object.\n * @param input The path to the value in the JSON object, provided as a string in JSON pointer syntax.\n * @returns The value at the given path in the JSON object, as a string. If the value is a large dictionary or exceeds the maximum length, a message is returned instead.\n */\n public getValue(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n\n if (res === null || res === undefined) {\n throw new Error(`Value at ${input} is null or undefined.`);\n }\n\n const str = typeof res === \"object\" ? JSON.stringify(res) : res.toString();\n if (\n typeof res === \"object\" &&\n !Array.isArray(res) &&\n str.length > this.maxValueLength\n ) {\n return `Value is a large dictionary, should explore its keys directly.`;\n }\n\n if (str.length > this.maxValueLength) {\n return `${str.slice(0, this.maxValueLength)}...`;\n }\n return str;\n }\n}\n\nexport interface JsonToolFields extends ToolParams {\n jsonSpec: JsonSpec;\n}\n\n/**\n * A tool in the LangChain framework that lists all keys at a given path\n * in a JSON object.\n */\nexport class JsonListKeysTool extends Tool {\n static lc_name() {\n return \"JsonListKeysTool\";\n }\n\n name = \"json_list_keys\";\n\n jsonSpec: JsonSpec;\n\n constructor(jsonSpec: JsonSpec);\n\n constructor(fields: JsonToolFields);\n\n constructor(fields: JsonSpec | JsonToolFields) {\n if (!(\"jsonSpec\" in fields)) {\n // oxlint-disable-next-line no-param-reassign\n fields = { jsonSpec: fields };\n }\n super(fields);\n\n this.jsonSpec = fields.jsonSpec;\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getKeys(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to list all keys at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n\n/**\n * A tool in the LangChain framework that retrieves the value at a given\n * path in a JSON object.\n */\nexport class JsonGetValueTool extends Tool {\n static lc_name() {\n return \"JsonGetValueTool\";\n }\n\n name = \"json_get_value\";\n\n constructor(public jsonSpec: JsonSpec) {\n super();\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getValue(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to see value in string format at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n"],"mappings":";;;;;;;;;;AAkBA,IAAa,WAAb,cAA8BA,kCAAAA,aAAa;CACzC,eAAe;EAAC;EAAa;EAAS;EAAO;CAE7C;CAEA,iBAAiB;CAEjB,YAAY,KAAiB,mBAAmB,KAAM;AACpD,QAAM,GAAG,UAAU;AACnB,OAAK,MAAM;AACX,OAAK,iBAAiB;;;;;;;CAQxB,QAAe,OAAuB;EAEpC,MAAM,MADU,YAAA,QAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AACjC,MAAI,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAC5D,QAAO,OAAO,KAAK,IAAI,CACpB,KAAK,MAAM,EAAE,WAAW,KAAK,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CACzD,KAAK,KAAK;AAGf,QAAM,IAAI,MACR,YAAY,MAAM,uDACnB;;;;;;;CAQH,SAAgB,OAAuB;EAErC,MAAM,MADU,YAAA,QAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AAEjC,MAAI,QAAQ,QAAQ,QAAQ,KAAA,EAC1B,OAAM,IAAI,MAAM,YAAY,MAAM,wBAAwB;EAG5D,MAAM,MAAM,OAAO,QAAQ,WAAW,KAAK,UAAU,IAAI,GAAG,IAAI,UAAU;AAC1E,MACE,OAAO,QAAQ,YACf,CAAC,MAAM,QAAQ,IAAI,IACnB,IAAI,SAAS,KAAK,eAElB,QAAO;AAGT,MAAI,IAAI,SAAS,KAAK,eACpB,QAAO,GAAG,IAAI,MAAM,GAAG,KAAK,eAAe,CAAC;AAE9C,SAAO;;;;;;;AAYX,IAAa,mBAAb,cAAsCC,sBAAAA,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP;CAMA,YAAY,QAAmC;AAC7C,MAAI,EAAE,cAAc,QAElB,UAAS,EAAE,UAAU,QAAQ;AAE/B,QAAM,OAAO;AAEb,OAAK,WAAW,OAAO;;;CAIzB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,QAAQ,MAAM;WAC5B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc;;;;;;;;AAShB,IAAa,mBAAb,cAAsCA,sBAAAA,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,YAAY,UAA2B;AACrC,SAAO;AADU,OAAA,WAAA;;;CAKnB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,SAAS,MAAM;WAC7B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"json.js","names":[],"sources":["../../src/tools/json.ts"],"sourcesContent":["import jsonpointer from \"jsonpointer\";\nimport { Serializable } from \"@langchain/core/load/serializable\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\n\nexport type Json =\n | string\n | number\n | boolean\n | null\n | { [key: string]: Json }\n | Json[];\n\nexport type JsonObject = { [key: string]: Json };\n\n/**\n * Represents a JSON object in the LangChain framework. Provides methods\n * to get keys and values from the JSON object.\n */\nexport class JsonSpec extends Serializable {\n lc_namespace = [\"langchain\", \"tools\", \"json\"];\n\n obj: JsonObject;\n\n maxValueLength = 4000;\n\n constructor(obj: JsonObject, max_value_length = 4000) {\n super(...arguments);\n this.obj = obj;\n this.maxValueLength = max_value_length;\n }\n\n /**\n * Retrieves all keys at a given path in the JSON object.\n * @param input The path to the keys in the JSON object, provided as a string in JSON pointer syntax.\n * @returns A string containing all keys at the given path, separated by commas.\n */\n public getKeys(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n if (typeof res === \"object\" && !Array.isArray(res) && res !== null) {\n return Object.keys(res)\n .map((i) => i.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\"))\n .join(\", \");\n }\n\n throw new Error(\n `Value at ${input} is not a dictionary, get the value directly instead.`\n );\n }\n\n /**\n * Retrieves the value at a given path in the JSON object.\n * @param input The path to the value in the JSON object, provided as a string in JSON pointer syntax.\n * @returns The value at the given path in the JSON object, as a string. If the value is a large dictionary or exceeds the maximum length, a message is returned instead.\n */\n public getValue(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n\n if (res === null || res === undefined) {\n throw new Error(`Value at ${input} is null or undefined.`);\n }\n\n const str = typeof res === \"object\" ? JSON.stringify(res) : res.toString();\n if (\n typeof res === \"object\" &&\n !Array.isArray(res) &&\n str.length > this.maxValueLength\n ) {\n return `Value is a large dictionary, should explore its keys directly.`;\n }\n\n if (str.length > this.maxValueLength) {\n return `${str.slice(0, this.maxValueLength)}...`;\n }\n return str;\n }\n}\n\nexport interface JsonToolFields extends ToolParams {\n jsonSpec: JsonSpec;\n}\n\n/**\n * A tool in the LangChain framework that lists all keys at a given path\n * in a JSON object.\n */\nexport class JsonListKeysTool extends Tool {\n static lc_name() {\n return \"JsonListKeysTool\";\n }\n\n name = \"json_list_keys\";\n\n jsonSpec: JsonSpec;\n\n constructor(jsonSpec: JsonSpec);\n\n constructor(fields: JsonToolFields);\n\n constructor(fields: JsonSpec | JsonToolFields) {\n if (!(\"jsonSpec\" in fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = { jsonSpec: fields };\n }\n super(fields);\n\n this.jsonSpec = fields.jsonSpec;\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getKeys(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to list all keys at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n\n/**\n * A tool in the LangChain framework that retrieves the value at a given\n * path in a JSON object.\n */\nexport class JsonGetValueTool extends Tool {\n static lc_name() {\n return \"JsonGetValueTool\";\n }\n\n name = \"json_get_value\";\n\n constructor(public jsonSpec: JsonSpec) {\n super();\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getValue(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to see value in string format at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n"],"mappings":";;;;;;;;AAkBA,IAAa,WAAb,cAA8B,aAAa;CACzC,eAAe;EAAC;EAAa;EAAS;EAAO;CAE7C;CAEA,iBAAiB;CAEjB,YAAY,KAAiB,mBAAmB,KAAM;AACpD,QAAM,GAAG,UAAU;AACnB,OAAK,MAAM;AACX,OAAK,iBAAiB;;;;;;;CAQxB,QAAe,OAAuB;EAEpC,MAAM,MADU,YAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AACjC,MAAI,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAC5D,QAAO,OAAO,KAAK,IAAI,CACpB,KAAK,MAAM,EAAE,WAAW,KAAK,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CACzD,KAAK,KAAK;AAGf,QAAM,IAAI,MACR,YAAY,MAAM,uDACnB;;;;;;;CAQH,SAAgB,OAAuB;EAErC,MAAM,MADU,YAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AAEjC,MAAI,QAAQ,QAAQ,QAAQ,KAAA,EAC1B,OAAM,IAAI,MAAM,YAAY,MAAM,wBAAwB;EAG5D,MAAM,MAAM,OAAO,QAAQ,WAAW,KAAK,UAAU,IAAI,GAAG,IAAI,UAAU;AAC1E,MACE,OAAO,QAAQ,YACf,CAAC,MAAM,QAAQ,IAAI,IACnB,IAAI,SAAS,KAAK,eAElB,QAAO;AAGT,MAAI,IAAI,SAAS,KAAK,eACpB,QAAO,GAAG,IAAI,MAAM,GAAG,KAAK,eAAe,CAAC;AAE9C,SAAO;;;;;;;AAYX,IAAa,mBAAb,cAAsC,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP;CAMA,YAAY,QAAmC;AAC7C,MAAI,EAAE,cAAc,QAElB,UAAS,EAAE,UAAU,QAAQ;AAE/B,QAAM,OAAO;AAEb,OAAK,WAAW,OAAO;;;CAIzB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,QAAQ,MAAM;WAC5B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc;;;;;;;;AAShB,IAAa,mBAAb,cAAsC,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,YAAY,UAA2B;AACrC,SAAO;AADU,OAAA,WAAA;;;CAKnB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,SAAS,MAAM;WAC7B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc"}
1
+ {"version":3,"file":"json.js","names":[],"sources":["../../src/tools/json.ts"],"sourcesContent":["import jsonpointer from \"jsonpointer\";\nimport { Serializable } from \"@langchain/core/load/serializable\";\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\n\nexport type Json =\n | string\n | number\n | boolean\n | null\n | { [key: string]: Json }\n | Json[];\n\nexport type JsonObject = { [key: string]: Json };\n\n/**\n * Represents a JSON object in the LangChain framework. Provides methods\n * to get keys and values from the JSON object.\n */\nexport class JsonSpec extends Serializable {\n lc_namespace = [\"langchain\", \"tools\", \"json\"];\n\n obj: JsonObject;\n\n maxValueLength = 4000;\n\n constructor(obj: JsonObject, max_value_length = 4000) {\n super(...arguments);\n this.obj = obj;\n this.maxValueLength = max_value_length;\n }\n\n /**\n * Retrieves all keys at a given path in the JSON object.\n * @param input The path to the keys in the JSON object, provided as a string in JSON pointer syntax.\n * @returns A string containing all keys at the given path, separated by commas.\n */\n public getKeys(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n if (typeof res === \"object\" && !Array.isArray(res) && res !== null) {\n return Object.keys(res)\n .map((i) => i.replaceAll(\"~\", \"~0\").replaceAll(\"/\", \"~1\"))\n .join(\", \");\n }\n\n throw new Error(\n `Value at ${input} is not a dictionary, get the value directly instead.`\n );\n }\n\n /**\n * Retrieves the value at a given path in the JSON object.\n * @param input The path to the value in the JSON object, provided as a string in JSON pointer syntax.\n * @returns The value at the given path in the JSON object, as a string. If the value is a large dictionary or exceeds the maximum length, a message is returned instead.\n */\n public getValue(input: string): string {\n const pointer = jsonpointer.compile(input);\n const res = pointer.get(this.obj) as Json;\n\n if (res === null || res === undefined) {\n throw new Error(`Value at ${input} is null or undefined.`);\n }\n\n const str = typeof res === \"object\" ? JSON.stringify(res) : res.toString();\n if (\n typeof res === \"object\" &&\n !Array.isArray(res) &&\n str.length > this.maxValueLength\n ) {\n return `Value is a large dictionary, should explore its keys directly.`;\n }\n\n if (str.length > this.maxValueLength) {\n return `${str.slice(0, this.maxValueLength)}...`;\n }\n return str;\n }\n}\n\nexport interface JsonToolFields extends ToolParams {\n jsonSpec: JsonSpec;\n}\n\n/**\n * A tool in the LangChain framework that lists all keys at a given path\n * in a JSON object.\n */\nexport class JsonListKeysTool extends Tool {\n static lc_name() {\n return \"JsonListKeysTool\";\n }\n\n name = \"json_list_keys\";\n\n jsonSpec: JsonSpec;\n\n constructor(jsonSpec: JsonSpec);\n\n constructor(fields: JsonToolFields);\n\n constructor(fields: JsonSpec | JsonToolFields) {\n if (!(\"jsonSpec\" in fields)) {\n // oxlint-disable-next-line no-param-reassign\n fields = { jsonSpec: fields };\n }\n super(fields);\n\n this.jsonSpec = fields.jsonSpec;\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getKeys(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to list all keys at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n\n/**\n * A tool in the LangChain framework that retrieves the value at a given\n * path in a JSON object.\n */\nexport class JsonGetValueTool extends Tool {\n static lc_name() {\n return \"JsonGetValueTool\";\n }\n\n name = \"json_get_value\";\n\n constructor(public jsonSpec: JsonSpec) {\n super();\n }\n\n /** @ignore */\n async _call(input: string) {\n try {\n return this.jsonSpec.getValue(input);\n } catch (error) {\n return `${error}`;\n }\n }\n\n description = `Can be used to see value in string format at a given path.\n Before calling this you should be SURE that the path to this exists.\n The input is a text representation of the path to the json as json pointer syntax (e.g. /key1/0/key2).`;\n}\n"],"mappings":";;;;;;;;AAkBA,IAAa,WAAb,cAA8B,aAAa;CACzC,eAAe;EAAC;EAAa;EAAS;EAAO;CAE7C;CAEA,iBAAiB;CAEjB,YAAY,KAAiB,mBAAmB,KAAM;AACpD,QAAM,GAAG,UAAU;AACnB,OAAK,MAAM;AACX,OAAK,iBAAiB;;;;;;;CAQxB,QAAe,OAAuB;EAEpC,MAAM,MADU,YAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AACjC,MAAI,OAAO,QAAQ,YAAY,CAAC,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAC5D,QAAO,OAAO,KAAK,IAAI,CACpB,KAAK,MAAM,EAAE,WAAW,KAAK,KAAK,CAAC,WAAW,KAAK,KAAK,CAAC,CACzD,KAAK,KAAK;AAGf,QAAM,IAAI,MACR,YAAY,MAAM,uDACnB;;;;;;;CAQH,SAAgB,OAAuB;EAErC,MAAM,MADU,YAAY,QAAQ,MAAM,CACtB,IAAI,KAAK,IAAI;AAEjC,MAAI,QAAQ,QAAQ,QAAQ,KAAA,EAC1B,OAAM,IAAI,MAAM,YAAY,MAAM,wBAAwB;EAG5D,MAAM,MAAM,OAAO,QAAQ,WAAW,KAAK,UAAU,IAAI,GAAG,IAAI,UAAU;AAC1E,MACE,OAAO,QAAQ,YACf,CAAC,MAAM,QAAQ,IAAI,IACnB,IAAI,SAAS,KAAK,eAElB,QAAO;AAGT,MAAI,IAAI,SAAS,KAAK,eACpB,QAAO,GAAG,IAAI,MAAM,GAAG,KAAK,eAAe,CAAC;AAE9C,SAAO;;;;;;;AAYX,IAAa,mBAAb,cAAsC,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP;CAMA,YAAY,QAAmC;AAC7C,MAAI,EAAE,cAAc,QAElB,UAAS,EAAE,UAAU,QAAQ;AAE/B,QAAM,OAAO;AAEb,OAAK,WAAW,OAAO;;;CAIzB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,QAAQ,MAAM;WAC5B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc;;;;;;;;AAShB,IAAa,mBAAb,cAAsC,KAAK;CACzC,OAAO,UAAU;AACf,SAAO;;CAGT,OAAO;CAEP,YAAY,UAA2B;AACrC,SAAO;AADU,OAAA,WAAA;;;CAKnB,MAAM,MAAM,OAAe;AACzB,MAAI;AACF,UAAO,KAAK,SAAS,SAAS,MAAM;WAC7B,OAAO;AACd,UAAO,GAAG;;;CAId,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"webbrowser.cjs","names":["Tool","RecursiveCharacterTextSplitter","Document","formatDocumentsAsString","MemoryVectorStore","RunnableSequence","StringOutputParser"],"sources":["../../src/tools/webbrowser.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { Document } from \"@langchain/core/documents\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\n\nimport * as cheerio from \"cheerio\";\nimport {\n CallbackManager,\n CallbackManagerForToolRun,\n} from \"@langchain/core/callbacks/manager\";\n\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { RunnableSequence } from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n RecursiveCharacterTextSplitter,\n TextSplitter,\n} from \"@langchain/textsplitters\";\nimport { MemoryVectorStore } from \"../vectorstores/memory.js\";\n\nimport { formatDocumentsAsString } from \"../util/document.js\";\n\nexport const parseInputs = (inputs: string): [string, string] => {\n const [baseUrl, task] = inputs.split(\",\").map((input) => {\n let t = input.trim();\n t = t.startsWith('\"') ? t.slice(1) : t;\n t = t.endsWith('\"') ? t.slice(0, -1) : t;\n // it likes to put / at the end of urls, wont matter for task\n t = t.endsWith(\"/\") ? t.slice(0, -1) : t;\n return t.trim();\n });\n\n return [baseUrl, task];\n};\n\nexport const getText = (\n html: string,\n baseUrl: string,\n summary: boolean\n): string => {\n // scriptingEnabled so noscript elements are parsed\n const $ = cheerio.load(html, { scriptingEnabled: true });\n\n let text = \"\";\n\n // lets only get the body if its a summary, dont need to summarize header or footer etc\n const rootElement = summary ? \"body \" : \"*\";\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $(`${rootElement}:not(style):not(script):not(svg)`).each((_i, elem: any) => {\n // we dont want duplicated content as we drill down so remove children\n let content = $(elem).clone().children().remove().end().text().trim();\n const $el = $(elem);\n\n // if its an ahref, print the content and url\n let href = $el.attr(\"href\");\n if ($el.prop(\"tagName\")?.toLowerCase() === \"a\" && href) {\n if (!href.startsWith(\"http\")) {\n try {\n href = new URL(href, baseUrl).toString();\n } catch {\n // if this fails thats fine, just no url for this\n href = \"\";\n }\n }\n\n const imgAlt = $el.find(\"img[alt]\").attr(\"alt\")?.trim();\n if (imgAlt) {\n content += ` ${imgAlt}`;\n }\n\n text += ` [${content}](${href})`;\n }\n // otherwise just print the content\n else if (content !== \"\") {\n text += ` ${content}`;\n }\n });\n\n return text.trim().replace(/\\n+/g, \" \");\n};\n\nconst getHtml = async (baseUrl: string, h: Headers, config: RequestConfig) => {\n const domain = new URL(baseUrl).hostname;\n\n const headers = { ...h };\n // these appear to be positional, which means they have to exist in the headers passed in\n headers.Host = domain;\n headers[\"Alt-Used\"] = domain;\n\n let htmlResponse;\n try {\n const fetchOptions: RequestInit = {\n method: \"GET\",\n headers,\n credentials: config.withCredentials ? \"include\" : \"same-origin\",\n ...config,\n };\n\n htmlResponse = await fetch(baseUrl, fetchOptions);\n\n if (!htmlResponse.ok) {\n throw new Error(`http response ${htmlResponse.status}`);\n }\n } catch (e) {\n if (\n e &&\n typeof e === \"object\" &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"http response\")\n ) {\n throw e;\n }\n throw e;\n }\n\n const allowedContentTypes = [\n \"text/html\",\n \"application/json\",\n \"application/xml\",\n \"application/javascript\",\n \"text/plain\",\n ];\n\n const contentType = htmlResponse.headers.get(\"content-type\") || \"\";\n const contentTypeArray = contentType.split(\";\");\n if (\n contentTypeArray[0] &&\n !allowedContentTypes.includes(contentTypeArray[0])\n ) {\n throw new Error(\"returned page was not utf8\");\n }\n return htmlResponse.text();\n};\n\nconst DEFAULT_HEADERS = {\n Accept:\n \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\",\n \"Accept-Encoding\": \"gzip, deflate\",\n \"Accept-Language\": \"en-US,en;q=0.5\",\n \"Alt-Used\": \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Connection: \"keep-alive\",\n Host: \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Referer: \"https://www.google.com/\",\n \"Sec-Fetch-Dest\": \"document\",\n \"Sec-Fetch-Mode\": \"navigate\",\n \"Sec-Fetch-Site\": \"cross-site\",\n \"Upgrade-Insecure-Requests\": \"1\",\n \"User-Agent\":\n \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0\",\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Headers = Record<string, any>;\n\n/**\n * Configuration options for fetch requests, similar to axios config but for fetch\n */\nexport interface RequestConfig extends Omit<RequestInit, \"headers\"> {\n withCredentials?: boolean;\n}\n\n/**\n * Defines the arguments that can be passed to the WebBrowser constructor.\n * It extends the ToolParams interface and includes properties for a\n * language model, embeddings, HTTP headers, an Axios configuration, a\n * callback manager, and a text splitter.\n */\nexport interface WebBrowserArgs extends ToolParams {\n model: BaseLanguageModelInterface;\n\n embeddings: EmbeddingsInterface;\n\n headers?: Headers;\n\n requestConfig?: RequestConfig;\n\n /** @deprecated */\n callbackManager?: CallbackManager;\n\n textSplitter?: TextSplitter;\n}\n\n/**\n * A class designed to interact with web pages, either to extract\n * information from them or to summarize their content. It uses the native\n * fetch API to send HTTP requests and the cheerio library to parse the\n * returned HTML.\n * @example\n * ```typescript\n * const browser = new WebBrowser({\n * model: new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 }),\n * embeddings: new OpenAIEmbeddings({}),\n * });\n * const result = await browser.invoke(\"https:exampleurl.com\");\n * ```\n */\nexport class WebBrowser extends Tool {\n static lc_name() {\n return \"WebBrowser\";\n }\n\n get lc_namespace() {\n return [...super.lc_namespace, \"webbrowser\"];\n }\n\n private model: BaseLanguageModelInterface;\n\n private embeddings: EmbeddingsInterface;\n\n private headers: Headers;\n\n private requestConfig: RequestConfig;\n\n private textSplitter: TextSplitter;\n\n constructor({\n model,\n headers,\n embeddings,\n requestConfig,\n textSplitter,\n }: WebBrowserArgs) {\n super(...arguments);\n\n this.model = model;\n this.embeddings = embeddings;\n this.headers = headers ?? DEFAULT_HEADERS;\n this.requestConfig = {\n withCredentials: true,\n ...requestConfig,\n };\n this.textSplitter =\n textSplitter ??\n new RecursiveCharacterTextSplitter({\n chunkSize: 2000,\n chunkOverlap: 200,\n });\n }\n\n /** @ignore */\n async _call(inputs: string, runManager?: CallbackManagerForToolRun) {\n const [baseUrl, task] = parseInputs(inputs);\n const doSummary = !task;\n\n let text;\n try {\n const html = await getHtml(baseUrl, this.headers, this.requestConfig);\n text = getText(html, baseUrl, doSummary);\n } catch (e) {\n if (e) {\n return e.toString();\n }\n return \"There was a problem connecting to the site\";\n }\n\n const texts = await this.textSplitter.splitText(text);\n\n let context;\n // if we want a summary grab first 4\n if (doSummary) {\n context = texts.slice(0, 4).join(\"\\n\");\n }\n // search term well embed and grab top 4\n else {\n const docs = texts.map(\n (pageContent) =>\n new Document({\n pageContent,\n metadata: [],\n })\n );\n\n const vectorStore = await MemoryVectorStore.fromDocuments(\n docs,\n this.embeddings\n );\n const results = await vectorStore.similaritySearch(\n task,\n 4,\n undefined,\n runManager?.getChild(\"vectorstore\")\n );\n context = formatDocumentsAsString(results);\n }\n\n const input = `Text:${context}\\n\\nI need ${\n doSummary ? \"a summary\" : task\n } from the above text, also provide up to 5 markdown links from within that would be of interest (always including URL and text). Links should be provided, if present, in markdown syntax as a list under the heading \"Relevant Links:\".`;\n\n const chain = RunnableSequence.from([this.model, new StringOutputParser()]);\n return chain.invoke(input, runManager?.getChild());\n }\n\n name = \"web-browser\";\n\n description = `useful for when you need to find something on or summarize a webpage. input should be a comma separated list of \"ONE valid http URL including protocol\",\"what you want to find on the page or empty string for a summary\".`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAa,eAAe,WAAqC;CAC/D,MAAM,CAAC,SAAS,QAAQ,OAAO,MAAM,IAAI,CAAC,KAAK,UAAU;EACvD,IAAI,IAAI,MAAM,MAAM;AACpB,MAAI,EAAE,WAAW,KAAI,GAAG,EAAE,MAAM,EAAE,GAAG;AACrC,MAAI,EAAE,SAAS,KAAI,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG;AAEvC,MAAI,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG;AACvC,SAAO,EAAE,MAAM;GACf;AAEF,QAAO,CAAC,SAAS,KAAK;;AAGxB,MAAa,WACX,MACA,SACA,YACW;CAEX,MAAM,IAAI,QAA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,KAAK,KAAK;OAGnC;GACH,MAAM,OAAO,MAAM,KAChB,gBACC,IAAIC,0BAAAA,SAAS;IACX;IACA,UAAU,EAAE;IACb,CAAC,CACL;AAYD,aAAUC,sBAAAA,wBANM,OAJI,MAAMC,4BAAAA,kBAAkB,cAC1C,MACA,KAAK,WACN,EACiC,iBAChC,MACA,GACA,KAAA,GACA,YAAY,SAAS,cAAc,CACpC,CACyC;;EAG5C,MAAM,QAAQ,QAAQ,QAAQ,aAC5B,YAAY,cAAc,KAC3B;AAGD,SADcC,0BAAAA,iBAAiB,KAAK,CAAC,KAAK,OAAO,IAAIC,+BAAAA,oBAAoB,CAAC,CAAC,CAC9D,OAAO,OAAO,YAAY,UAAU,CAAC;;CAGpD,OAAO;CAEP,cAAc"}
1
+ {"version":3,"file":"webbrowser.cjs","names":["Tool","RecursiveCharacterTextSplitter","Document","formatDocumentsAsString","MemoryVectorStore","RunnableSequence","StringOutputParser"],"sources":["../../src/tools/webbrowser.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { Document } from \"@langchain/core/documents\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\n\nimport * as cheerio from \"cheerio\";\nimport {\n CallbackManager,\n CallbackManagerForToolRun,\n} from \"@langchain/core/callbacks/manager\";\n\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { RunnableSequence } from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n RecursiveCharacterTextSplitter,\n TextSplitter,\n} from \"@langchain/textsplitters\";\nimport { MemoryVectorStore } from \"../vectorstores/memory.js\";\n\nimport { formatDocumentsAsString } from \"../util/document.js\";\n\nexport const parseInputs = (inputs: string): [string, string] => {\n const [baseUrl, task] = inputs.split(\",\").map((input) => {\n let t = input.trim();\n t = t.startsWith('\"') ? t.slice(1) : t;\n t = t.endsWith('\"') ? t.slice(0, -1) : t;\n // it likes to put / at the end of urls, wont matter for task\n t = t.endsWith(\"/\") ? t.slice(0, -1) : t;\n return t.trim();\n });\n\n return [baseUrl, task];\n};\n\nexport const getText = (\n html: string,\n baseUrl: string,\n summary: boolean\n): string => {\n // scriptingEnabled so noscript elements are parsed\n const $ = cheerio.load(html, { scriptingEnabled: true });\n\n let text = \"\";\n\n // lets only get the body if its a summary, dont need to summarize header or footer etc\n const rootElement = summary ? \"body \" : \"*\";\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n $(`${rootElement}:not(style):not(script):not(svg)`).each((_i, elem: any) => {\n // we dont want duplicated content as we drill down so remove children\n let content = $(elem).clone().children().remove().end().text().trim();\n const $el = $(elem);\n\n // if its an ahref, print the content and url\n let href = $el.attr(\"href\");\n if ($el.prop(\"tagName\")?.toLowerCase() === \"a\" && href) {\n if (!href.startsWith(\"http\")) {\n try {\n href = new URL(href, baseUrl).toString();\n } catch {\n // if this fails thats fine, just no url for this\n href = \"\";\n }\n }\n\n const imgAlt = $el.find(\"img[alt]\").attr(\"alt\")?.trim();\n if (imgAlt) {\n content += ` ${imgAlt}`;\n }\n\n text += ` [${content}](${href})`;\n }\n // otherwise just print the content\n else if (content !== \"\") {\n text += ` ${content}`;\n }\n });\n\n return text.trim().replace(/\\n+/g, \" \");\n};\n\nconst getHtml = async (baseUrl: string, h: Headers, config: RequestConfig) => {\n const domain = new URL(baseUrl).hostname;\n\n const headers = { ...h };\n // these appear to be positional, which means they have to exist in the headers passed in\n headers.Host = domain;\n headers[\"Alt-Used\"] = domain;\n\n let htmlResponse;\n try {\n const fetchOptions: RequestInit = {\n method: \"GET\",\n headers,\n credentials: config.withCredentials ? \"include\" : \"same-origin\",\n ...config,\n };\n\n htmlResponse = await fetch(baseUrl, fetchOptions);\n\n if (!htmlResponse.ok) {\n throw new Error(`http response ${htmlResponse.status}`);\n }\n } catch (e) {\n if (\n e &&\n typeof e === \"object\" &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"http response\")\n ) {\n throw e;\n }\n throw e;\n }\n\n const allowedContentTypes = [\n \"text/html\",\n \"application/json\",\n \"application/xml\",\n \"application/javascript\",\n \"text/plain\",\n ];\n\n const contentType = htmlResponse.headers.get(\"content-type\") || \"\";\n const contentTypeArray = contentType.split(\";\");\n if (\n contentTypeArray[0] &&\n !allowedContentTypes.includes(contentTypeArray[0])\n ) {\n throw new Error(\"returned page was not utf8\");\n }\n return htmlResponse.text();\n};\n\nconst DEFAULT_HEADERS = {\n Accept:\n \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\",\n \"Accept-Encoding\": \"gzip, deflate\",\n \"Accept-Language\": \"en-US,en;q=0.5\",\n \"Alt-Used\": \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Connection: \"keep-alive\",\n Host: \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Referer: \"https://www.google.com/\",\n \"Sec-Fetch-Dest\": \"document\",\n \"Sec-Fetch-Mode\": \"navigate\",\n \"Sec-Fetch-Site\": \"cross-site\",\n \"Upgrade-Insecure-Requests\": \"1\",\n \"User-Agent\":\n \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0\",\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype Headers = Record<string, any>;\n\n/**\n * Configuration options for fetch requests, similar to axios config but for fetch\n */\nexport interface RequestConfig extends Omit<RequestInit, \"headers\"> {\n withCredentials?: boolean;\n}\n\n/**\n * Defines the arguments that can be passed to the WebBrowser constructor.\n * It extends the ToolParams interface and includes properties for a\n * language model, embeddings, HTTP headers, an Axios configuration, a\n * callback manager, and a text splitter.\n */\nexport interface WebBrowserArgs extends ToolParams {\n model: BaseLanguageModelInterface;\n\n embeddings: EmbeddingsInterface;\n\n headers?: Headers;\n\n requestConfig?: RequestConfig;\n\n /** @deprecated */\n callbackManager?: CallbackManager;\n\n textSplitter?: TextSplitter;\n}\n\n/**\n * A class designed to interact with web pages, either to extract\n * information from them or to summarize their content. It uses the native\n * fetch API to send HTTP requests and the cheerio library to parse the\n * returned HTML.\n * @example\n * ```typescript\n * const browser = new WebBrowser({\n * model: new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 }),\n * embeddings: new OpenAIEmbeddings({}),\n * });\n * const result = await browser.invoke(\"https:exampleurl.com\");\n * ```\n */\nexport class WebBrowser extends Tool {\n static lc_name() {\n return \"WebBrowser\";\n }\n\n get lc_namespace() {\n return [...super.lc_namespace, \"webbrowser\"];\n }\n\n private model: BaseLanguageModelInterface;\n\n private embeddings: EmbeddingsInterface;\n\n private headers: Headers;\n\n private requestConfig: RequestConfig;\n\n private textSplitter: TextSplitter;\n\n constructor({\n model,\n headers,\n embeddings,\n requestConfig,\n textSplitter,\n }: WebBrowserArgs) {\n super(...arguments);\n\n this.model = model;\n this.embeddings = embeddings;\n this.headers = headers ?? DEFAULT_HEADERS;\n this.requestConfig = {\n withCredentials: true,\n ...requestConfig,\n };\n this.textSplitter =\n textSplitter ??\n new RecursiveCharacterTextSplitter({\n chunkSize: 2000,\n chunkOverlap: 200,\n });\n }\n\n /** @ignore */\n async _call(inputs: string, runManager?: CallbackManagerForToolRun) {\n const [baseUrl, task] = parseInputs(inputs);\n const doSummary = !task;\n\n let text;\n try {\n const html = await getHtml(baseUrl, this.headers, this.requestConfig);\n text = getText(html, baseUrl, doSummary);\n } catch (e) {\n if (e) {\n return e.toString();\n }\n return \"There was a problem connecting to the site\";\n }\n\n const texts = await this.textSplitter.splitText(text);\n\n let context;\n // if we want a summary grab first 4\n if (doSummary) {\n context = texts.slice(0, 4).join(\"\\n\");\n }\n // search term well embed and grab top 4\n else {\n const docs = texts.map(\n (pageContent) =>\n new Document({\n pageContent,\n metadata: [],\n })\n );\n\n const vectorStore = await MemoryVectorStore.fromDocuments(\n docs,\n this.embeddings\n );\n const results = await vectorStore.similaritySearch(\n task,\n 4,\n undefined,\n runManager?.getChild(\"vectorstore\")\n );\n context = formatDocumentsAsString(results);\n }\n\n const input = `Text:${context}\\n\\nI need ${\n doSummary ? \"a summary\" : task\n } from the above text, also provide up to 5 markdown links from within that would be of interest (always including URL and text). Links should be provided, if present, in markdown syntax as a list under the heading \"Relevant Links:\".`;\n\n const chain = RunnableSequence.from([this.model, new StringOutputParser()]);\n return chain.invoke(input, runManager?.getChild());\n }\n\n name = \"web-browser\";\n\n description = `useful for when you need to find something on or summarize a webpage. input should be a comma separated list of \"ONE valid http URL including protocol\",\"what you want to find on the page or empty string for a summary\".`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,MAAa,eAAe,WAAqC;CAC/D,MAAM,CAAC,SAAS,QAAQ,OAAO,MAAM,IAAI,CAAC,KAAK,UAAU;EACvD,IAAI,IAAI,MAAM,MAAM;AACpB,MAAI,EAAE,WAAW,KAAI,GAAG,EAAE,MAAM,EAAE,GAAG;AACrC,MAAI,EAAE,SAAS,KAAI,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG;AAEvC,MAAI,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG;AACvC,SAAO,EAAE,MAAM;GACf;AAEF,QAAO,CAAC,SAAS,KAAK;;AAGxB,MAAa,WACX,MACA,SACA,YACW;CAEX,MAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,kBAAkB,MAAM,CAAC;CAExD,IAAI,OAAO;AAMX,GAAE,GAHkB,UAAU,UAAU,IAGvB,kCAAkC,CAAC,MAAM,IAAI,SAAc;EAE1E,IAAI,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM;EACrE,MAAM,MAAM,EAAE,KAAK;EAGnB,IAAI,OAAO,IAAI,KAAK,OAAO;AAC3B,MAAI,IAAI,KAAK,UAAU,EAAE,aAAa,KAAK,OAAO,MAAM;AACtD,OAAI,CAAC,KAAK,WAAW,OAAO,CAC1B,KAAI;AACF,WAAO,IAAI,IAAI,MAAM,QAAQ,CAAC,UAAU;WAClC;AA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Ac"}
@@ -1 +1 @@
1
- {"version":3,"file":"webbrowser.d.cts","names":[],"sources":["../../src/tools/webbrowser.ts"],"mappings":";;;;;;;cAqBa,WAAA,GAAW,MAAA;AAAA,cAaX,OAAA,GAAO,IAAA,UAAA,OAAA,UAAA,OAAA;AAAA,KAuHf,OAAA,GAAU,MAAA;;;;UAKE,aAAA,SAAsB,IAAA,CAAK,WAAA;EAC1C,eAAA;AAAA;;;;;;;UASe,cAAA,SAAuB,UAAA;EACtC,KAAA,EAAO,0BAAA;EAEP,UAAA,EAAY,mBAAA;EAEZ,OAAA,GAAU,OAAA;EAEV,aAAA,GAAgB,aAAA;EAtBG;EAyBnB,eAAA,GAAkB,eAAA;EAElB,YAAA,GAAe,YAAA;AAAA;;;;;;;AAZjB;;;;;;;;cA6Ba,UAAA,SAAmB,IAAA;EAAA,OACvB,OAAA,CAAA;EAAA,IAIH,YAAA,CAAA;EAAA,QAII,KAAA;EAAA,QAEA,UAAA;EAAA,QAEA,OAAA;EAAA,QAEA,aAAA;EAAA,QAEA,YAAA;EAER,WAAA,CAAA;IACE,KAAA;IACA,OAAA;IACA,UAAA;IACA,aAAA;IACA;EAAA,GACC,cAAA;EAjDH;EAoEM,KAAA,CAAM,MAAA,UAAgB,UAAA,GAAa,yBAAA,GAAyB,OAAA;EAqDlE,IAAA;EAEA,WAAA;AAAA"}
1
+ {"version":3,"file":"webbrowser.d.cts","names":[],"sources":["../../src/tools/webbrowser.ts"],"mappings":";;;;;;;cAqBa,WAAA,GAAW,MAAA;AAAA,cAaX,OAAA,GAAO,IAAA,UACN,OAAA,UACG,OAAA;AAAA,KAqHZ,OAAA,GAAU,MAAA;;;;UAKE,aAAA,SAAsB,IAAA,CAAK,WAAA;EAC1C,eAAA;AAAA;;;;;;;UASe,cAAA,SAAuB,UAAA;EACtC,KAAA,EAAO,0BAAA;EAEP,UAAA,EAAY,mBAAA;EAEZ,OAAA,GAAU,OAAA;EAEV,aAAA,GAAgB,aAAA;EAtBG;EAyBnB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E,IAAA;EAEA,WAAA;AAAA"}
1
+ {"version":3,"file":"webbrowser.d.ts","names":[],"sources":["../../src/tools/webbrowser.ts"],"mappings":";;;;;;;cAqBa,WAAA,GAAW,MAAA;AAAA,cAaX,OAAA,GAAO,IAAA,UACN,OAAA,UACG,OAAA;AAAA,KAqHZ,OAAA,GAAU,MAAA;;;;UAKE,aAAA,SAAsB,IAAA,CAAK,WAAA;EAC1C,eAAA;AAAA;;;;;;;UASe,cAAA,SAAuB,UAAA;EACtC,KAAA,EAAO,0BAAA;EAEP,UAAA,EAAY,mBAAA;EAEZ,OAAA,GAAU,OAAA;EAEV,aAAA,GAAgB,aAAA;EAtBG;EAyBnB,eAAA,GAAkB,eAAA;EAElB,YAAA,GAAe,YAAA;AAAA;;;;;;;AAZjB;;;;;;;;cA6Ba,UAAA,SAAmB,IAAA;EAAA,OACvB,OAAA,CAAA;EAAA,IAIH,YAAA,CAAA;EAAA,QAII,KAAA;EAAA,QAEA,UAAA;EAAA,QAEA,OAAA;EAAA,QAEA,aAAA;EAAA,QAEA,YAAA;EAER,WAAA,CAAA;IACE,KAAA;IACA,OAAA;IACA,UAAA;IACA,aAAA;IACA;EAAA,GACC,cAAA;EAjDH;EAoEM,KAAA,CAAM,MAAA,UAAgB,UAAA,GAAa,yBAAA,GAAyB,OAAA;EAqDlE,IAAA;EAEA,WAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"webbrowser.js","names":[],"sources":["../../src/tools/webbrowser.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { Document } from \"@langchain/core/documents\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\n\nimport * as cheerio from \"cheerio\";\nimport {\n CallbackManager,\n CallbackManagerForToolRun,\n} from \"@langchain/core/callbacks/manager\";\n\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { RunnableSequence } from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n RecursiveCharacterTextSplitter,\n TextSplitter,\n} from \"@langchain/textsplitters\";\nimport { MemoryVectorStore } from \"../vectorstores/memory.js\";\n\nimport { formatDocumentsAsString } from \"../util/document.js\";\n\nexport const parseInputs = (inputs: string): [string, string] => {\n const [baseUrl, task] = inputs.split(\",\").map((input) => {\n let t = input.trim();\n t = t.startsWith('\"') ? t.slice(1) : t;\n t = t.endsWith('\"') ? t.slice(0, -1) : t;\n // it likes to put / at the end of urls, wont matter for task\n t = t.endsWith(\"/\") ? t.slice(0, -1) : t;\n return t.trim();\n });\n\n return [baseUrl, task];\n};\n\nexport const getText = (\n html: string,\n baseUrl: string,\n summary: boolean\n): string => {\n // scriptingEnabled so noscript elements are parsed\n const $ = cheerio.load(html, { scriptingEnabled: true });\n\n let text = \"\";\n\n // lets only get the body if its a summary, dont need to summarize header or footer etc\n const rootElement = summary ? \"body \" : \"*\";\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n $(`${rootElement}:not(style):not(script):not(svg)`).each((_i, elem: any) => {\n // we dont want duplicated content as we drill down so remove children\n let content = $(elem).clone().children().remove().end().text().trim();\n const $el = $(elem);\n\n // if its an ahref, print the content and url\n let href = $el.attr(\"href\");\n if ($el.prop(\"tagName\")?.toLowerCase() === \"a\" && href) {\n if (!href.startsWith(\"http\")) {\n try {\n href = new URL(href, baseUrl).toString();\n } catch {\n // if this fails thats fine, just no url for this\n href = \"\";\n }\n }\n\n const imgAlt = $el.find(\"img[alt]\").attr(\"alt\")?.trim();\n if (imgAlt) {\n content += ` ${imgAlt}`;\n }\n\n text += ` [${content}](${href})`;\n }\n // otherwise just print the content\n else if (content !== \"\") {\n text += ` ${content}`;\n }\n });\n\n return text.trim().replace(/\\n+/g, \" \");\n};\n\nconst getHtml = async (baseUrl: string, h: Headers, config: RequestConfig) => {\n const domain = new URL(baseUrl).hostname;\n\n const headers = { ...h };\n // these appear to be positional, which means they have to exist in the headers passed in\n headers.Host = domain;\n headers[\"Alt-Used\"] = domain;\n\n let htmlResponse;\n try {\n const fetchOptions: RequestInit = {\n method: \"GET\",\n headers,\n credentials: config.withCredentials ? \"include\" : \"same-origin\",\n ...config,\n };\n\n htmlResponse = await fetch(baseUrl, fetchOptions);\n\n if (!htmlResponse.ok) {\n throw new Error(`http response ${htmlResponse.status}`);\n }\n } catch (e) {\n if (\n e &&\n typeof e === \"object\" &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"http response\")\n ) {\n throw e;\n }\n throw e;\n }\n\n const allowedContentTypes = [\n \"text/html\",\n \"application/json\",\n \"application/xml\",\n \"application/javascript\",\n \"text/plain\",\n ];\n\n const contentType = htmlResponse.headers.get(\"content-type\") || \"\";\n const contentTypeArray = contentType.split(\";\");\n if (\n contentTypeArray[0] &&\n !allowedContentTypes.includes(contentTypeArray[0])\n ) {\n throw new Error(\"returned page was not utf8\");\n }\n return htmlResponse.text();\n};\n\nconst DEFAULT_HEADERS = {\n Accept:\n \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\",\n \"Accept-Encoding\": \"gzip, deflate\",\n \"Accept-Language\": \"en-US,en;q=0.5\",\n \"Alt-Used\": \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Connection: \"keep-alive\",\n Host: \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Referer: \"https://www.google.com/\",\n \"Sec-Fetch-Dest\": \"document\",\n \"Sec-Fetch-Mode\": \"navigate\",\n \"Sec-Fetch-Site\": \"cross-site\",\n \"Upgrade-Insecure-Requests\": \"1\",\n \"User-Agent\":\n \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0\",\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Headers = Record<string, any>;\n\n/**\n * Configuration options for fetch requests, similar to axios config but for fetch\n */\nexport interface RequestConfig extends Omit<RequestInit, \"headers\"> {\n withCredentials?: boolean;\n}\n\n/**\n * Defines the arguments that can be passed to the WebBrowser constructor.\n * It extends the ToolParams interface and includes properties for a\n * language model, embeddings, HTTP headers, an Axios configuration, a\n * callback manager, and a text splitter.\n */\nexport interface WebBrowserArgs extends ToolParams {\n model: BaseLanguageModelInterface;\n\n embeddings: EmbeddingsInterface;\n\n headers?: Headers;\n\n requestConfig?: RequestConfig;\n\n /** @deprecated */\n callbackManager?: CallbackManager;\n\n textSplitter?: TextSplitter;\n}\n\n/**\n * A class designed to interact with web pages, either to extract\n * information from them or to summarize their content. It uses the native\n * fetch API to send HTTP requests and the cheerio library to parse the\n * returned HTML.\n * @example\n * ```typescript\n * const browser = new WebBrowser({\n * model: new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 }),\n * embeddings: new OpenAIEmbeddings({}),\n * });\n * const result = await browser.invoke(\"https:exampleurl.com\");\n * ```\n */\nexport class WebBrowser extends Tool {\n static lc_name() {\n return \"WebBrowser\";\n }\n\n get lc_namespace() {\n return [...super.lc_namespace, \"webbrowser\"];\n }\n\n private model: BaseLanguageModelInterface;\n\n private embeddings: EmbeddingsInterface;\n\n private headers: Headers;\n\n private requestConfig: RequestConfig;\n\n private textSplitter: TextSplitter;\n\n constructor({\n model,\n headers,\n embeddings,\n requestConfig,\n textSplitter,\n }: WebBrowserArgs) {\n super(...arguments);\n\n this.model = model;\n this.embeddings = embeddings;\n this.headers = headers ?? DEFAULT_HEADERS;\n this.requestConfig = {\n withCredentials: true,\n ...requestConfig,\n };\n this.textSplitter =\n textSplitter ??\n new RecursiveCharacterTextSplitter({\n chunkSize: 2000,\n chunkOverlap: 200,\n });\n }\n\n /** @ignore */\n async _call(inputs: string, runManager?: CallbackManagerForToolRun) {\n const [baseUrl, task] = parseInputs(inputs);\n const doSummary = !task;\n\n let text;\n try {\n const html = await getHtml(baseUrl, this.headers, this.requestConfig);\n text = getText(html, baseUrl, doSummary);\n } catch (e) {\n if (e) {\n return e.toString();\n }\n return \"There was a problem connecting to the site\";\n }\n\n const texts = await this.textSplitter.splitText(text);\n\n let context;\n // if we want a summary grab first 4\n if (doSummary) {\n context = texts.slice(0, 4).join(\"\\n\");\n }\n // search term well embed and grab top 4\n else {\n const docs = texts.map(\n (pageContent) =>\n new Document({\n pageContent,\n metadata: [],\n })\n );\n\n const vectorStore = await MemoryVectorStore.fromDocuments(\n docs,\n this.embeddings\n );\n const results = await vectorStore.similaritySearch(\n task,\n 4,\n undefined,\n runManager?.getChild(\"vectorstore\")\n );\n context = formatDocumentsAsString(results);\n }\n\n const input = `Text:${context}\\n\\nI need ${\n doSummary ? \"a summary\" : task\n } from the above text, also provide up to 5 markdown links from within that would be of interest (always including URL and text). Links should be provided, if present, in markdown syntax as a list under the heading \"Relevant Links:\".`;\n\n const chain = RunnableSequence.from([this.model, new StringOutputParser()]);\n return chain.invoke(input, runManager?.getChild());\n }\n\n name = \"web-browser\";\n\n description = `useful for when you need to find something on or summarize a webpage. input should be a comma separated list of \"ONE valid http URL including protocol\",\"what you want to find on the page or empty string for a summary\".`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,MAAa,eAAe,WAAqC;CAC/D,MAAM,CAAC,SAAS,QAAQ,OAAO,MAAM,IAAI,CAAC,KAAK,UAAU;EACvD,IAAI,IAAI,MAAM,MAAM;AACpB,MAAI,EAAE,WAAW,KAAI,GAAG,EAAE,MAAM,EAAE,GAAG;AACrC,MAAI,EAAE,SAAS,KAAI,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG;AAEvC,MAAI,EAAE,SAAS,IAAI,GAAG,EAAE,MAAM,GAAG,GAAG,GAAG;AACvC,SAAO,EAAE,MAAM;GACf;AAEF,QAAO,CAAC,SAAS,KAAK;;AAGxB,MAAa,WACX,MACA,SACA,YACW;CAEX,MAAM,IAAI,QAAQ,KAAK,MAAM,EAAE,kBAAkB,MAAM,CAAC;CAExD,IAAI,OAAO;AAMX,GAAE,GAHkB,UAAU,UAAU,IAGvB,kCAAkC,CAAC,MAAM,IAAI,SAAc;EAE1E,IAAI,UAAU,EAAE,KAAK,CA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GACA,KAAA,GACA,YAAY,SAAS,cAAc,CACpC,CACyC;;EAG5C,MAAM,QAAQ,QAAQ,QAAQ,aAC5B,YAAY,cAAc,KAC3B;AAGD,SADc,iBAAiB,KAAK,CAAC,KAAK,OAAO,IAAI,oBAAoB,CAAC,CAAC,CAC9D,OAAO,OAAO,YAAY,UAAU,CAAC;;CAGpD,OAAO;CAEP,cAAc"}
1
+ {"version":3,"file":"webbrowser.js","names":[],"sources":["../../src/tools/webbrowser.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { Document } from \"@langchain/core/documents\";\nimport type { EmbeddingsInterface } from \"@langchain/core/embeddings\";\n\nimport * as cheerio from \"cheerio\";\nimport {\n CallbackManager,\n CallbackManagerForToolRun,\n} from \"@langchain/core/callbacks/manager\";\n\nimport { Tool, ToolParams } from \"@langchain/core/tools\";\nimport { RunnableSequence } from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n RecursiveCharacterTextSplitter,\n TextSplitter,\n} from \"@langchain/textsplitters\";\nimport { MemoryVectorStore } from \"../vectorstores/memory.js\";\n\nimport { formatDocumentsAsString } from \"../util/document.js\";\n\nexport const parseInputs = (inputs: string): [string, string] => {\n const [baseUrl, task] = inputs.split(\",\").map((input) => {\n let t = input.trim();\n t = t.startsWith('\"') ? t.slice(1) : t;\n t = t.endsWith('\"') ? t.slice(0, -1) : t;\n // it likes to put / at the end of urls, wont matter for task\n t = t.endsWith(\"/\") ? t.slice(0, -1) : t;\n return t.trim();\n });\n\n return [baseUrl, task];\n};\n\nexport const getText = (\n html: string,\n baseUrl: string,\n summary: boolean\n): string => {\n // scriptingEnabled so noscript elements are parsed\n const $ = cheerio.load(html, { scriptingEnabled: true });\n\n let text = \"\";\n\n // lets only get the body if its a summary, dont need to summarize header or footer etc\n const rootElement = summary ? \"body \" : \"*\";\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n $(`${rootElement}:not(style):not(script):not(svg)`).each((_i, elem: any) => {\n // we dont want duplicated content as we drill down so remove children\n let content = $(elem).clone().children().remove().end().text().trim();\n const $el = $(elem);\n\n // if its an ahref, print the content and url\n let href = $el.attr(\"href\");\n if ($el.prop(\"tagName\")?.toLowerCase() === \"a\" && href) {\n if (!href.startsWith(\"http\")) {\n try {\n href = new URL(href, baseUrl).toString();\n } catch {\n // if this fails thats fine, just no url for this\n href = \"\";\n }\n }\n\n const imgAlt = $el.find(\"img[alt]\").attr(\"alt\")?.trim();\n if (imgAlt) {\n content += ` ${imgAlt}`;\n }\n\n text += ` [${content}](${href})`;\n }\n // otherwise just print the content\n else if (content !== \"\") {\n text += ` ${content}`;\n }\n });\n\n return text.trim().replace(/\\n+/g, \" \");\n};\n\nconst getHtml = async (baseUrl: string, h: Headers, config: RequestConfig) => {\n const domain = new URL(baseUrl).hostname;\n\n const headers = { ...h };\n // these appear to be positional, which means they have to exist in the headers passed in\n headers.Host = domain;\n headers[\"Alt-Used\"] = domain;\n\n let htmlResponse;\n try {\n const fetchOptions: RequestInit = {\n method: \"GET\",\n headers,\n credentials: config.withCredentials ? \"include\" : \"same-origin\",\n ...config,\n };\n\n htmlResponse = await fetch(baseUrl, fetchOptions);\n\n if (!htmlResponse.ok) {\n throw new Error(`http response ${htmlResponse.status}`);\n }\n } catch (e) {\n if (\n e &&\n typeof e === \"object\" &&\n \"message\" in e &&\n typeof e.message === \"string\" &&\n e.message.includes(\"http response\")\n ) {\n throw e;\n }\n throw e;\n }\n\n const allowedContentTypes = [\n \"text/html\",\n \"application/json\",\n \"application/xml\",\n \"application/javascript\",\n \"text/plain\",\n ];\n\n const contentType = htmlResponse.headers.get(\"content-type\") || \"\";\n const contentTypeArray = contentType.split(\";\");\n if (\n contentTypeArray[0] &&\n !allowedContentTypes.includes(contentTypeArray[0])\n ) {\n throw new Error(\"returned page was not utf8\");\n }\n return htmlResponse.text();\n};\n\nconst DEFAULT_HEADERS = {\n Accept:\n \"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8\",\n \"Accept-Encoding\": \"gzip, deflate\",\n \"Accept-Language\": \"en-US,en;q=0.5\",\n \"Alt-Used\": \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Connection: \"keep-alive\",\n Host: \"LEAVE-THIS-KEY-SET-BY-TOOL\",\n Referer: \"https://www.google.com/\",\n \"Sec-Fetch-Dest\": \"document\",\n \"Sec-Fetch-Mode\": \"navigate\",\n \"Sec-Fetch-Site\": \"cross-site\",\n \"Upgrade-Insecure-Requests\": \"1\",\n \"User-Agent\":\n \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0\",\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype Headers = Record<string, any>;\n\n/**\n * Configuration options for fetch requests, similar to axios config but for fetch\n */\nexport interface RequestConfig extends Omit<RequestInit, \"headers\"> {\n withCredentials?: boolean;\n}\n\n/**\n * Defines the arguments that can be passed to the WebBrowser constructor.\n * It extends the ToolParams interface and includes properties for a\n * language model, embeddings, HTTP headers, an Axios configuration, a\n * callback manager, and a text splitter.\n */\nexport interface WebBrowserArgs extends ToolParams {\n model: BaseLanguageModelInterface;\n\n embeddings: EmbeddingsInterface;\n\n headers?: Headers;\n\n requestConfig?: RequestConfig;\n\n /** @deprecated */\n callbackManager?: CallbackManager;\n\n textSplitter?: TextSplitter;\n}\n\n/**\n * A class designed to interact with web pages, either to extract\n * information from them or to summarize their content. It uses the native\n * fetch API to send HTTP requests and the cheerio library to parse the\n * returned HTML.\n * @example\n * ```typescript\n * const browser = new WebBrowser({\n * model: new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 }),\n * embeddings: new OpenAIEmbeddings({}),\n * });\n * const result = await browser.invoke(\"https:exampleurl.com\");\n * ```\n */\nexport class WebBrowser extends Tool {\n static lc_name() {\n return \"WebBrowser\";\n }\n\n get lc_namespace() {\n return [...super.lc_namespace, \"webbrowser\"];\n }\n\n private model: BaseLanguageModelInterface;\n\n private embeddings: EmbeddingsInterface;\n\n private headers: Headers;\n\n private requestConfig: RequestConfig;\n\n private textSplitter: TextSplitter;\n\n constructor({\n model,\n headers,\n embeddings,\n requestConfig,\n textSplitter,\n }: WebBrowserArgs) {\n super(...arguments);\n\n this.model = model;\n this.embeddings = embeddings;\n this.headers = headers ?? DEFAULT_HEADERS;\n this.requestConfig = {\n withCredentials: true,\n ...requestConfig,\n };\n this.textSplitter =\n textSplitter ??\n new RecursiveCharacterTextSplitter({\n chunkSize: 2000,\n chunkOverlap: 200,\n });\n }\n\n /** @ignore */\n async _call(inputs: string, runManager?: CallbackManagerForToolRun) {\n const [baseUrl, task] = parseInputs(inputs);\n const doSummary = !task;\n\n let text;\n try {\n const html = await getHtml(baseUrl, this.headers, this.requestConfig);\n text = getText(html, baseUrl, doSummary);\n } catch (e) {\n if (e) {\n return e.toString();\n }\n return \"There was a problem connecting to the site\";\n }\n\n const texts = await this.textSplitter.splitText(text);\n\n let context;\n // if we want a summary grab first 4\n if (doSummary) {\n context = texts.slice(0, 4).join(\"\\n\");\n }\n // search term well embed and grab top 4\n else {\n const docs = texts.map(\n (pageContent) =>\n new Document({\n pageContent,\n metadata: [],\n })\n );\n\n const vectorStore = await MemoryVectorStore.fromDocuments(\n docs,\n this.embeddings\n );\n const results = await vectorStore.similaritySearch(\n task,\n 4,\n undefined,\n runManager?.getChild(\"vectorstore\")\n );\n context = formatDocumentsAsString(results);\n }\n\n const input = `Text:${context}\\n\\nI need ${\n doSummary ? \"a summary\" : task\n } from the above text, also provide up to 5 markdown links from within that would be of interest (always including URL and text). Links should be provided, if present, in markdown syntax as a list under the heading \"Relevant Links:\".`;\n\n const chain = RunnableSequence.from([this.model, new StringOutputParser()]);\n return chain.invoke(input, runManager?.getChild());\n }\n\n name = \"web-browser\";\n\n description = `useful for when you need to find something on or summarize a webpage. input should be a comma separated list of \"ONE valid http URL including protocol\",\"what you want to find on the page or empty string for a summary\".`;\n}\n"],"mappings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BACA,IAAI,+BAA+B;GACjC,WAAW;GACX,cAAc;GACf,CAAC;;;CAIN,MAAM,MAAM,QAAgB,YAAwC;EAClE,MAAM,CAAC,SAAS,QAAQ,YAAY,OAAO;EAC3C,MAAM,YAAY,CAAC;EAEnB,IAAI;AACJ,MAAI;AAEF,UAAO,QADM,MAAM,QAAQ,SAAS,KAAK,SAAS,KAAK,cAAc,EAChD,SAAS,UAAU;WACjC,GAAG;AACV,OAAI,EACF,QAAO,EAAE,UAAU;AAErB,UAAO;;EAGT,MAAM,QAAQ,MAAM,KAAK,aAAa,UAAU,KAAK;EAErD,IAAI;AAEJ,MAAI,UACF,WAAU,MAAM,MAAM,GAAG,EAAE,CAAC,KAAK,KAAK;OAGnC;GACH,MAAM,OAAO,MAAM,KAChB,gBACC,IAAI,SAAS;IACX;IACA,UAAU,EAAE;IACb,CAAC,CACL;AAYD,aAAU,wBANM,OAJI,MAAM,kBAAkB,cAC1C,MACA,KAAK,WACN,EACiC,iBAChC,MACA,GACA,KAAA,GACA,YAAY,SAAS,cAAc,CACpC,CACyC;;EAG5C,MAAM,QAAQ,QAAQ,QAAQ,aAC5B,YAAY,cAAc,KAC3B;AAGD,SADc,iBAAiB,KAAK,CAAC,KAAK,OAAO,IAAI,oBAAoB,CAAC,CAAC,CAC9D,OAAO,OAAO,YAAY,UAAU,CAAC;;CAGpD,OAAO;CAEP,cAAc"}
@@ -8,7 +8,7 @@ import { Document } from "@langchain/core/documents";
8
8
  * @param documents
9
9
  * @returns A string of the documents page content, separated by newlines.
10
10
  */
11
- declare const formatDocumentsAsString: (documents: Document<Record<string, any>>[]) => string;
11
+ declare const formatDocumentsAsString: (documents: Document[]) => string;
12
12
  //#endregion
13
13
  export { formatDocumentsAsString };
14
14
  //# sourceMappingURL=document.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.cts","names":[],"sources":["../../src/util/document.ts"],"mappings":";;;;;AASA;;;;;cAAa,uBAAA,GAAuB,SAAA,EAAA,QAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"document.d.cts","names":[],"sources":["../../src/util/document.ts"],"mappings":";;;;;AASA;;;;;cAAa,uBAAA,GAAuB,SAAA,EAAe,QAAA"}
@@ -8,7 +8,7 @@ import { Document } from "@langchain/core/documents";
8
8
  * @param documents
9
9
  * @returns A string of the documents page content, separated by newlines.
10
10
  */
11
- declare const formatDocumentsAsString: (documents: Document<Record<string, any>>[]) => string;
11
+ declare const formatDocumentsAsString: (documents: Document[]) => string;
12
12
  //#endregion
13
13
  export { formatDocumentsAsString };
14
14
  //# sourceMappingURL=document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","names":[],"sources":["../../src/util/document.ts"],"mappings":";;;;;AASA;;;;;cAAa,uBAAA,GAAuB,SAAA,EAAA,QAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"document.d.ts","names":[],"sources":["../../src/util/document.ts"],"mappings":";;;;;AASA;;;;;cAAa,uBAAA,GAAuB,SAAA,EAAe,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/util/is-network-error/index.js"],"sourcesContent":["/* eslint-disable */\nconst objectToString = Object.prototype.toString;\n\nconst isError = (value) => objectToString.call(value) === \"[object Error]\";\n\nconst errorMessages = new Set([\n \"network error\", // Chrome\n \"Failed to fetch\", // Chrome\n \"NetworkError when attempting to fetch resource.\", // Firefox\n \"The Internet connection appears to be offline.\", // Safari 16\n \"Network request failed\", // `cross-fetch`\n \"fetch failed\", // Undici (Node.js)\n \"terminated\", // Undici (Node.js)\n \" A network error occurred.\", // Bun (WebKit)\n \"Network connection lost\", // Cloudflare Workers (fetch)\n]);\n\nexport default function isNetworkError(error) {\n const isValid =\n error &&\n isError(error) &&\n error.name === \"TypeError\" &&\n typeof error.message === \"string\";\n\n if (!isValid) {\n return false;\n }\n\n const { message, stack } = error;\n\n // Safari 17+ has generic message but no stack for network errors\n if (message === \"Load failed\") {\n return (\n stack === undefined ||\n // Sentry adds its own stack trace to the fetch error, so also check for that\n \"__sentry_captured__\" in error\n );\n }\n\n // Deno network errors start with specific text\n if (message.startsWith(\"error sending request for url\")) {\n return true;\n }\n\n // Standard network error messages\n return errorMessages.has(message);\n}\n"],"mappings":";AACA,MAAM,iBAAiB,OAAO,UAAU;AAExC,MAAM,WAAW,UAAU,eAAe,KAAK,MAAM,KAAK;AAE1D,MAAM,gBAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAwB,eAAe,OAAO;AAO5C,KAAI,EALF,SACA,QAAQ,MAAM,IACd,MAAM,SAAS,eACf,OAAO,MAAM,YAAY,UAGzB,QAAO;CAGT,MAAM,EAAE,SAAS,UAAU;AAG3B,KAAI,YAAY,cACd,QACE,UAAU,KAAA,KAEV,yBAAyB;AAK7B,KAAI,QAAQ,WAAW,gCAAgC,CACrD,QAAO;AAIT,QAAO,cAAc,IAAI,QAAQ"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../src/util/is-network-error/index.js"],"sourcesContent":["/* oxlint-disable */\nconst objectToString = Object.prototype.toString;\n\nconst isError = (value) => objectToString.call(value) === \"[object Error]\";\n\nconst errorMessages = new Set([\n \"network error\", // Chrome\n \"Failed to fetch\", // Chrome\n \"NetworkError when attempting to fetch resource.\", // Firefox\n \"The Internet connection appears to be offline.\", // Safari 16\n \"Network request failed\", // `cross-fetch`\n \"fetch failed\", // Undici (Node.js)\n \"terminated\", // Undici (Node.js)\n \" A network error occurred.\", // Bun (WebKit)\n \"Network connection lost\", // Cloudflare Workers (fetch)\n]);\n\nexport default function isNetworkError(error) {\n const isValid =\n error &&\n isError(error) &&\n error.name === \"TypeError\" &&\n typeof error.message === \"string\";\n\n if (!isValid) {\n return false;\n }\n\n const { message, stack } = error;\n\n // Safari 17+ has generic message but no stack for network errors\n if (message === \"Load failed\") {\n return (\n stack === undefined ||\n // Sentry adds its own stack trace to the fetch error, so also check for that\n \"__sentry_captured__\" in error\n );\n }\n\n // Deno network errors start with specific text\n if (message.startsWith(\"error sending request for url\")) {\n return true;\n }\n\n // Standard network error messages\n return errorMessages.has(message);\n}\n"],"mappings":";AACA,MAAM,iBAAiB,OAAO,UAAU;AAExC,MAAM,WAAW,UAAU,eAAe,KAAK,MAAM,KAAK;AAE1D,MAAM,gBAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAwB,eAAe,OAAO;AAO5C,KAAI,EALF,SACA,QAAQ,MAAM,IACd,MAAM,SAAS,eACf,OAAO,MAAM,YAAY,UAGzB,QAAO;CAGT,MAAM,EAAE,SAAS,UAAU;AAG3B,KAAI,YAAY,cACd,QACE,UAAU,KAAA,KAEV,yBAAyB;AAK7B,KAAI,QAAQ,WAAW,gCAAgC,CACrD,QAAO;AAIT,QAAO,cAAc,IAAI,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/util/is-network-error/index.js"],"sourcesContent":["/* eslint-disable */\nconst objectToString = Object.prototype.toString;\n\nconst isError = (value) => objectToString.call(value) === \"[object Error]\";\n\nconst errorMessages = new Set([\n \"network error\", // Chrome\n \"Failed to fetch\", // Chrome\n \"NetworkError when attempting to fetch resource.\", // Firefox\n \"The Internet connection appears to be offline.\", // Safari 16\n \"Network request failed\", // `cross-fetch`\n \"fetch failed\", // Undici (Node.js)\n \"terminated\", // Undici (Node.js)\n \" A network error occurred.\", // Bun (WebKit)\n \"Network connection lost\", // Cloudflare Workers (fetch)\n]);\n\nexport default function isNetworkError(error) {\n const isValid =\n error &&\n isError(error) &&\n error.name === \"TypeError\" &&\n typeof error.message === \"string\";\n\n if (!isValid) {\n return false;\n }\n\n const { message, stack } = error;\n\n // Safari 17+ has generic message but no stack for network errors\n if (message === \"Load failed\") {\n return (\n stack === undefined ||\n // Sentry adds its own stack trace to the fetch error, so also check for that\n \"__sentry_captured__\" in error\n );\n }\n\n // Deno network errors start with specific text\n if (message.startsWith(\"error sending request for url\")) {\n return true;\n }\n\n // Standard network error messages\n return errorMessages.has(message);\n}\n"],"mappings":";AACA,MAAM,iBAAiB,OAAO,UAAU;AAExC,MAAM,WAAW,UAAU,eAAe,KAAK,MAAM,KAAK;AAE1D,MAAM,gBAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAwB,eAAe,OAAO;AAO5C,KAAI,EALF,SACA,QAAQ,MAAM,IACd,MAAM,SAAS,eACf,OAAO,MAAM,YAAY,UAGzB,QAAO;CAGT,MAAM,EAAE,SAAS,UAAU;AAG3B,KAAI,YAAY,cACd,QACE,UAAU,KAAA,KAEV,yBAAyB;AAK7B,KAAI,QAAQ,WAAW,gCAAgC,CACrD,QAAO;AAIT,QAAO,cAAc,IAAI,QAAQ"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/util/is-network-error/index.js"],"sourcesContent":["/* oxlint-disable */\nconst objectToString = Object.prototype.toString;\n\nconst isError = (value) => objectToString.call(value) === \"[object Error]\";\n\nconst errorMessages = new Set([\n \"network error\", // Chrome\n \"Failed to fetch\", // Chrome\n \"NetworkError when attempting to fetch resource.\", // Firefox\n \"The Internet connection appears to be offline.\", // Safari 16\n \"Network request failed\", // `cross-fetch`\n \"fetch failed\", // Undici (Node.js)\n \"terminated\", // Undici (Node.js)\n \" A network error occurred.\", // Bun (WebKit)\n \"Network connection lost\", // Cloudflare Workers (fetch)\n]);\n\nexport default function isNetworkError(error) {\n const isValid =\n error &&\n isError(error) &&\n error.name === \"TypeError\" &&\n typeof error.message === \"string\";\n\n if (!isValid) {\n return false;\n }\n\n const { message, stack } = error;\n\n // Safari 17+ has generic message but no stack for network errors\n if (message === \"Load failed\") {\n return (\n stack === undefined ||\n // Sentry adds its own stack trace to the fetch error, so also check for that\n \"__sentry_captured__\" in error\n );\n }\n\n // Deno network errors start with specific text\n if (message.startsWith(\"error sending request for url\")) {\n return true;\n }\n\n // Standard network error messages\n return errorMessages.has(message);\n}\n"],"mappings":";AACA,MAAM,iBAAiB,OAAO,UAAU;AAExC,MAAM,WAAW,UAAU,eAAe,KAAK,MAAM,KAAK;AAE1D,MAAM,gBAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAwB,eAAe,OAAO;AAO5C,KAAI,EALF,SACA,QAAQ,MAAM,IACd,MAAM,SAAS,eACf,OAAO,MAAM,YAAY,UAGzB,QAAO;CAGT,MAAM,EAAE,SAAS,UAAU;AAG3B,KAAI,YAAY,cACd,QACE,UAAU,KAAA,KAEV,yBAAyB;AAK7B,KAAI,QAAQ,WAAW,gCAAgC,CACrD,QAAO;AAIT,QAAO,cAAc,IAAI,QAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"load.cjs","names":[],"sources":["../../src/util/load.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadValues = Record<string, any>;\n\nexport type FileLoader<T> = (\n text: string,\n filePath: string,\n values: LoadValues\n) => Promise<T>;\n\nexport const loadFromFile = async <T>(\n uri: string,\n loader: FileLoader<T>,\n values: LoadValues = {}\n): Promise<T> => {\n try {\n const fs = await import(\"node:fs/promises\");\n return loader(await fs.readFile(uri, { encoding: \"utf-8\" }), uri, values);\n } catch (e) {\n console.error(e);\n throw new Error(`Could not load file at ${uri}`);\n }\n};\n"],"mappings":";AASA,MAAa,eAAe,OAC1B,KACA,QACA,SAAqB,EAAE,KACR;AACf,KAAI;AAEF,SAAO,OAAO,OADH,MAAM,OAAO,qBACD,SAAS,KAAK,EAAE,UAAU,SAAS,CAAC,EAAE,KAAK,OAAO;UAClE,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,QAAM,IAAI,MAAM,0BAA0B,MAAM"}
1
+ {"version":3,"file":"load.cjs","names":[],"sources":["../../src/util/load.ts"],"sourcesContent":["// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadValues = Record<string, any>;\n\nexport type FileLoader<T> = (\n text: string,\n filePath: string,\n values: LoadValues\n) => Promise<T>;\n\nexport const loadFromFile = async <T>(\n uri: string,\n loader: FileLoader<T>,\n values: LoadValues = {}\n): Promise<T> => {\n try {\n const fs = await import(\"node:fs/promises\");\n return loader(await fs.readFile(uri, { encoding: \"utf-8\" }), uri, values);\n } catch (e) {\n console.error(e);\n throw new Error(`Could not load file at ${uri}`);\n }\n};\n"],"mappings":";AASA,MAAa,eAAe,OAC1B,KACA,QACA,SAAqB,EAAE,KACR;AACf,KAAI;AAEF,SAAO,OAAO,OADH,MAAM,OAAO,qBACD,SAAS,KAAK,EAAE,UAAU,SAAS,CAAC,EAAE,KAAK,OAAO;UAClE,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,QAAM,IAAI,MAAM,0BAA0B,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"load.js","names":[],"sources":["../../src/util/load.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadValues = Record<string, any>;\n\nexport type FileLoader<T> = (\n text: string,\n filePath: string,\n values: LoadValues\n) => Promise<T>;\n\nexport const loadFromFile = async <T>(\n uri: string,\n loader: FileLoader<T>,\n values: LoadValues = {}\n): Promise<T> => {\n try {\n const fs = await import(\"node:fs/promises\");\n return loader(await fs.readFile(uri, { encoding: \"utf-8\" }), uri, values);\n } catch (e) {\n console.error(e);\n throw new Error(`Could not load file at ${uri}`);\n }\n};\n"],"mappings":";AASA,MAAa,eAAe,OAC1B,KACA,QACA,SAAqB,EAAE,KACR;AACf,KAAI;AAEF,SAAO,OAAO,OADH,MAAM,OAAO,qBACD,SAAS,KAAK,EAAE,UAAU,SAAS,CAAC,EAAE,KAAK,OAAO;UAClE,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,QAAM,IAAI,MAAM,0BAA0B,MAAM"}
1
+ {"version":3,"file":"load.js","names":[],"sources":["../../src/util/load.ts"],"sourcesContent":["// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type LoadValues = Record<string, any>;\n\nexport type FileLoader<T> = (\n text: string,\n filePath: string,\n values: LoadValues\n) => Promise<T>;\n\nexport const loadFromFile = async <T>(\n uri: string,\n loader: FileLoader<T>,\n values: LoadValues = {}\n): Promise<T> => {\n try {\n const fs = await import(\"node:fs/promises\");\n return loader(await fs.readFile(uri, { encoding: \"utf-8\" }), uri, values);\n } catch (e) {\n console.error(e);\n throw new Error(`Could not load file at ${uri}`);\n }\n};\n"],"mappings":";AASA,MAAa,eAAe,OAC1B,KACA,QACA,SAAqB,EAAE,KACR;AACf,KAAI;AAEF,SAAO,OAAO,OADH,MAAM,OAAO,qBACD,SAAS,KAAK,EAAE,UAAU,SAAS,CAAC,EAAE,KAAK,OAAO;UAClE,GAAG;AACV,UAAQ,MAAM,EAAE;AAChB,QAAM,IAAI,MAAM,0BAA0B,MAAM"}
@@ -1 +1 @@
1
- {"version":3,"file":"openapi.cjs","names":["yaml"],"sources":["../../src/util/openapi.ts"],"sourcesContent":["import * as yaml from \"js-yaml\";\nimport { OpenAPIV3, OpenAPIV3_1 } from \"openapi-types\";\n\nexport class OpenAPISpec {\n constructor(public document: OpenAPIV3_1.Document) {}\n\n get baseUrl() {\n return this.document.servers ? this.document.servers[0].url : undefined;\n }\n\n getPathsStrict() {\n if (!this.document.paths) {\n throw new Error(\"No paths found in spec\");\n }\n return this.document.paths;\n }\n\n getParametersStrict() {\n if (!this.document.components?.parameters) {\n throw new Error(\"No parameters found in spec\");\n }\n return this.document.components.parameters;\n }\n\n getSchemasStrict() {\n if (!this.document.components?.schemas) {\n throw new Error(\"No schemas found in spec.\");\n }\n return this.document.components.schemas;\n }\n\n getRequestBodiesStrict() {\n if (!this.document.components?.requestBodies) {\n throw new Error(\"No request body found in spec.\");\n }\n return this.document.components.requestBodies;\n }\n\n getPathStrict(path: string) {\n const pathItem = this.getPathsStrict()[path];\n if (pathItem === undefined) {\n throw new Error(`No path found for \"${path}\".`);\n }\n return pathItem;\n }\n\n getReferencedParameter(ref: OpenAPIV3_1.ReferenceObject) {\n const refComponents = ref.$ref.split(\"/\");\n const refName = refComponents[refComponents.length - 1];\n if (this.getParametersStrict()[refName] === undefined) {\n throw new Error(`No parameter found for \"${refName}\".`);\n }\n return this.getParametersStrict()[refName];\n }\n\n getRootReferencedParameter(\n ref: OpenAPIV3_1.ReferenceObject\n ): OpenAPIV3_1.ParameterObject {\n let parameter = this.getReferencedParameter(ref);\n while ((parameter as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n parameter = this.getReferencedParameter(\n parameter as OpenAPIV3_1.ReferenceObject\n );\n }\n return parameter as OpenAPIV3_1.ParameterObject;\n }\n\n getReferencedSchema(\n ref: OpenAPIV3_1.ReferenceObject\n ): OpenAPIV3_1.SchemaObject {\n const refComponents = ref.$ref.split(\"/\");\n const refName = refComponents[refComponents.length - 1];\n const schema = this.getSchemasStrict()[refName];\n if (schema === undefined) {\n throw new Error(`No schema found for \"${refName}\".`);\n }\n return schema;\n }\n\n getSchema(\n schema: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject\n ): OpenAPIV3_1.SchemaObject {\n if ((schema as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n return this.getReferencedSchema(schema as OpenAPIV3_1.ReferenceObject);\n }\n return schema;\n }\n\n getRootReferencedSchema(ref: OpenAPIV3_1.ReferenceObject) {\n let schema = this.getReferencedSchema(ref);\n while ((schema as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n schema = this.getReferencedSchema(schema as OpenAPIV3_1.ReferenceObject);\n }\n return schema as OpenAPIV3_1.ParameterObject;\n }\n\n getReferencedRequestBody(ref: OpenAPIV3_1.ReferenceObject) {\n const refComponents = ref.$ref.split(\"/\");\n const refName = refComponents[refComponents.length - 1];\n const requestBodies = this.getRequestBodiesStrict();\n if (requestBodies[refName] === undefined) {\n throw new Error(`No request body found for \"${refName}\"`);\n }\n return requestBodies[refName];\n }\n\n getRootReferencedRequestBody(ref: OpenAPIV3_1.ReferenceObject) {\n let requestBody = this.getReferencedRequestBody(ref);\n while ((requestBody as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n requestBody = this.getReferencedRequestBody(\n requestBody as OpenAPIV3_1.ReferenceObject\n );\n }\n return requestBody as OpenAPIV3_1.RequestBodyObject;\n }\n\n getMethodsForPath(path: string): OpenAPIV3.HttpMethods[] {\n const pathItem = this.getPathStrict(path);\n // This is an enum in the underlying package.\n // Werestate here to allow \"import type\" above and not cause warnings in certain envs.\n const possibleMethods = [\n \"get\",\n \"put\",\n \"post\",\n \"delete\",\n \"options\",\n \"head\",\n \"patch\",\n \"trace\",\n ];\n return possibleMethods.filter(\n (possibleMethod) =>\n pathItem[possibleMethod as OpenAPIV3.HttpMethods] !== undefined\n ) as OpenAPIV3.HttpMethods[];\n }\n\n getParametersForPath(path: string) {\n const pathItem = this.getPathStrict(path);\n if (pathItem.parameters === undefined) {\n return [];\n }\n return pathItem.parameters.map((parameter) => {\n if ((parameter as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n return this.getRootReferencedParameter(\n parameter as OpenAPIV3_1.ReferenceObject\n );\n }\n return parameter as OpenAPIV3_1.ParameterObject;\n });\n }\n\n getOperation(path: string, method: OpenAPIV3.HttpMethods) {\n const pathItem = this.getPathStrict(path);\n if (pathItem[method] === undefined) {\n throw new Error(`No ${method} method found for \"path\".`);\n }\n return pathItem[method];\n }\n\n getParametersForOperation(operation: OpenAPIV3_1.OperationObject) {\n if (operation.parameters === undefined) {\n return [];\n }\n return operation.parameters.map((parameter) => {\n if ((parameter as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n return this.getRootReferencedParameter(\n parameter as OpenAPIV3_1.ReferenceObject\n );\n }\n return parameter as OpenAPIV3_1.ParameterObject;\n });\n }\n\n getRequestBodyForOperation(\n operation: OpenAPIV3_1.OperationObject\n ): OpenAPIV3_1.RequestBodyObject {\n const { requestBody } = operation;\n if ((requestBody as OpenAPIV3_1.ReferenceObject)?.$ref !== undefined) {\n return this.getRootReferencedRequestBody(\n requestBody as OpenAPIV3_1.ReferenceObject\n );\n }\n return requestBody as OpenAPIV3_1.RequestBodyObject;\n }\n\n static getCleanedOperationId(\n operation: OpenAPIV3_1.OperationObject,\n path: string,\n method: OpenAPIV3_1.HttpMethods\n ) {\n let { operationId } = operation;\n if (operationId === undefined) {\n const updatedPath = path.replaceAll(/[^a-zA-Z0-9]/g, \"_\");\n operationId = `${\n updatedPath.startsWith(\"/\") ? updatedPath.slice(1) : updatedPath\n }_${method}`;\n }\n return operationId\n .replaceAll(/-/g, \"_\")\n .replaceAll(/\\./g, \"_\")\n .replaceAll(/\\//g, \"_\");\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static alertUnsupportedSpec(document: Record<string, any>) {\n const warningMessage =\n \"This may result in degraded performance. Convert your OpenAPI spec to 3.1.0 for better support.\";\n const swaggerVersion = document.swagger;\n const openAPIVersion = document.openapi;\n if (openAPIVersion !== undefined && openAPIVersion !== \"3.1.0\") {\n console.warn(\n `Attempting to load an OpenAPI ${openAPIVersion} spec. ${warningMessage}`\n );\n } else if (swaggerVersion !== undefined) {\n console.warn(\n `Attempting to load a Swagger ${swaggerVersion} spec. ${warningMessage}`\n );\n } else {\n throw new Error(\n `Attempting to load an unsupported spec:\\n\\n${JSON.stringify(\n document,\n null,\n 2\n )}.`\n );\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static fromObject(document: Record<string, any>) {\n OpenAPISpec.alertUnsupportedSpec(document);\n return new OpenAPISpec(document as OpenAPIV3_1.Document);\n }\n\n static fromString(rawString: string) {\n let document;\n try {\n document = JSON.parse(rawString);\n } catch {\n document = yaml.load(rawString);\n }\n return OpenAPISpec.fromObject(document);\n }\n\n static async fromURL(url: string) {\n const response = await fetch(url);\n const rawDocument = await response.text();\n return OpenAPISpec.fromString(rawDocument);\n }\n}\n"],"mappings":";;;;AAGA,IAAa,cAAb,MAAa,YAAY;CACvB,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AI,EACE,MAAM;AACzC,SAAO,YAAY,WAAW,YAAY"}
1
+ {"version":3,"file":"openapi.cjs","names":["yaml"],"sources":["../../src/util/openapi.ts"],"sourcesContent":["import * as yaml from \"js-yaml\";\nimport { OpenAPIV3, OpenAPIV3_1 } from \"openapi-types\";\n\nexport class OpenAPISpec {\n constructor(public document: OpenAPIV3_1.Document) {}\n\n get baseUrl() {\n return this.document.servers ? this.document.servers[0].url : undefined;\n }\n\n getPathsStrict() {\n if (!this.document.paths) {\n throw new Error(\"No paths found in spec\");\n }\n return this.document.paths;\n }\n\n getParametersStrict() {\n if (!this.document.components?.parameters) {\n throw new Error(\"No parameters found in spec\");\n }\n return this.document.components.parameters;\n }\n\n getSchemasStrict() {\n if (!this.document.components?.schemas) {\n throw new Error(\"No schemas found in spec.\");\n }\n return this.document.components.schemas;\n }\n\n getRequestBodiesStrict() {\n if (!this.document.components?.requestBodies) {\n throw new Error(\"No request body found in spec.\");\n }\n return this.document.components.requestBodies;\n }\n\n getPathStrict(path: string) {\n const pathItem = this.getPathsStrict()[path];\n if (pathItem === undefined) {\n throw new Error(`No path found for \"${path}\".`);\n }\n return pathItem;\n }\n\n getReferencedParameter(ref: OpenAPIV3_1.ReferenceObject) {\n const refComponents = ref.$ref.split(\"/\");\n const refName = refComponents[refComponents.length - 1];\n if (this.getParametersStrict()[refName] === undefined) {\n throw new Error(`No parameter found for \"${refName}\".`);\n }\n return this.getParametersStrict()[refName];\n }\n\n getRootReferencedParameter(\n ref: OpenAPIV3_1.ReferenceObject\n ): OpenAPIV3_1.ParameterObject {\n let parameter = this.getReferencedParameter(ref);\n while ((parameter as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n parameter = this.getReferencedParameter(\n parameter as OpenAPIV3_1.ReferenceObject\n );\n }\n return parameter as OpenAPIV3_1.ParameterObject;\n }\n\n getReferencedSchema(\n ref: OpenAPIV3_1.ReferenceObject\n ): OpenAPIV3_1.SchemaObject {\n const refComponents = ref.$ref.split(\"/\");\n const refName = refComponents[refComponents.length - 1];\n const schema = this.getSchemasStrict()[refName];\n if (schema === undefined) {\n throw new Error(`No schema found for \"${refName}\".`);\n }\n return schema;\n }\n\n getSchema(\n schema: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject\n ): OpenAPIV3_1.SchemaObject {\n if ((schema as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n return this.getReferencedSchema(schema as OpenAPIV3_1.ReferenceObject);\n }\n return schema;\n }\n\n getRootReferencedSchema(ref: OpenAPIV3_1.ReferenceObject) {\n let schema = this.getReferencedSchema(ref);\n while ((schema as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n schema = this.getReferencedSchema(schema as OpenAPIV3_1.ReferenceObject);\n }\n return schema as OpenAPIV3_1.ParameterObject;\n }\n\n getReferencedRequestBody(ref: OpenAPIV3_1.ReferenceObject) {\n const refComponents = ref.$ref.split(\"/\");\n const refName = refComponents[refComponents.length - 1];\n const requestBodies = this.getRequestBodiesStrict();\n if (requestBodies[refName] === undefined) {\n throw new Error(`No request body found for \"${refName}\"`);\n }\n return requestBodies[refName];\n }\n\n getRootReferencedRequestBody(ref: OpenAPIV3_1.ReferenceObject) {\n let requestBody = this.getReferencedRequestBody(ref);\n while ((requestBody as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n requestBody = this.getReferencedRequestBody(\n requestBody as OpenAPIV3_1.ReferenceObject\n );\n }\n return requestBody as OpenAPIV3_1.RequestBodyObject;\n }\n\n getMethodsForPath(path: string): OpenAPIV3.HttpMethods[] {\n const pathItem = this.getPathStrict(path);\n // This is an enum in the underlying package.\n // Werestate here to allow \"import type\" above and not cause warnings in certain envs.\n const possibleMethods = [\n \"get\",\n \"put\",\n \"post\",\n \"delete\",\n \"options\",\n \"head\",\n \"patch\",\n \"trace\",\n ];\n return possibleMethods.filter(\n (possibleMethod) =>\n pathItem[possibleMethod as OpenAPIV3.HttpMethods] !== undefined\n ) as OpenAPIV3.HttpMethods[];\n }\n\n getParametersForPath(path: string) {\n const pathItem = this.getPathStrict(path);\n if (pathItem.parameters === undefined) {\n return [];\n }\n return pathItem.parameters.map((parameter) => {\n if ((parameter as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n return this.getRootReferencedParameter(\n parameter as OpenAPIV3_1.ReferenceObject\n );\n }\n return parameter as OpenAPIV3_1.ParameterObject;\n });\n }\n\n getOperation(path: string, method: OpenAPIV3.HttpMethods) {\n const pathItem = this.getPathStrict(path);\n if (pathItem[method] === undefined) {\n throw new Error(`No ${method} method found for \"path\".`);\n }\n return pathItem[method];\n }\n\n getParametersForOperation(operation: OpenAPIV3_1.OperationObject) {\n if (operation.parameters === undefined) {\n return [];\n }\n return operation.parameters.map((parameter) => {\n if ((parameter as OpenAPIV3_1.ReferenceObject).$ref !== undefined) {\n return this.getRootReferencedParameter(\n parameter as OpenAPIV3_1.ReferenceObject\n );\n }\n return parameter as OpenAPIV3_1.ParameterObject;\n });\n }\n\n getRequestBodyForOperation(\n operation: OpenAPIV3_1.OperationObject\n ): OpenAPIV3_1.RequestBodyObject {\n const { requestBody } = operation;\n if ((requestBody as OpenAPIV3_1.ReferenceObject)?.$ref !== undefined) {\n return this.getRootReferencedRequestBody(\n requestBody as OpenAPIV3_1.ReferenceObject\n );\n }\n return requestBody as OpenAPIV3_1.RequestBodyObject;\n }\n\n static getCleanedOperationId(\n operation: OpenAPIV3_1.OperationObject,\n path: string,\n method: OpenAPIV3_1.HttpMethods\n ) {\n let { operationId } = operation;\n if (operationId === undefined) {\n const updatedPath = path.replaceAll(/[^a-zA-Z0-9]/g, \"_\");\n operationId = `${\n updatedPath.startsWith(\"/\") ? updatedPath.slice(1) : updatedPath\n }_${method}`;\n }\n return operationId\n .replaceAll(/-/g, \"_\")\n .replaceAll(/\\./g, \"_\")\n .replaceAll(/\\//g, \"_\");\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n static alertUnsupportedSpec(document: Record<string, any>) {\n const warningMessage =\n \"This may result in degraded performance. Convert your OpenAPI spec to 3.1.0 for better support.\";\n const swaggerVersion = document.swagger;\n const openAPIVersion = document.openapi;\n if (openAPIVersion !== undefined && openAPIVersion !== \"3.1.0\") {\n console.warn(\n `Attempting to load an OpenAPI ${openAPIVersion} spec. ${warningMessage}`\n );\n } else if (swaggerVersion !== undefined) {\n console.warn(\n `Attempting to load a Swagger ${swaggerVersion} spec. ${warningMessage}`\n );\n } else {\n throw new Error(\n `Attempting to load an unsupported spec:\\n\\n${JSON.stringify(\n document,\n null,\n 2\n )}.`\n );\n }\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n static fromObject(document: Record<string, any>) {\n OpenAPISpec.alertUnsupportedSpec(document);\n return new OpenAPISpec(document as OpenAPIV3_1.Document);\n }\n\n static fromString(rawString: string) {\n let document;\n try {\n document = JSON.parse(rawString);\n } catch {\n document = yaml.load(rawString);\n }\n return OpenAPISpec.fromObject(document);\n }\n\n static async fromURL(url: string) {\n const response = await fetch(url);\n const rawDocument = await response.text();\n return OpenAPISpec.fromString(rawDocument);\n }\n}\n"],"mappings":";;;;AAGA,IAAa,cAAb,MAAa,YAAY;CACvB,YAAY,UAAuC;AAAhC,OAAA,WAAA;;CAEnB,IAAI,UAAU;AACZ,SAAO,KAAK,SAAS,UAAU,KAAK,SAAS,QAAQ,GAAG,MAAM,KAAA;;CAGhE,iBAAiB;AACf,MAAI,CAAC,KAAK,SAAS,MACjB,OAAM,IAAI,MAAM,yBAAyB;AAE3C,SAAO,KAAK,SAAS;;CAGvB,sBAAsB;AACpB,MAAI,CAAC,KAAK,SAAS,YAAY,WAC7B,OAAM,IAAI,MAAM,8BAA8B;AAEhD,SAAO,KAAK,SAAS,WAAW;;CAGlC,mBAAmB;AACjB,MAAI,CAAC,KAAK,SAAS,YAAY,QAC7B,OAAM,IAAI,MAAM,4BAA4B;AAE9C,SAAO,KAAK,SAAS,WAAW;;CAGlC,yBAAyB;AACvB,MAAI,CAAC,KAAK,SAAS,YAAY,cAC7B,OAAM,I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