@langchain/core 1.2.0-dev-1765937705265 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1873) hide show
  1. package/CHANGELOG.md +429 -0
  2. package/README.md +1 -1
  3. package/agents.cjs +1 -0
  4. package/agents.d.cts +1 -0
  5. package/agents.d.ts +1 -0
  6. package/agents.js +1 -0
  7. package/caches.cjs +1 -0
  8. package/caches.d.cts +1 -0
  9. package/caches.d.ts +1 -0
  10. package/caches.js +1 -0
  11. package/callbacks/base.cjs +1 -0
  12. package/callbacks/base.d.cts +1 -0
  13. package/callbacks/base.d.ts +1 -0
  14. package/callbacks/base.js +1 -0
  15. package/callbacks/dispatch/web.cjs +1 -0
  16. package/callbacks/dispatch/web.d.cts +1 -0
  17. package/callbacks/dispatch/web.d.ts +1 -0
  18. package/callbacks/dispatch/web.js +1 -0
  19. package/callbacks/dispatch.cjs +1 -0
  20. package/callbacks/dispatch.d.cts +1 -0
  21. package/callbacks/dispatch.d.ts +1 -0
  22. package/callbacks/dispatch.js +1 -0
  23. package/callbacks/manager.cjs +1 -0
  24. package/callbacks/manager.d.cts +1 -0
  25. package/callbacks/manager.d.ts +1 -0
  26. package/callbacks/manager.js +1 -0
  27. package/callbacks/promises.cjs +1 -0
  28. package/callbacks/promises.d.cts +1 -0
  29. package/callbacks/promises.d.ts +1 -0
  30. package/callbacks/promises.js +1 -0
  31. package/chat_history.cjs +1 -0
  32. package/chat_history.d.cts +1 -0
  33. package/chat_history.d.ts +1 -0
  34. package/chat_history.js +1 -0
  35. package/context.cjs +1 -0
  36. package/context.d.cts +1 -0
  37. package/context.d.ts +1 -0
  38. package/context.js +1 -0
  39. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +7 -6
  40. package/dist/_virtual/_rolldown/runtime.js +13 -0
  41. package/dist/agents.cjs +8 -8
  42. package/dist/agents.cjs.map +1 -1
  43. package/dist/agents.d.cts.map +1 -1
  44. package/dist/agents.d.ts.map +1 -1
  45. package/dist/agents.js +3 -2
  46. package/dist/agents.js.map +1 -1
  47. package/dist/caches/index.cjs +12 -13
  48. package/dist/caches/index.cjs.map +1 -1
  49. package/dist/caches/index.d.cts.map +1 -1
  50. package/dist/caches/index.d.ts.map +1 -1
  51. package/dist/caches/index.js +4 -6
  52. package/dist/caches/index.js.map +1 -1
  53. package/dist/callbacks/base.cjs +22 -26
  54. package/dist/callbacks/base.cjs.map +1 -1
  55. package/dist/callbacks/base.d.cts +100 -39
  56. package/dist/callbacks/base.d.cts.map +1 -1
  57. package/dist/callbacks/base.d.ts +100 -39
  58. package/dist/callbacks/base.d.ts.map +1 -1
  59. package/dist/callbacks/base.js +14 -20
  60. package/dist/callbacks/base.js.map +1 -1
  61. package/dist/callbacks/dispatch/index.cjs +11 -12
  62. package/dist/callbacks/dispatch/index.cjs.map +1 -1
  63. package/dist/callbacks/dispatch/index.d.cts +0 -2
  64. package/dist/callbacks/dispatch/index.d.cts.map +1 -1
  65. package/dist/callbacks/dispatch/index.d.ts +0 -3
  66. package/dist/callbacks/dispatch/index.d.ts.map +1 -1
  67. package/dist/callbacks/dispatch/index.js +5 -7
  68. package/dist/callbacks/dispatch/index.js.map +1 -1
  69. package/dist/callbacks/dispatch/web.cjs +3 -3
  70. package/dist/callbacks/dispatch/web.cjs.map +1 -1
  71. package/dist/callbacks/dispatch/web.d.cts +0 -2
  72. package/dist/callbacks/dispatch/web.d.cts.map +1 -1
  73. package/dist/callbacks/dispatch/web.d.ts +0 -3
  74. package/dist/callbacks/dispatch/web.d.ts.map +1 -1
  75. package/dist/callbacks/dispatch/web.js +1 -2
  76. package/dist/callbacks/dispatch/web.js.map +1 -1
  77. package/dist/callbacks/manager.cjs +94 -80
  78. package/dist/callbacks/manager.cjs.map +1 -1
  79. package/dist/callbacks/manager.d.cts +7 -2
  80. package/dist/callbacks/manager.d.cts.map +1 -1
  81. package/dist/callbacks/manager.d.ts +7 -2
  82. package/dist/callbacks/manager.d.ts.map +1 -1
  83. package/dist/callbacks/manager.js +74 -61
  84. package/dist/callbacks/manager.js.map +1 -1
  85. package/dist/callbacks/promises.cjs +10 -11
  86. package/dist/callbacks/promises.js +3 -5
  87. package/dist/chat_history.cjs +13 -14
  88. package/dist/chat_history.cjs.map +1 -1
  89. package/dist/chat_history.d.cts +0 -2
  90. package/dist/chat_history.d.cts.map +1 -1
  91. package/dist/chat_history.d.ts +0 -3
  92. package/dist/chat_history.d.ts.map +1 -1
  93. package/dist/chat_history.js +4 -6
  94. package/dist/chat_history.js.map +1 -1
  95. package/dist/context.cjs +14 -7
  96. package/dist/context.cjs.map +1 -1
  97. package/dist/context.d.cts.map +1 -1
  98. package/dist/context.d.ts.map +1 -1
  99. package/dist/context.js +8 -2
  100. package/dist/context.js.map +1 -1
  101. package/dist/document_loaders/base.cjs +8 -10
  102. package/dist/document_loaders/base.cjs.map +1 -1
  103. package/dist/document_loaders/base.d.cts +0 -1
  104. package/dist/document_loaders/base.d.cts.map +1 -1
  105. package/dist/document_loaders/base.d.ts +0 -1
  106. package/dist/document_loaders/base.d.ts.map +1 -1
  107. package/dist/document_loaders/base.js +3 -5
  108. package/dist/document_loaders/base.js.map +1 -1
  109. package/dist/document_loaders/langsmith.cjs +11 -12
  110. package/dist/document_loaders/langsmith.cjs.map +1 -1
  111. package/dist/document_loaders/langsmith.d.cts.map +1 -1
  112. package/dist/document_loaders/langsmith.d.ts.map +1 -1
  113. package/dist/document_loaders/langsmith.js +3 -5
  114. package/dist/document_loaders/langsmith.js.map +1 -1
  115. package/dist/documents/document.cjs +1 -2
  116. package/dist/documents/document.cjs.map +1 -1
  117. package/dist/documents/document.d.cts.map +1 -1
  118. package/dist/documents/document.d.ts.map +1 -1
  119. package/dist/documents/document.js +1 -1
  120. package/dist/documents/document.js.map +1 -1
  121. package/dist/documents/index.cjs +11 -12
  122. package/dist/documents/index.js +3 -5
  123. package/dist/documents/transformers.cjs +2 -3
  124. package/dist/documents/transformers.cjs.map +1 -1
  125. package/dist/documents/transformers.d.cts +0 -1
  126. package/dist/documents/transformers.d.cts.map +1 -1
  127. package/dist/documents/transformers.d.ts +0 -1
  128. package/dist/documents/transformers.d.ts.map +1 -1
  129. package/dist/documents/transformers.js +1 -2
  130. package/dist/documents/transformers.js.map +1 -1
  131. package/dist/embeddings.cjs +10 -11
  132. package/dist/embeddings.cjs.map +1 -1
  133. package/dist/embeddings.d.cts +0 -1
  134. package/dist/embeddings.d.cts.map +1 -1
  135. package/dist/embeddings.d.ts +0 -1
  136. package/dist/embeddings.d.ts.map +1 -1
  137. package/dist/embeddings.js +3 -5
  138. package/dist/embeddings.js.map +1 -1
  139. package/dist/errors/index.cjs +165 -2
  140. package/dist/errors/index.cjs.map +1 -1
  141. package/dist/errors/index.d.cts +150 -0
  142. package/dist/errors/index.d.cts.map +1 -0
  143. package/dist/errors/index.d.ts +150 -0
  144. package/dist/errors/index.d.ts.map +1 -0
  145. package/dist/errors/index.js +155 -2
  146. package/dist/errors/index.js.map +1 -1
  147. package/dist/example_selectors/base.cjs +2 -3
  148. package/dist/example_selectors/base.cjs.map +1 -1
  149. package/dist/example_selectors/base.d.cts +0 -1
  150. package/dist/example_selectors/base.d.cts.map +1 -1
  151. package/dist/example_selectors/base.d.ts +0 -1
  152. package/dist/example_selectors/base.d.ts.map +1 -1
  153. package/dist/example_selectors/base.js +1 -2
  154. package/dist/example_selectors/base.js.map +1 -1
  155. package/dist/example_selectors/conditional.cjs +2 -4
  156. package/dist/example_selectors/conditional.cjs.map +1 -1
  157. package/dist/example_selectors/conditional.d.cts.map +1 -1
  158. package/dist/example_selectors/conditional.d.ts.map +1 -1
  159. package/dist/example_selectors/conditional.js +2 -3
  160. package/dist/example_selectors/conditional.js.map +1 -1
  161. package/dist/example_selectors/index.cjs +13 -14
  162. package/dist/example_selectors/index.js +3 -5
  163. package/dist/example_selectors/length_based.cjs +3 -5
  164. package/dist/example_selectors/length_based.cjs.map +1 -1
  165. package/dist/example_selectors/length_based.d.cts +0 -1
  166. package/dist/example_selectors/length_based.d.cts.map +1 -1
  167. package/dist/example_selectors/length_based.d.ts +0 -1
  168. package/dist/example_selectors/length_based.d.ts.map +1 -1
  169. package/dist/example_selectors/length_based.js +2 -4
  170. package/dist/example_selectors/length_based.js.map +1 -1
  171. package/dist/example_selectors/semantic_similarity.cjs +7 -12
  172. package/dist/example_selectors/semantic_similarity.cjs.map +1 -1
  173. package/dist/example_selectors/semantic_similarity.d.cts +0 -1
  174. package/dist/example_selectors/semantic_similarity.d.cts.map +1 -1
  175. package/dist/example_selectors/semantic_similarity.d.ts +0 -1
  176. package/dist/example_selectors/semantic_similarity.d.ts.map +1 -1
  177. package/dist/example_selectors/semantic_similarity.js +5 -10
  178. package/dist/example_selectors/semantic_similarity.js.map +1 -1
  179. package/dist/index.cjs +8 -8
  180. package/dist/index.js +3 -2
  181. package/dist/indexing/base.cjs +11 -17
  182. package/dist/indexing/base.cjs.map +1 -1
  183. package/dist/indexing/base.d.cts.map +1 -1
  184. package/dist/indexing/base.d.ts.map +1 -1
  185. package/dist/indexing/base.js +7 -12
  186. package/dist/indexing/base.js.map +1 -1
  187. package/dist/indexing/index.cjs +11 -12
  188. package/dist/indexing/index.js +3 -5
  189. package/dist/indexing/record_manager.cjs +2 -3
  190. package/dist/indexing/record_manager.cjs.map +1 -1
  191. package/dist/indexing/record_manager.d.cts.map +1 -1
  192. package/dist/indexing/record_manager.d.ts.map +1 -1
  193. package/dist/indexing/record_manager.js +1 -2
  194. package/dist/indexing/record_manager.js.map +1 -1
  195. package/dist/language_models/base.cjs +40 -26
  196. package/dist/language_models/base.cjs.map +1 -1
  197. package/dist/language_models/base.d.cts +22 -14
  198. package/dist/language_models/base.d.cts.map +1 -1
  199. package/dist/language_models/base.d.ts +22 -16
  200. package/dist/language_models/base.d.ts.map +1 -1
  201. package/dist/language_models/base.js +29 -16
  202. package/dist/language_models/base.js.map +1 -1
  203. package/dist/language_models/chat_models.cjs +173 -75
  204. package/dist/language_models/chat_models.cjs.map +1 -1
  205. package/dist/language_models/chat_models.d.cts +147 -10
  206. package/dist/language_models/chat_models.d.cts.map +1 -1
  207. package/dist/language_models/chat_models.d.ts +147 -13
  208. package/dist/language_models/chat_models.d.ts.map +1 -1
  209. package/dist/language_models/chat_models.js +155 -58
  210. package/dist/language_models/chat_models.js.map +1 -1
  211. package/dist/language_models/compat.cjs +412 -0
  212. package/dist/language_models/compat.cjs.map +1 -0
  213. package/dist/language_models/compat.d.cts +20 -0
  214. package/dist/language_models/compat.d.cts.map +1 -0
  215. package/dist/language_models/compat.d.ts +20 -0
  216. package/dist/language_models/compat.d.ts.map +1 -0
  217. package/dist/language_models/compat.js +404 -0
  218. package/dist/language_models/compat.js.map +1 -0
  219. package/dist/language_models/event.cjs +12 -0
  220. package/dist/language_models/event.cjs.map +1 -0
  221. package/dist/language_models/event.d.cts +185 -0
  222. package/dist/language_models/event.d.cts.map +1 -0
  223. package/dist/language_models/event.d.ts +185 -0
  224. package/dist/language_models/event.d.ts.map +1 -0
  225. package/dist/language_models/event.js +7 -0
  226. package/dist/language_models/event.js.map +1 -0
  227. package/dist/language_models/llms.cjs +41 -33
  228. package/dist/language_models/llms.cjs.map +1 -1
  229. package/dist/language_models/llms.d.cts +4 -4
  230. package/dist/language_models/llms.d.cts.map +1 -1
  231. package/dist/language_models/llms.d.ts +4 -5
  232. package/dist/language_models/llms.d.ts.map +1 -1
  233. package/dist/language_models/llms.js +30 -23
  234. package/dist/language_models/llms.js.map +1 -1
  235. package/dist/language_models/openai_completions_stream.cjs +308 -0
  236. package/dist/language_models/openai_completions_stream.cjs.map +1 -0
  237. package/dist/language_models/openai_completions_stream.d.cts +75 -0
  238. package/dist/language_models/openai_completions_stream.d.cts.map +1 -0
  239. package/dist/language_models/openai_completions_stream.d.ts +75 -0
  240. package/dist/language_models/openai_completions_stream.d.ts.map +1 -0
  241. package/dist/language_models/openai_completions_stream.js +301 -0
  242. package/dist/language_models/openai_completions_stream.js.map +1 -0
  243. package/dist/language_models/profile.cjs +8 -8
  244. package/dist/language_models/profile.d.cts.map +1 -1
  245. package/dist/language_models/profile.d.ts.map +1 -1
  246. package/dist/language_models/profile.js +3 -2
  247. package/dist/language_models/stream.cjs +506 -0
  248. package/dist/language_models/stream.cjs.map +1 -0
  249. package/dist/language_models/stream.d.cts +106 -0
  250. package/dist/language_models/stream.d.cts.map +1 -0
  251. package/dist/language_models/stream.d.ts +106 -0
  252. package/dist/language_models/stream.d.ts.map +1 -0
  253. package/dist/language_models/stream.js +495 -0
  254. package/dist/language_models/stream.js.map +1 -0
  255. package/dist/language_models/structured_output.cjs +87 -0
  256. package/dist/language_models/structured_output.cjs.map +1 -0
  257. package/dist/language_models/structured_output.d.cts +45 -0
  258. package/dist/language_models/structured_output.d.cts.map +1 -0
  259. package/dist/language_models/structured_output.d.ts +45 -0
  260. package/dist/language_models/structured_output.d.ts.map +1 -0
  261. package/dist/language_models/structured_output.js +78 -0
  262. package/dist/language_models/structured_output.js.map +1 -0
  263. package/dist/language_models/utils.cjs +1 -2
  264. package/dist/language_models/utils.cjs.map +1 -1
  265. package/dist/language_models/utils.js +1 -1
  266. package/dist/language_models/utils.js.map +1 -1
  267. package/dist/load/import_constants.cjs +1 -2
  268. package/dist/load/import_constants.cjs.map +1 -1
  269. package/dist/load/import_constants.js +1 -1
  270. package/dist/load/import_constants.js.map +1 -1
  271. package/dist/load/import_map.cjs +86 -66
  272. package/dist/load/import_map.cjs.map +1 -1
  273. package/dist/load/import_map.js +49 -29
  274. package/dist/load/import_map.js.map +1 -1
  275. package/dist/load/import_type.d.cts.map +1 -1
  276. package/dist/load/import_type.d.ts.map +1 -1
  277. package/dist/load/index.cjs +179 -41
  278. package/dist/load/index.cjs.map +1 -1
  279. package/dist/load/index.d.cts +126 -3
  280. package/dist/load/index.d.cts.map +1 -1
  281. package/dist/load/index.d.ts +126 -3
  282. package/dist/load/index.d.ts.map +1 -1
  283. package/dist/load/index.js +168 -31
  284. package/dist/load/index.js.map +1 -1
  285. package/dist/load/map_keys.cjs +14 -7
  286. package/dist/load/map_keys.cjs.map +1 -1
  287. package/dist/load/map_keys.d.cts.map +1 -1
  288. package/dist/load/map_keys.d.ts.map +1 -1
  289. package/dist/load/map_keys.js +12 -4
  290. package/dist/load/map_keys.js.map +1 -1
  291. package/dist/load/serializable.cjs +22 -26
  292. package/dist/load/serializable.cjs.map +1 -1
  293. package/dist/load/serializable.d.cts +15 -1
  294. package/dist/load/serializable.d.cts.map +1 -1
  295. package/dist/load/serializable.d.ts +15 -1
  296. package/dist/load/serializable.d.ts.map +1 -1
  297. package/dist/load/serializable.js +15 -20
  298. package/dist/load/serializable.js.map +1 -1
  299. package/dist/load/validation.cjs +120 -0
  300. package/dist/load/validation.cjs.map +1 -0
  301. package/dist/load/validation.js +118 -0
  302. package/dist/load/validation.js.map +1 -0
  303. package/dist/memory.cjs +10 -18
  304. package/dist/memory.cjs.map +1 -1
  305. package/dist/memory.d.cts +2 -2
  306. package/dist/memory.d.cts.map +1 -1
  307. package/dist/memory.d.ts +2 -2
  308. package/dist/memory.d.ts.map +1 -1
  309. package/dist/memory.js +5 -13
  310. package/dist/memory.js.map +1 -1
  311. package/dist/messages/ai.cjs +27 -18
  312. package/dist/messages/ai.cjs.map +1 -1
  313. package/dist/messages/ai.d.cts +2 -2
  314. package/dist/messages/ai.d.cts.map +1 -1
  315. package/dist/messages/ai.d.ts +2 -2
  316. package/dist/messages/ai.d.ts.map +1 -1
  317. package/dist/messages/ai.js +22 -13
  318. package/dist/messages/ai.js.map +1 -1
  319. package/dist/messages/base.cjs +121 -44
  320. package/dist/messages/base.cjs.map +1 -1
  321. package/dist/messages/base.d.cts +58 -12
  322. package/dist/messages/base.d.cts.map +1 -1
  323. package/dist/messages/base.d.ts +58 -12
  324. package/dist/messages/base.d.ts.map +1 -1
  325. package/dist/messages/base.js +114 -38
  326. package/dist/messages/base.js.map +1 -1
  327. package/dist/messages/block_translators/anthropic.cjs +32 -38
  328. package/dist/messages/block_translators/anthropic.cjs.map +1 -1
  329. package/dist/messages/block_translators/anthropic.js +31 -37
  330. package/dist/messages/block_translators/anthropic.js.map +1 -1
  331. package/dist/messages/block_translators/bedrock_converse.cjs +40 -49
  332. package/dist/messages/block_translators/bedrock_converse.cjs.map +1 -1
  333. package/dist/messages/block_translators/bedrock_converse.js +39 -48
  334. package/dist/messages/block_translators/bedrock_converse.js.map +1 -1
  335. package/dist/messages/block_translators/data.cjs +3 -4
  336. package/dist/messages/block_translators/data.cjs.map +1 -1
  337. package/dist/messages/block_translators/data.js +1 -2
  338. package/dist/messages/block_translators/data.js.map +1 -1
  339. package/dist/messages/block_translators/deepseek.cjs +58 -0
  340. package/dist/messages/block_translators/deepseek.cjs.map +1 -0
  341. package/dist/messages/block_translators/deepseek.js +58 -0
  342. package/dist/messages/block_translators/deepseek.js.map +1 -0
  343. package/dist/messages/block_translators/google.cjs +97 -0
  344. package/dist/messages/block_translators/google.cjs.map +1 -0
  345. package/dist/messages/block_translators/google.js +97 -0
  346. package/dist/messages/block_translators/google.js.map +1 -0
  347. package/dist/messages/block_translators/google_genai.cjs +9 -3
  348. package/dist/messages/block_translators/google_genai.cjs.map +1 -1
  349. package/dist/messages/block_translators/google_genai.js +8 -2
  350. package/dist/messages/block_translators/google_genai.js.map +1 -1
  351. package/dist/messages/block_translators/google_vertexai.cjs +10 -6
  352. package/dist/messages/block_translators/google_vertexai.cjs.map +1 -1
  353. package/dist/messages/block_translators/google_vertexai.js +9 -5
  354. package/dist/messages/block_translators/google_vertexai.js.map +1 -1
  355. package/dist/messages/block_translators/groq.cjs +96 -0
  356. package/dist/messages/block_translators/groq.cjs.map +1 -0
  357. package/dist/messages/block_translators/groq.js +96 -0
  358. package/dist/messages/block_translators/groq.js.map +1 -0
  359. package/dist/messages/block_translators/index.cjs +19 -8
  360. package/dist/messages/block_translators/index.cjs.map +1 -1
  361. package/dist/messages/block_translators/index.js +14 -3
  362. package/dist/messages/block_translators/index.js.map +1 -1
  363. package/dist/messages/block_translators/ollama.cjs +58 -0
  364. package/dist/messages/block_translators/ollama.cjs.map +1 -0
  365. package/dist/messages/block_translators/ollama.js +58 -0
  366. package/dist/messages/block_translators/ollama.js.map +1 -0
  367. package/dist/messages/block_translators/openai.cjs +85 -26
  368. package/dist/messages/block_translators/openai.cjs.map +1 -1
  369. package/dist/messages/block_translators/openai.js +83 -24
  370. package/dist/messages/block_translators/openai.js.map +1 -1
  371. package/dist/messages/block_translators/openrouter.cjs +101 -0
  372. package/dist/messages/block_translators/openrouter.cjs.map +1 -0
  373. package/dist/messages/block_translators/openrouter.js +101 -0
  374. package/dist/messages/block_translators/openrouter.js.map +1 -0
  375. package/dist/messages/block_translators/utils.cjs +2 -3
  376. package/dist/messages/block_translators/utils.cjs.map +1 -1
  377. package/dist/messages/block_translators/utils.js +2 -2
  378. package/dist/messages/block_translators/utils.js.map +1 -1
  379. package/dist/messages/block_translators/xai.cjs +94 -0
  380. package/dist/messages/block_translators/xai.cjs.map +1 -0
  381. package/dist/messages/block_translators/xai.js +94 -0
  382. package/dist/messages/block_translators/xai.js.map +1 -0
  383. package/dist/messages/chat.cjs +2 -3
  384. package/dist/messages/chat.cjs.map +1 -1
  385. package/dist/messages/chat.d.cts.map +1 -1
  386. package/dist/messages/chat.d.ts.map +1 -1
  387. package/dist/messages/chat.js +1 -2
  388. package/dist/messages/chat.js.map +1 -1
  389. package/dist/messages/content/base.d.cts.map +1 -1
  390. package/dist/messages/content/base.d.ts.map +1 -1
  391. package/dist/messages/content/data.cjs +2 -5
  392. package/dist/messages/content/data.cjs.map +1 -1
  393. package/dist/messages/content/data.d.cts +0 -1
  394. package/dist/messages/content/data.d.cts.map +1 -1
  395. package/dist/messages/content/data.d.ts +0 -1
  396. package/dist/messages/content/data.d.ts.map +1 -1
  397. package/dist/messages/content/data.js +2 -4
  398. package/dist/messages/content/data.js.map +1 -1
  399. package/dist/messages/content/index.cjs +5 -6
  400. package/dist/messages/content/index.cjs.map +1 -1
  401. package/dist/messages/content/index.d.cts +7 -3
  402. package/dist/messages/content/index.d.cts.map +1 -1
  403. package/dist/messages/content/index.d.ts +7 -3
  404. package/dist/messages/content/index.d.ts.map +1 -1
  405. package/dist/messages/content/index.js +7 -8
  406. package/dist/messages/content/index.js.map +1 -1
  407. package/dist/messages/content/multimodal.cjs +1 -2
  408. package/dist/messages/content/multimodal.cjs.map +1 -1
  409. package/dist/messages/content/multimodal.d.cts +4 -8
  410. package/dist/messages/content/multimodal.d.cts.map +1 -1
  411. package/dist/messages/content/multimodal.d.ts +4 -8
  412. package/dist/messages/content/multimodal.d.ts.map +1 -1
  413. package/dist/messages/content/multimodal.js +1 -1
  414. package/dist/messages/content/multimodal.js.map +1 -1
  415. package/dist/messages/content/tools.cjs +1 -2
  416. package/dist/messages/content/tools.cjs.map +1 -1
  417. package/dist/messages/content/tools.d.cts +1 -1
  418. package/dist/messages/content/tools.d.cts.map +1 -1
  419. package/dist/messages/content/tools.d.ts +1 -1
  420. package/dist/messages/content/tools.d.ts.map +1 -1
  421. package/dist/messages/content/tools.js +1 -1
  422. package/dist/messages/content/tools.js.map +1 -1
  423. package/dist/messages/format.cjs +1 -2
  424. package/dist/messages/format.cjs.map +1 -1
  425. package/dist/messages/format.d.cts.map +1 -1
  426. package/dist/messages/format.d.ts.map +1 -1
  427. package/dist/messages/format.js +1 -1
  428. package/dist/messages/format.js.map +1 -1
  429. package/dist/messages/function.cjs +2 -3
  430. package/dist/messages/function.cjs.map +1 -1
  431. package/dist/messages/function.d.cts.map +1 -1
  432. package/dist/messages/function.d.ts.map +1 -1
  433. package/dist/messages/function.js +1 -2
  434. package/dist/messages/function.js.map +1 -1
  435. package/dist/messages/human.cjs +2 -3
  436. package/dist/messages/human.cjs.map +1 -1
  437. package/dist/messages/human.d.cts.map +1 -1
  438. package/dist/messages/human.d.ts.map +1 -1
  439. package/dist/messages/human.js +1 -2
  440. package/dist/messages/human.js.map +1 -1
  441. package/dist/messages/index.cjs +25 -24
  442. package/dist/messages/index.d.cts +4 -4
  443. package/dist/messages/index.d.ts +4 -4
  444. package/dist/messages/index.js +7 -8
  445. package/dist/messages/message.cjs +1 -2
  446. package/dist/messages/message.cjs.map +1 -1
  447. package/dist/messages/message.d.cts +50 -27
  448. package/dist/messages/message.d.cts.map +1 -1
  449. package/dist/messages/message.d.ts +50 -27
  450. package/dist/messages/message.d.ts.map +1 -1
  451. package/dist/messages/message.js +1 -1
  452. package/dist/messages/message.js.map +1 -1
  453. package/dist/messages/metadata.cjs +3 -5
  454. package/dist/messages/metadata.cjs.map +1 -1
  455. package/dist/messages/metadata.d.cts.map +1 -1
  456. package/dist/messages/metadata.d.ts.map +1 -1
  457. package/dist/messages/metadata.js +2 -4
  458. package/dist/messages/metadata.js.map +1 -1
  459. package/dist/messages/modifier.cjs +8 -3
  460. package/dist/messages/modifier.cjs.map +1 -1
  461. package/dist/messages/modifier.d.cts +9 -4
  462. package/dist/messages/modifier.d.cts.map +1 -1
  463. package/dist/messages/modifier.d.ts +9 -4
  464. package/dist/messages/modifier.d.ts.map +1 -1
  465. package/dist/messages/modifier.js +7 -2
  466. package/dist/messages/modifier.js.map +1 -1
  467. package/dist/messages/system.cjs +10 -7
  468. package/dist/messages/system.cjs.map +1 -1
  469. package/dist/messages/system.d.cts.map +1 -1
  470. package/dist/messages/system.d.ts.map +1 -1
  471. package/dist/messages/system.js +9 -6
  472. package/dist/messages/system.js.map +1 -1
  473. package/dist/messages/tool.cjs +10 -11
  474. package/dist/messages/tool.cjs.map +1 -1
  475. package/dist/messages/tool.d.cts +1 -1
  476. package/dist/messages/tool.d.cts.map +1 -1
  477. package/dist/messages/tool.d.ts +1 -1
  478. package/dist/messages/tool.d.ts.map +1 -1
  479. package/dist/messages/tool.js +3 -5
  480. package/dist/messages/tool.js.map +1 -1
  481. package/dist/messages/transformers.cjs +18 -25
  482. package/dist/messages/transformers.cjs.map +1 -1
  483. package/dist/messages/transformers.d.cts.map +1 -1
  484. package/dist/messages/transformers.d.ts.map +1 -1
  485. package/dist/messages/transformers.js +9 -16
  486. package/dist/messages/transformers.js.map +1 -1
  487. package/dist/messages/utils.cjs +85 -32
  488. package/dist/messages/utils.cjs.map +1 -1
  489. package/dist/messages/utils.d.cts +25 -8
  490. package/dist/messages/utils.d.cts.map +1 -1
  491. package/dist/messages/utils.d.ts +25 -8
  492. package/dist/messages/utils.d.ts.map +1 -1
  493. package/dist/messages/utils.js +77 -24
  494. package/dist/messages/utils.js.map +1 -1
  495. package/dist/output_parsers/base.cjs +10 -11
  496. package/dist/output_parsers/base.cjs.map +1 -1
  497. package/dist/output_parsers/base.d.cts +0 -1
  498. package/dist/output_parsers/base.d.cts.map +1 -1
  499. package/dist/output_parsers/base.d.ts +0 -4
  500. package/dist/output_parsers/base.d.ts.map +1 -1
  501. package/dist/output_parsers/base.js +6 -7
  502. package/dist/output_parsers/base.js.map +1 -1
  503. package/dist/output_parsers/bytes.cjs +2 -3
  504. package/dist/output_parsers/bytes.cjs.map +1 -1
  505. package/dist/output_parsers/bytes.d.cts +0 -1
  506. package/dist/output_parsers/bytes.d.cts.map +1 -1
  507. package/dist/output_parsers/bytes.d.ts +0 -1
  508. package/dist/output_parsers/bytes.d.ts.map +1 -1
  509. package/dist/output_parsers/bytes.js +1 -2
  510. package/dist/output_parsers/bytes.js.map +1 -1
  511. package/dist/output_parsers/index.cjs +21 -19
  512. package/dist/output_parsers/index.cjs.map +1 -1
  513. package/dist/output_parsers/index.d.cts +2 -1
  514. package/dist/output_parsers/index.d.ts +2 -1
  515. package/dist/output_parsers/index.js +7 -7
  516. package/dist/output_parsers/index.js.map +1 -1
  517. package/dist/output_parsers/json.cjs +16 -7
  518. package/dist/output_parsers/json.cjs.map +1 -1
  519. package/dist/output_parsers/json.d.cts +9 -1
  520. package/dist/output_parsers/json.d.cts.map +1 -1
  521. package/dist/output_parsers/json.d.ts +9 -1
  522. package/dist/output_parsers/json.d.ts.map +1 -1
  523. package/dist/output_parsers/json.js +13 -4
  524. package/dist/output_parsers/json.js.map +1 -1
  525. package/dist/output_parsers/list.cjs +3 -4
  526. package/dist/output_parsers/list.cjs.map +1 -1
  527. package/dist/output_parsers/list.d.cts +0 -1
  528. package/dist/output_parsers/list.d.cts.map +1 -1
  529. package/dist/output_parsers/list.d.ts +0 -2
  530. package/dist/output_parsers/list.d.ts.map +1 -1
  531. package/dist/output_parsers/list.js +1 -2
  532. package/dist/output_parsers/list.js.map +1 -1
  533. package/dist/output_parsers/openai_functions/index.cjs +10 -11
  534. package/dist/output_parsers/openai_functions/index.js +3 -5
  535. package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs +13 -17
  536. package/dist/output_parsers/openai_functions/json_output_functions_parsers.cjs.map +1 -1
  537. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -2
  538. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +1 -1
  539. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -2
  540. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +1 -1
  541. package/dist/output_parsers/openai_functions/json_output_functions_parsers.js +7 -11
  542. package/dist/output_parsers/openai_functions/json_output_functions_parsers.js.map +1 -1
  543. package/dist/output_parsers/openai_tools/index.cjs +10 -11
  544. package/dist/output_parsers/openai_tools/index.d.cts +2 -2
  545. package/dist/output_parsers/openai_tools/index.d.ts +2 -2
  546. package/dist/output_parsers/openai_tools/index.js +3 -5
  547. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +29 -30
  548. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
  549. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +10 -8
  550. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +1 -1
  551. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +10 -8
  552. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -1
  553. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +23 -24
  554. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
  555. package/dist/output_parsers/standard_schema.cjs +42 -0
  556. package/dist/output_parsers/standard_schema.cjs.map +1 -0
  557. package/dist/output_parsers/standard_schema.d.cts +18 -0
  558. package/dist/output_parsers/standard_schema.d.cts.map +1 -0
  559. package/dist/output_parsers/standard_schema.d.ts +18 -0
  560. package/dist/output_parsers/standard_schema.d.ts.map +1 -0
  561. package/dist/output_parsers/standard_schema.js +42 -0
  562. package/dist/output_parsers/standard_schema.js.map +1 -0
  563. package/dist/output_parsers/string.cjs +5 -3
  564. package/dist/output_parsers/string.cjs.map +1 -1
  565. package/dist/output_parsers/string.d.cts +0 -1
  566. package/dist/output_parsers/string.d.cts.map +1 -1
  567. package/dist/output_parsers/string.d.ts +0 -2
  568. package/dist/output_parsers/string.d.ts.map +1 -1
  569. package/dist/output_parsers/string.js +4 -2
  570. package/dist/output_parsers/string.js.map +1 -1
  571. package/dist/output_parsers/structured.cjs +17 -18
  572. package/dist/output_parsers/structured.cjs.map +1 -1
  573. package/dist/output_parsers/structured.d.cts +2 -0
  574. package/dist/output_parsers/structured.d.cts.map +1 -1
  575. package/dist/output_parsers/structured.d.ts +2 -0
  576. package/dist/output_parsers/structured.d.ts.map +1 -1
  577. package/dist/output_parsers/structured.js +12 -13
  578. package/dist/output_parsers/structured.js.map +1 -1
  579. package/dist/output_parsers/transform.cjs +8 -9
  580. package/dist/output_parsers/transform.cjs.map +1 -1
  581. package/dist/output_parsers/transform.d.cts +0 -1
  582. package/dist/output_parsers/transform.d.cts.map +1 -1
  583. package/dist/output_parsers/transform.d.ts +0 -1
  584. package/dist/output_parsers/transform.d.ts.map +1 -1
  585. package/dist/output_parsers/transform.js +1 -2
  586. package/dist/output_parsers/transform.js.map +1 -1
  587. package/dist/output_parsers/xml.cjs +11 -15
  588. package/dist/output_parsers/xml.cjs.map +1 -1
  589. package/dist/output_parsers/xml.d.cts +1 -1
  590. package/dist/output_parsers/xml.d.cts.map +1 -1
  591. package/dist/output_parsers/xml.d.ts +1 -1
  592. package/dist/output_parsers/xml.d.ts.map +1 -1
  593. package/dist/output_parsers/xml.js +7 -11
  594. package/dist/output_parsers/xml.js.map +1 -1
  595. package/dist/outputs.cjs +8 -10
  596. package/dist/outputs.cjs.map +1 -1
  597. package/dist/outputs.d.cts.map +1 -1
  598. package/dist/outputs.d.ts.map +1 -1
  599. package/dist/outputs.js +3 -5
  600. package/dist/outputs.js.map +1 -1
  601. package/dist/prompt_values.cjs +12 -13
  602. package/dist/prompt_values.cjs.map +1 -1
  603. package/dist/prompt_values.d.cts +1 -3
  604. package/dist/prompt_values.d.cts.map +1 -1
  605. package/dist/prompt_values.d.ts +1 -3
  606. package/dist/prompt_values.d.ts.map +1 -1
  607. package/dist/prompt_values.js +3 -5
  608. package/dist/prompt_values.js.map +1 -1
  609. package/dist/prompts/base.cjs +4 -6
  610. package/dist/prompts/base.cjs.map +1 -1
  611. package/dist/prompts/base.d.cts +0 -1
  612. package/dist/prompts/base.d.cts.map +1 -1
  613. package/dist/prompts/base.d.ts +0 -2
  614. package/dist/prompts/base.d.ts.map +1 -1
  615. package/dist/prompts/base.js +3 -5
  616. package/dist/prompts/base.js.map +1 -1
  617. package/dist/prompts/chat.cjs +37 -53
  618. package/dist/prompts/chat.cjs.map +1 -1
  619. package/dist/prompts/chat.d.cts +1 -0
  620. package/dist/prompts/chat.d.cts.map +1 -1
  621. package/dist/prompts/chat.d.ts +1 -1
  622. package/dist/prompts/chat.d.ts.map +1 -1
  623. package/dist/prompts/chat.js +23 -39
  624. package/dist/prompts/chat.js.map +1 -1
  625. package/dist/prompts/dict.cjs +3 -4
  626. package/dist/prompts/dict.cjs.map +1 -1
  627. package/dist/prompts/dict.d.cts.map +1 -1
  628. package/dist/prompts/dict.d.ts.map +1 -1
  629. package/dist/prompts/dict.js +1 -2
  630. package/dist/prompts/dict.js.map +1 -1
  631. package/dist/prompts/few_shot.cjs +14 -20
  632. package/dist/prompts/few_shot.cjs.map +1 -1
  633. package/dist/prompts/few_shot.d.cts.map +1 -1
  634. package/dist/prompts/few_shot.d.ts +0 -1
  635. package/dist/prompts/few_shot.d.ts.map +1 -1
  636. package/dist/prompts/few_shot.js +10 -16
  637. package/dist/prompts/few_shot.js.map +1 -1
  638. package/dist/prompts/image.cjs +7 -10
  639. package/dist/prompts/image.cjs.map +1 -1
  640. package/dist/prompts/image.d.cts +0 -1
  641. package/dist/prompts/image.d.cts.map +1 -1
  642. package/dist/prompts/image.d.ts +0 -2
  643. package/dist/prompts/image.d.ts.map +1 -1
  644. package/dist/prompts/image.js +4 -7
  645. package/dist/prompts/image.js.map +1 -1
  646. package/dist/prompts/index.cjs +19 -20
  647. package/dist/prompts/index.js +3 -5
  648. package/dist/prompts/pipeline.cjs +3 -4
  649. package/dist/prompts/pipeline.cjs.map +1 -1
  650. package/dist/prompts/pipeline.d.cts +0 -1
  651. package/dist/prompts/pipeline.d.cts.map +1 -1
  652. package/dist/prompts/pipeline.d.ts +0 -1
  653. package/dist/prompts/pipeline.d.ts.map +1 -1
  654. package/dist/prompts/pipeline.js +1 -2
  655. package/dist/prompts/pipeline.js.map +1 -1
  656. package/dist/prompts/prompt.cjs +13 -17
  657. package/dist/prompts/prompt.cjs.map +1 -1
  658. package/dist/prompts/prompt.d.cts +1 -2
  659. package/dist/prompts/prompt.d.cts.map +1 -1
  660. package/dist/prompts/prompt.d.ts +1 -2
  661. package/dist/prompts/prompt.d.ts.map +1 -1
  662. package/dist/prompts/prompt.js +11 -15
  663. package/dist/prompts/prompt.js.map +1 -1
  664. package/dist/prompts/serde.d.cts +0 -1
  665. package/dist/prompts/serde.d.cts.map +1 -1
  666. package/dist/prompts/serde.d.ts +0 -2
  667. package/dist/prompts/serde.d.ts.map +1 -1
  668. package/dist/prompts/string.cjs +4 -6
  669. package/dist/prompts/string.cjs.map +1 -1
  670. package/dist/prompts/string.d.cts +0 -1
  671. package/dist/prompts/string.d.cts.map +1 -1
  672. package/dist/prompts/string.d.ts +0 -1
  673. package/dist/prompts/string.d.ts.map +1 -1
  674. package/dist/prompts/string.js +2 -4
  675. package/dist/prompts/string.js.map +1 -1
  676. package/dist/prompts/structured.cjs +3 -4
  677. package/dist/prompts/structured.cjs.map +1 -1
  678. package/dist/prompts/structured.d.cts +0 -1
  679. package/dist/prompts/structured.d.cts.map +1 -1
  680. package/dist/prompts/structured.d.ts +0 -1
  681. package/dist/prompts/structured.d.ts.map +1 -1
  682. package/dist/prompts/structured.js +1 -2
  683. package/dist/prompts/structured.js.map +1 -1
  684. package/dist/prompts/template.cjs +12 -23
  685. package/dist/prompts/template.cjs.map +1 -1
  686. package/dist/prompts/template.d.cts +0 -2
  687. package/dist/prompts/template.d.cts.map +1 -1
  688. package/dist/prompts/template.d.ts +0 -2
  689. package/dist/prompts/template.d.ts.map +1 -1
  690. package/dist/prompts/template.js +8 -20
  691. package/dist/prompts/template.js.map +1 -1
  692. package/dist/retrievers/document_compressors/index.cjs +8 -10
  693. package/dist/retrievers/document_compressors/index.cjs.map +1 -1
  694. package/dist/retrievers/document_compressors/index.d.cts +0 -1
  695. package/dist/retrievers/document_compressors/index.d.cts.map +1 -1
  696. package/dist/retrievers/document_compressors/index.d.ts +0 -1
  697. package/dist/retrievers/document_compressors/index.d.ts.map +1 -1
  698. package/dist/retrievers/document_compressors/index.js +3 -5
  699. package/dist/retrievers/document_compressors/index.js.map +1 -1
  700. package/dist/retrievers/index.cjs +13 -15
  701. package/dist/retrievers/index.cjs.map +1 -1
  702. package/dist/retrievers/index.d.cts +0 -1
  703. package/dist/retrievers/index.d.cts.map +1 -1
  704. package/dist/retrievers/index.d.ts +0 -2
  705. package/dist/retrievers/index.d.ts.map +1 -1
  706. package/dist/retrievers/index.js +4 -7
  707. package/dist/retrievers/index.js.map +1 -1
  708. package/dist/runnables/base.cjs +76 -100
  709. package/dist/runnables/base.cjs.map +1 -1
  710. package/dist/runnables/base.d.cts +46 -4
  711. package/dist/runnables/base.d.cts.map +1 -1
  712. package/dist/runnables/base.d.ts +46 -4
  713. package/dist/runnables/base.d.ts.map +1 -1
  714. package/dist/runnables/base.js +58 -82
  715. package/dist/runnables/base.js.map +1 -1
  716. package/dist/runnables/branch.cjs +8 -13
  717. package/dist/runnables/branch.cjs.map +1 -1
  718. package/dist/runnables/branch.d.cts +0 -1
  719. package/dist/runnables/branch.d.cts.map +1 -1
  720. package/dist/runnables/branch.d.ts +0 -2
  721. package/dist/runnables/branch.d.ts.map +1 -1
  722. package/dist/runnables/branch.js +5 -10
  723. package/dist/runnables/branch.js.map +1 -1
  724. package/dist/runnables/config.cjs +21 -16
  725. package/dist/runnables/config.cjs.map +1 -1
  726. package/dist/runnables/config.d.cts.map +1 -1
  727. package/dist/runnables/config.d.ts.map +1 -1
  728. package/dist/runnables/config.js +19 -13
  729. package/dist/runnables/config.js.map +1 -1
  730. package/dist/runnables/graph.cjs +19 -22
  731. package/dist/runnables/graph.cjs.map +1 -1
  732. package/dist/runnables/graph.d.cts.map +1 -1
  733. package/dist/runnables/graph.d.ts.map +1 -1
  734. package/dist/runnables/graph.js +6 -10
  735. package/dist/runnables/graph.js.map +1 -1
  736. package/dist/runnables/graph_mermaid.cjs +8 -12
  737. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  738. package/dist/runnables/graph_mermaid.js +7 -11
  739. package/dist/runnables/graph_mermaid.js.map +1 -1
  740. package/dist/runnables/history.cjs +15 -17
  741. package/dist/runnables/history.cjs.map +1 -1
  742. package/dist/runnables/history.d.cts +5 -4
  743. package/dist/runnables/history.d.cts.map +1 -1
  744. package/dist/runnables/history.d.ts +5 -6
  745. package/dist/runnables/history.d.ts.map +1 -1
  746. package/dist/runnables/history.js +10 -12
  747. package/dist/runnables/history.js.map +1 -1
  748. package/dist/runnables/index.cjs +16 -17
  749. package/dist/runnables/index.js +3 -5
  750. package/dist/runnables/iter.cjs +21 -5
  751. package/dist/runnables/iter.cjs.map +1 -1
  752. package/dist/runnables/iter.js +17 -3
  753. package/dist/runnables/iter.js.map +1 -1
  754. package/dist/runnables/passthrough.cjs +5 -6
  755. package/dist/runnables/passthrough.cjs.map +1 -1
  756. package/dist/runnables/passthrough.d.cts.map +1 -1
  757. package/dist/runnables/passthrough.d.ts +0 -1
  758. package/dist/runnables/passthrough.d.ts.map +1 -1
  759. package/dist/runnables/passthrough.js +2 -3
  760. package/dist/runnables/passthrough.js.map +1 -1
  761. package/dist/runnables/router.cjs +5 -7
  762. package/dist/runnables/router.cjs.map +1 -1
  763. package/dist/runnables/router.d.cts.map +1 -1
  764. package/dist/runnables/router.d.ts +0 -1
  765. package/dist/runnables/router.d.ts.map +1 -1
  766. package/dist/runnables/router.js +3 -5
  767. package/dist/runnables/router.js.map +1 -1
  768. package/dist/runnables/types.d.cts +1 -2
  769. package/dist/runnables/types.d.cts.map +1 -1
  770. package/dist/runnables/types.d.ts +1 -2
  771. package/dist/runnables/types.d.ts.map +1 -1
  772. package/dist/runnables/utils.cjs +2 -4
  773. package/dist/runnables/utils.cjs.map +1 -1
  774. package/dist/runnables/utils.js +2 -3
  775. package/dist/runnables/utils.js.map +1 -1
  776. package/dist/runnables/wrappers.cjs +2 -3
  777. package/dist/runnables/wrappers.cjs.map +1 -1
  778. package/dist/runnables/wrappers.js +1 -2
  779. package/dist/runnables/wrappers.js.map +1 -1
  780. package/dist/singletons/async_local_storage/context.cjs +6 -8
  781. package/dist/singletons/async_local_storage/context.cjs.map +1 -1
  782. package/dist/singletons/async_local_storage/context.d.cts +0 -1
  783. package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
  784. package/dist/singletons/async_local_storage/context.d.ts +0 -1
  785. package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
  786. package/dist/singletons/async_local_storage/context.js +3 -5
  787. package/dist/singletons/async_local_storage/context.js.map +1 -1
  788. package/dist/singletons/async_local_storage/globals.cjs +1 -2
  789. package/dist/singletons/async_local_storage/globals.cjs.map +1 -1
  790. package/dist/singletons/async_local_storage/globals.d.cts.map +1 -1
  791. package/dist/singletons/async_local_storage/globals.d.ts.map +1 -1
  792. package/dist/singletons/async_local_storage/globals.js +1 -1
  793. package/dist/singletons/async_local_storage/globals.js.map +1 -1
  794. package/dist/singletons/async_local_storage/index.cjs +8 -14
  795. package/dist/singletons/async_local_storage/index.cjs.map +1 -1
  796. package/dist/singletons/async_local_storage/index.d.cts.map +1 -1
  797. package/dist/singletons/async_local_storage/index.d.ts.map +1 -1
  798. package/dist/singletons/async_local_storage/index.js +4 -10
  799. package/dist/singletons/async_local_storage/index.js.map +1 -1
  800. package/dist/singletons/callbacks.cjs +7 -8
  801. package/dist/singletons/callbacks.cjs.map +1 -1
  802. package/dist/singletons/callbacks.d.cts +0 -1
  803. package/dist/singletons/callbacks.d.cts.map +1 -1
  804. package/dist/singletons/callbacks.d.ts +0 -1
  805. package/dist/singletons/callbacks.d.ts.map +1 -1
  806. package/dist/singletons/callbacks.js +2 -4
  807. package/dist/singletons/callbacks.js.map +1 -1
  808. package/dist/singletons/index.cjs +11 -12
  809. package/dist/singletons/index.js +3 -5
  810. package/dist/singletons/tracer.cjs +5 -9
  811. package/dist/singletons/tracer.cjs.map +1 -1
  812. package/dist/singletons/tracer.js +2 -6
  813. package/dist/singletons/tracer.js.map +1 -1
  814. package/dist/stores.cjs +10 -11
  815. package/dist/stores.cjs.map +1 -1
  816. package/dist/stores.d.cts +0 -1
  817. package/dist/stores.d.cts.map +1 -1
  818. package/dist/stores.d.ts +0 -1
  819. package/dist/stores.d.ts.map +1 -1
  820. package/dist/stores.js +3 -5
  821. package/dist/stores.js.map +1 -1
  822. package/dist/structured_query/base.cjs +6 -7
  823. package/dist/structured_query/base.cjs.map +1 -1
  824. package/dist/structured_query/base.d.cts +0 -1
  825. package/dist/structured_query/base.d.cts.map +1 -1
  826. package/dist/structured_query/base.d.ts +0 -1
  827. package/dist/structured_query/base.d.ts.map +1 -1
  828. package/dist/structured_query/base.js +4 -5
  829. package/dist/structured_query/base.js.map +1 -1
  830. package/dist/structured_query/functional.cjs +7 -8
  831. package/dist/structured_query/functional.cjs.map +1 -1
  832. package/dist/structured_query/functional.d.cts +0 -1
  833. package/dist/structured_query/functional.d.cts.map +1 -1
  834. package/dist/structured_query/functional.d.ts +0 -1
  835. package/dist/structured_query/functional.d.ts.map +1 -1
  836. package/dist/structured_query/functional.js +4 -5
  837. package/dist/structured_query/functional.js.map +1 -1
  838. package/dist/structured_query/index.cjs +13 -14
  839. package/dist/structured_query/index.js +3 -5
  840. package/dist/structured_query/ir.cjs +1 -2
  841. package/dist/structured_query/ir.cjs.map +1 -1
  842. package/dist/structured_query/ir.d.cts +0 -1
  843. package/dist/structured_query/ir.d.cts.map +1 -1
  844. package/dist/structured_query/ir.d.ts +0 -1
  845. package/dist/structured_query/ir.d.ts.map +1 -1
  846. package/dist/structured_query/ir.js +1 -1
  847. package/dist/structured_query/ir.js.map +1 -1
  848. package/dist/structured_query/utils.cjs +1 -2
  849. package/dist/structured_query/utils.cjs.map +1 -1
  850. package/dist/structured_query/utils.d.cts.map +1 -1
  851. package/dist/structured_query/utils.d.ts.map +1 -1
  852. package/dist/structured_query/utils.js +1 -1
  853. package/dist/structured_query/utils.js.map +1 -1
  854. package/dist/testing/fake_model_builder.cjs +226 -0
  855. package/dist/testing/fake_model_builder.cjs.map +1 -0
  856. package/dist/testing/fake_model_builder.d.cts +137 -0
  857. package/dist/testing/fake_model_builder.d.cts.map +1 -0
  858. package/dist/testing/fake_model_builder.d.ts +137 -0
  859. package/dist/testing/fake_model_builder.d.ts.map +1 -0
  860. package/dist/testing/fake_model_builder.js +225 -0
  861. package/dist/testing/fake_model_builder.js.map +1 -0
  862. package/dist/testing/index.cjs +58 -0
  863. package/dist/testing/index.cjs.map +1 -0
  864. package/dist/testing/index.d.cts +5 -0
  865. package/dist/testing/index.d.ts +5 -0
  866. package/dist/testing/index.js +32 -0
  867. package/dist/testing/index.js.map +1 -0
  868. package/dist/testing/matchers.cjs +214 -0
  869. package/dist/testing/matchers.cjs.map +1 -0
  870. package/dist/testing/matchers.d.cts +98 -0
  871. package/dist/testing/matchers.d.cts.map +1 -0
  872. package/dist/testing/matchers.d.ts +98 -0
  873. package/dist/testing/matchers.d.ts.map +1 -0
  874. package/dist/testing/matchers.js +204 -0
  875. package/dist/testing/matchers.js.map +1 -0
  876. package/dist/tools/index.cjs +51 -36
  877. package/dist/tools/index.cjs.map +1 -1
  878. package/dist/tools/index.d.cts +31 -24
  879. package/dist/tools/index.d.cts.map +1 -1
  880. package/dist/tools/index.d.ts +31 -26
  881. package/dist/tools/index.d.ts.map +1 -1
  882. package/dist/tools/index.js +32 -18
  883. package/dist/tools/index.js.map +1 -1
  884. package/dist/tools/types.cjs +3 -4
  885. package/dist/tools/types.cjs.map +1 -1
  886. package/dist/tools/types.d.cts +26 -11
  887. package/dist/tools/types.d.cts.map +1 -1
  888. package/dist/tools/types.d.ts +26 -13
  889. package/dist/tools/types.d.ts.map +1 -1
  890. package/dist/tools/types.js +1 -2
  891. package/dist/tools/types.js.map +1 -1
  892. package/dist/tools/utils.cjs +1 -2
  893. package/dist/tools/utils.cjs.map +1 -1
  894. package/dist/tools/utils.d.cts +0 -1
  895. package/dist/tools/utils.d.cts.map +1 -1
  896. package/dist/tools/utils.d.ts +0 -1
  897. package/dist/tools/utils.d.ts.map +1 -1
  898. package/dist/tools/utils.js +1 -1
  899. package/dist/tools/utils.js.map +1 -1
  900. package/dist/tracers/base.cjs +20 -18
  901. package/dist/tracers/base.cjs.map +1 -1
  902. package/dist/tracers/base.d.cts +92 -98
  903. package/dist/tracers/base.d.cts.map +1 -1
  904. package/dist/tracers/base.d.ts +92 -98
  905. package/dist/tracers/base.d.ts.map +1 -1
  906. package/dist/tracers/base.js +11 -10
  907. package/dist/tracers/base.js.map +1 -1
  908. package/dist/tracers/console.cjs +44 -19
  909. package/dist/tracers/console.cjs.map +1 -1
  910. package/dist/tracers/console.d.cts +0 -1
  911. package/dist/tracers/console.d.cts.map +1 -1
  912. package/dist/tracers/console.d.ts +0 -1
  913. package/dist/tracers/console.d.ts.map +1 -1
  914. package/dist/tracers/console.js +35 -11
  915. package/dist/tracers/console.js.map +1 -1
  916. package/dist/tracers/event_stream.cjs +24 -10
  917. package/dist/tracers/event_stream.cjs.map +1 -1
  918. package/dist/tracers/event_stream.d.cts +7 -6
  919. package/dist/tracers/event_stream.d.cts.map +1 -1
  920. package/dist/tracers/event_stream.d.ts +7 -7
  921. package/dist/tracers/event_stream.d.ts.map +1 -1
  922. package/dist/tracers/event_stream.js +20 -6
  923. package/dist/tracers/event_stream.js.map +1 -1
  924. package/dist/tracers/log_stream.cjs +15 -16
  925. package/dist/tracers/log_stream.cjs.map +1 -1
  926. package/dist/tracers/log_stream.d.cts +14 -31
  927. package/dist/tracers/log_stream.d.cts.map +1 -1
  928. package/dist/tracers/log_stream.d.ts +14 -31
  929. package/dist/tracers/log_stream.d.ts.map +1 -1
  930. package/dist/tracers/log_stream.js +5 -7
  931. package/dist/tracers/log_stream.js.map +1 -1
  932. package/dist/tracers/root_listener.cjs +2 -3
  933. package/dist/tracers/root_listener.cjs.map +1 -1
  934. package/dist/tracers/root_listener.js +1 -2
  935. package/dist/tracers/root_listener.js.map +1 -1
  936. package/dist/tracers/run_collector.cjs +10 -11
  937. package/dist/tracers/run_collector.cjs.map +1 -1
  938. package/dist/tracers/run_collector.d.cts +0 -1
  939. package/dist/tracers/run_collector.d.cts.map +1 -1
  940. package/dist/tracers/run_collector.d.ts +0 -1
  941. package/dist/tracers/run_collector.d.ts.map +1 -1
  942. package/dist/tracers/run_collector.js +3 -5
  943. package/dist/tracers/run_collector.js.map +1 -1
  944. package/dist/tracers/tracer_langchain.cjs +112 -20
  945. package/dist/tracers/tracer_langchain.cjs.map +1 -1
  946. package/dist/tracers/tracer_langchain.d.cts +28 -2
  947. package/dist/tracers/tracer_langchain.d.cts.map +1 -1
  948. package/dist/tracers/tracer_langchain.d.ts +28 -2
  949. package/dist/tracers/tracer_langchain.d.ts.map +1 -1
  950. package/dist/tracers/tracer_langchain.js +102 -12
  951. package/dist/tracers/tracer_langchain.js.map +1 -1
  952. package/dist/types/_internal.d.cts.map +1 -1
  953. package/dist/types/_internal.d.ts.map +1 -1
  954. package/dist/types/stream.cjs +8 -8
  955. package/dist/types/stream.js +3 -2
  956. package/dist/types/type-utils.d.cts +2 -1
  957. package/dist/types/type-utils.d.cts.map +1 -1
  958. package/dist/types/type-utils.d.ts +2 -1
  959. package/dist/types/type-utils.d.ts.map +1 -1
  960. package/dist/utils/async_caller.cjs +28 -20
  961. package/dist/utils/async_caller.cjs.map +1 -1
  962. package/dist/utils/async_caller.d.cts.map +1 -1
  963. package/dist/utils/async_caller.d.ts.map +1 -1
  964. package/dist/utils/async_caller.js +18 -12
  965. package/dist/utils/async_caller.js.map +1 -1
  966. package/dist/utils/callbacks.cjs +4 -6
  967. package/dist/utils/callbacks.cjs.map +1 -1
  968. package/dist/utils/callbacks.js +3 -5
  969. package/dist/utils/callbacks.js.map +1 -1
  970. package/dist/utils/chunk_array.cjs +9 -12
  971. package/dist/utils/chunk_array.cjs.map +1 -1
  972. package/dist/utils/chunk_array.d.cts.map +1 -1
  973. package/dist/utils/chunk_array.d.ts.map +1 -1
  974. package/dist/utils/chunk_array.js +4 -7
  975. package/dist/utils/chunk_array.js.map +1 -1
  976. package/dist/utils/context.cjs +104 -0
  977. package/dist/utils/context.cjs.map +1 -0
  978. package/dist/utils/context.d.cts +44 -0
  979. package/dist/utils/context.d.cts.map +1 -0
  980. package/dist/utils/context.d.ts +44 -0
  981. package/dist/utils/context.d.ts.map +1 -0
  982. package/dist/utils/context.js +98 -0
  983. package/dist/utils/context.js.map +1 -0
  984. package/dist/utils/env.cjs +14 -19
  985. package/dist/utils/env.cjs.map +1 -1
  986. package/dist/utils/env.d.cts.map +1 -1
  987. package/dist/utils/env.d.ts.map +1 -1
  988. package/dist/utils/env.js +9 -14
  989. package/dist/utils/env.js.map +1 -1
  990. package/dist/utils/event_source_parse.cjs +15 -23
  991. package/dist/utils/event_source_parse.cjs.map +1 -1
  992. package/dist/utils/event_source_parse.d.cts +2 -2
  993. package/dist/utils/event_source_parse.d.cts.map +1 -1
  994. package/dist/utils/event_source_parse.d.ts +2 -2
  995. package/dist/utils/event_source_parse.d.ts.map +1 -1
  996. package/dist/utils/event_source_parse.js +8 -17
  997. package/dist/utils/event_source_parse.js.map +1 -1
  998. package/dist/utils/fast-json-patch/index.cjs +5 -13
  999. package/dist/utils/fast-json-patch/index.cjs.map +1 -1
  1000. package/dist/utils/fast-json-patch/index.js +6 -13
  1001. package/dist/utils/fast-json-patch/index.js.map +1 -1
  1002. package/dist/utils/fast-json-patch/src/core.cjs +16 -28
  1003. package/dist/utils/fast-json-patch/src/core.cjs.map +1 -1
  1004. package/dist/utils/fast-json-patch/src/core.d.cts +0 -1
  1005. package/dist/utils/fast-json-patch/src/core.d.cts.map +1 -1
  1006. package/dist/utils/fast-json-patch/src/core.d.ts +0 -1
  1007. package/dist/utils/fast-json-patch/src/core.d.ts.map +1 -1
  1008. package/dist/utils/fast-json-patch/src/core.js +10 -22
  1009. package/dist/utils/fast-json-patch/src/core.js.map +1 -1
  1010. package/dist/utils/fast-json-patch/src/duplex.cjs +8 -7
  1011. package/dist/utils/fast-json-patch/src/duplex.cjs.map +1 -1
  1012. package/dist/utils/fast-json-patch/src/duplex.d.cts +0 -1
  1013. package/dist/utils/fast-json-patch/src/duplex.d.cts.map +1 -1
  1014. package/dist/utils/fast-json-patch/src/duplex.d.ts +0 -1
  1015. package/dist/utils/fast-json-patch/src/duplex.d.ts.map +1 -1
  1016. package/dist/utils/fast-json-patch/src/duplex.js +6 -5
  1017. package/dist/utils/fast-json-patch/src/duplex.js.map +1 -1
  1018. package/dist/utils/fast-json-patch/src/helpers.cjs +5 -6
  1019. package/dist/utils/fast-json-patch/src/helpers.cjs.map +1 -1
  1020. package/dist/utils/fast-json-patch/src/helpers.js +5 -5
  1021. package/dist/utils/fast-json-patch/src/helpers.js.map +1 -1
  1022. package/dist/utils/format.cjs +8 -8
  1023. package/dist/utils/format.d.cts.map +1 -1
  1024. package/dist/utils/format.d.ts.map +1 -1
  1025. package/dist/utils/format.js +3 -2
  1026. package/dist/utils/function_calling.cjs +11 -12
  1027. package/dist/utils/function_calling.cjs.map +1 -1
  1028. package/dist/utils/function_calling.d.cts +0 -1
  1029. package/dist/utils/function_calling.d.cts.map +1 -1
  1030. package/dist/utils/function_calling.d.ts +0 -1
  1031. package/dist/utils/function_calling.d.ts.map +1 -1
  1032. package/dist/utils/function_calling.js +3 -5
  1033. package/dist/utils/function_calling.js.map +1 -1
  1034. package/dist/utils/hash.cjs +10 -11
  1035. package/dist/utils/hash.d.cts +0 -1
  1036. package/dist/utils/hash.d.cts.map +1 -1
  1037. package/dist/utils/hash.d.ts +0 -1
  1038. package/dist/utils/hash.d.ts.map +1 -1
  1039. package/dist/utils/hash.js +3 -5
  1040. package/dist/utils/is-network-error/index.cjs +3 -5
  1041. package/dist/utils/is-network-error/index.cjs.map +1 -1
  1042. package/dist/utils/is-network-error/index.js +3 -4
  1043. package/dist/utils/is-network-error/index.js.map +1 -1
  1044. package/dist/utils/js-sha256/hash.cjs +42 -37
  1045. package/dist/utils/js-sha256/hash.cjs.map +1 -1
  1046. package/dist/utils/js-sha256/hash.d.cts.map +1 -1
  1047. package/dist/utils/js-sha256/hash.d.ts.map +1 -1
  1048. package/dist/utils/js-sha256/hash.js +42 -36
  1049. package/dist/utils/js-sha256/hash.js.map +1 -1
  1050. package/dist/utils/json.cjs +1 -2
  1051. package/dist/utils/json.cjs.map +1 -1
  1052. package/dist/utils/json.d.cts.map +1 -1
  1053. package/dist/utils/json.d.ts.map +1 -1
  1054. package/dist/utils/json.js +1 -1
  1055. package/dist/utils/json.js.map +1 -1
  1056. package/dist/utils/json_patch.cjs +12 -13
  1057. package/dist/utils/json_patch.js +3 -5
  1058. package/dist/utils/json_schema.cjs +60 -37
  1059. package/dist/utils/json_schema.cjs.map +1 -1
  1060. package/dist/utils/json_schema.d.cts +4 -2
  1061. package/dist/utils/json_schema.d.cts.map +1 -1
  1062. package/dist/utils/json_schema.d.ts +4 -3
  1063. package/dist/utils/json_schema.d.ts.map +1 -1
  1064. package/dist/utils/json_schema.js +36 -14
  1065. package/dist/utils/json_schema.js.map +1 -1
  1066. package/dist/utils/math.cjs +16 -18
  1067. package/dist/utils/math.cjs.map +1 -1
  1068. package/dist/utils/math.d.cts.map +1 -1
  1069. package/dist/utils/math.d.ts.map +1 -1
  1070. package/dist/utils/math.js +9 -12
  1071. package/dist/utils/math.js.map +1 -1
  1072. package/dist/utils/ml-distance/distances.cjs +1 -2
  1073. package/dist/utils/ml-distance/distances.cjs.map +1 -1
  1074. package/dist/utils/ml-distance/distances.js +1 -1
  1075. package/dist/utils/ml-distance/distances.js.map +1 -1
  1076. package/dist/utils/ml-distance/similarities.cjs +1 -2
  1077. package/dist/utils/ml-distance/similarities.cjs.map +1 -1
  1078. package/dist/utils/ml-distance/similarities.d.cts.map +1 -1
  1079. package/dist/utils/ml-distance/similarities.d.ts.map +1 -1
  1080. package/dist/utils/ml-distance/similarities.js +1 -1
  1081. package/dist/utils/ml-distance/similarities.js.map +1 -1
  1082. package/dist/utils/ml-distance-euclidean/euclidean.cjs +1 -2
  1083. package/dist/utils/ml-distance-euclidean/euclidean.cjs.map +1 -1
  1084. package/dist/utils/ml-distance-euclidean/euclidean.js +1 -1
  1085. package/dist/utils/ml-distance-euclidean/euclidean.js.map +1 -1
  1086. package/dist/utils/namespace.cjs +62 -0
  1087. package/dist/utils/namespace.cjs.map +1 -0
  1088. package/dist/utils/namespace.d.cts +73 -0
  1089. package/dist/utils/namespace.d.cts.map +1 -0
  1090. package/dist/utils/namespace.d.ts +73 -0
  1091. package/dist/utils/namespace.d.ts.map +1 -0
  1092. package/dist/utils/namespace.js +62 -0
  1093. package/dist/utils/namespace.js.map +1 -0
  1094. package/dist/utils/p-retry/index.cjs +4 -5
  1095. package/dist/utils/p-retry/index.cjs.map +1 -1
  1096. package/dist/utils/p-retry/index.js +3 -4
  1097. package/dist/utils/p-retry/index.js.map +1 -1
  1098. package/dist/utils/sax-js/sax.cjs +29 -36
  1099. package/dist/utils/sax-js/sax.cjs.map +1 -1
  1100. package/dist/utils/sax-js/sax.js +29 -35
  1101. package/dist/utils/sax-js/sax.js.map +1 -1
  1102. package/dist/utils/signal.cjs +3 -4
  1103. package/dist/utils/signal.cjs.map +1 -1
  1104. package/dist/utils/signal.d.cts.map +1 -1
  1105. package/dist/utils/signal.d.ts.map +1 -1
  1106. package/dist/utils/signal.js +3 -3
  1107. package/dist/utils/signal.js.map +1 -1
  1108. package/dist/utils/ssrf.cjs +267 -0
  1109. package/dist/utils/ssrf.cjs.map +1 -0
  1110. package/dist/utils/ssrf.d.cts +52 -0
  1111. package/dist/utils/ssrf.d.cts.map +1 -0
  1112. package/dist/utils/ssrf.d.ts +52 -0
  1113. package/dist/utils/ssrf.d.ts.map +1 -0
  1114. package/dist/utils/ssrf.js +256 -0
  1115. package/dist/utils/ssrf.js.map +1 -0
  1116. package/dist/utils/standard_schema.cjs +41 -0
  1117. package/dist/utils/standard_schema.cjs.map +1 -0
  1118. package/dist/utils/standard_schema.d.cts +27 -0
  1119. package/dist/utils/standard_schema.d.cts.map +1 -0
  1120. package/dist/utils/standard_schema.d.ts +27 -0
  1121. package/dist/utils/standard_schema.d.ts.map +1 -0
  1122. package/dist/utils/standard_schema.js +33 -0
  1123. package/dist/utils/standard_schema.js.map +1 -0
  1124. package/dist/utils/stream.cjs +15 -16
  1125. package/dist/utils/stream.cjs.map +1 -1
  1126. package/dist/utils/stream.d.cts.map +1 -1
  1127. package/dist/utils/stream.d.ts.map +1 -1
  1128. package/dist/utils/stream.js +5 -7
  1129. package/dist/utils/stream.js.map +1 -1
  1130. package/dist/utils/testing/chat_models.cjs +10 -13
  1131. package/dist/utils/testing/chat_models.cjs.map +1 -1
  1132. package/dist/utils/testing/chat_models.d.cts.map +1 -1
  1133. package/dist/utils/testing/chat_models.d.ts +0 -1
  1134. package/dist/utils/testing/chat_models.d.ts.map +1 -1
  1135. package/dist/utils/testing/chat_models.js +4 -7
  1136. package/dist/utils/testing/chat_models.js.map +1 -1
  1137. package/dist/utils/testing/embeddings.cjs +4 -7
  1138. package/dist/utils/testing/embeddings.cjs.map +1 -1
  1139. package/dist/utils/testing/embeddings.d.cts +0 -1
  1140. package/dist/utils/testing/embeddings.d.cts.map +1 -1
  1141. package/dist/utils/testing/embeddings.d.ts +0 -1
  1142. package/dist/utils/testing/embeddings.d.ts.map +1 -1
  1143. package/dist/utils/testing/embeddings.js +3 -6
  1144. package/dist/utils/testing/embeddings.js.map +1 -1
  1145. package/dist/utils/testing/index.cjs +36 -21
  1146. package/dist/utils/testing/index.cjs.map +1 -1
  1147. package/dist/utils/testing/index.d.cts +3 -1
  1148. package/dist/utils/testing/index.d.ts +3 -1
  1149. package/dist/utils/testing/index.js +14 -7
  1150. package/dist/utils/testing/index.js.map +1 -1
  1151. package/dist/utils/testing/llms.cjs +2 -3
  1152. package/dist/utils/testing/llms.cjs.map +1 -1
  1153. package/dist/utils/testing/llms.d.cts.map +1 -1
  1154. package/dist/utils/testing/llms.d.ts.map +1 -1
  1155. package/dist/utils/testing/llms.js +1 -2
  1156. package/dist/utils/testing/llms.js.map +1 -1
  1157. package/dist/utils/testing/message_history.cjs +6 -7
  1158. package/dist/utils/testing/message_history.cjs.map +1 -1
  1159. package/dist/utils/testing/message_history.d.cts.map +1 -1
  1160. package/dist/utils/testing/message_history.d.ts +0 -1
  1161. package/dist/utils/testing/message_history.d.ts.map +1 -1
  1162. package/dist/utils/testing/message_history.js +2 -3
  1163. package/dist/utils/testing/message_history.js.map +1 -1
  1164. package/dist/utils/testing/openai_stream_fixtures.cjs +160 -0
  1165. package/dist/utils/testing/openai_stream_fixtures.cjs.map +1 -0
  1166. package/dist/utils/testing/openai_stream_fixtures.d.cts +12 -0
  1167. package/dist/utils/testing/openai_stream_fixtures.d.cts.map +1 -0
  1168. package/dist/utils/testing/openai_stream_fixtures.d.ts +12 -0
  1169. package/dist/utils/testing/openai_stream_fixtures.d.ts.map +1 -0
  1170. package/dist/utils/testing/openai_stream_fixtures.js +155 -0
  1171. package/dist/utils/testing/openai_stream_fixtures.js.map +1 -0
  1172. package/dist/utils/testing/output_parsers.cjs +2 -3
  1173. package/dist/utils/testing/output_parsers.cjs.map +1 -1
  1174. package/dist/utils/testing/output_parsers.d.cts +0 -1
  1175. package/dist/utils/testing/output_parsers.d.cts.map +1 -1
  1176. package/dist/utils/testing/output_parsers.d.ts +0 -1
  1177. package/dist/utils/testing/output_parsers.d.ts.map +1 -1
  1178. package/dist/utils/testing/output_parsers.js +1 -2
  1179. package/dist/utils/testing/output_parsers.js.map +1 -1
  1180. package/dist/utils/testing/retrievers.cjs +3 -4
  1181. package/dist/utils/testing/retrievers.cjs.map +1 -1
  1182. package/dist/utils/testing/retrievers.d.cts.map +1 -1
  1183. package/dist/utils/testing/retrievers.d.ts.map +1 -1
  1184. package/dist/utils/testing/retrievers.js +2 -3
  1185. package/dist/utils/testing/retrievers.js.map +1 -1
  1186. package/dist/utils/testing/runnables.cjs +2 -3
  1187. package/dist/utils/testing/runnables.cjs.map +1 -1
  1188. package/dist/utils/testing/runnables.d.cts.map +1 -1
  1189. package/dist/utils/testing/runnables.d.ts.map +1 -1
  1190. package/dist/utils/testing/runnables.js +1 -2
  1191. package/dist/utils/testing/runnables.js.map +1 -1
  1192. package/dist/utils/testing/stream.cjs +136 -0
  1193. package/dist/utils/testing/stream.cjs.map +1 -0
  1194. package/dist/utils/testing/stream.d.cts +96 -0
  1195. package/dist/utils/testing/stream.d.cts.map +1 -0
  1196. package/dist/utils/testing/stream.d.ts +96 -0
  1197. package/dist/utils/testing/stream.d.ts.map +1 -0
  1198. package/dist/utils/testing/stream.js +136 -0
  1199. package/dist/utils/testing/stream.js.map +1 -0
  1200. package/dist/utils/testing/tools.cjs +2 -3
  1201. package/dist/utils/testing/tools.cjs.map +1 -1
  1202. package/dist/utils/testing/tools.d.cts.map +1 -1
  1203. package/dist/utils/testing/tools.d.ts.map +1 -1
  1204. package/dist/utils/testing/tools.js +1 -2
  1205. package/dist/utils/testing/tools.js.map +1 -1
  1206. package/dist/utils/testing/tracers.cjs +2 -3
  1207. package/dist/utils/testing/tracers.cjs.map +1 -1
  1208. package/dist/utils/testing/tracers.d.cts.map +1 -1
  1209. package/dist/utils/testing/tracers.d.ts.map +1 -1
  1210. package/dist/utils/testing/tracers.js +1 -2
  1211. package/dist/utils/testing/tracers.js.map +1 -1
  1212. package/dist/utils/testing/vectorstores.cjs +10 -15
  1213. package/dist/utils/testing/vectorstores.cjs.map +1 -1
  1214. package/dist/utils/testing/vectorstores.d.cts +0 -1
  1215. package/dist/utils/testing/vectorstores.d.cts.map +1 -1
  1216. package/dist/utils/testing/vectorstores.d.ts +0 -1
  1217. package/dist/utils/testing/vectorstores.d.ts.map +1 -1
  1218. package/dist/utils/testing/vectorstores.js +8 -13
  1219. package/dist/utils/testing/vectorstores.js.map +1 -1
  1220. package/dist/utils/tiktoken.cjs +11 -12
  1221. package/dist/utils/tiktoken.cjs.map +1 -1
  1222. package/dist/utils/tiktoken.d.cts.map +1 -1
  1223. package/dist/utils/tiktoken.d.ts.map +1 -1
  1224. package/dist/utils/tiktoken.js +3 -5
  1225. package/dist/utils/tiktoken.js.map +1 -1
  1226. package/dist/utils/types/index.cjs +10 -11
  1227. package/dist/utils/types/index.cjs.map +1 -1
  1228. package/dist/utils/types/index.d.cts +2 -3
  1229. package/dist/utils/types/index.d.cts.map +1 -1
  1230. package/dist/utils/types/index.d.ts +2 -3
  1231. package/dist/utils/types/index.d.ts.map +1 -1
  1232. package/dist/utils/types/index.js +3 -5
  1233. package/dist/utils/types/index.js.map +1 -1
  1234. package/dist/utils/types/zod.cjs +20 -36
  1235. package/dist/utils/types/zod.cjs.map +1 -1
  1236. package/dist/utils/types/zod.d.cts +144 -33
  1237. package/dist/utils/types/zod.d.cts.map +1 -1
  1238. package/dist/utils/types/zod.d.ts +144 -33
  1239. package/dist/utils/types/zod.d.ts.map +1 -1
  1240. package/dist/utils/types/zod.js +18 -34
  1241. package/dist/utils/types/zod.js.map +1 -1
  1242. package/dist/utils/uuid/index.cjs +58 -0
  1243. package/dist/utils/uuid/index.cjs.map +1 -0
  1244. package/dist/utils/uuid/index.d.cts +26 -0
  1245. package/dist/utils/uuid/index.d.cts.map +1 -0
  1246. package/dist/utils/uuid/index.d.ts +26 -0
  1247. package/dist/utils/uuid/index.d.ts.map +1 -0
  1248. package/dist/utils/uuid/index.js +41 -0
  1249. package/dist/utils/uuid/index.js.map +1 -0
  1250. package/dist/utils/uuid/max.cjs +6 -0
  1251. package/dist/utils/uuid/max.cjs.map +1 -0
  1252. package/dist/utils/uuid/max.js +6 -0
  1253. package/dist/utils/uuid/max.js.map +1 -0
  1254. package/dist/utils/uuid/nil.cjs +6 -0
  1255. package/dist/utils/uuid/nil.cjs.map +1 -0
  1256. package/dist/utils/uuid/nil.js +6 -0
  1257. package/dist/utils/uuid/nil.js.map +1 -0
  1258. package/dist/utils/uuid/parse.cjs +11 -0
  1259. package/dist/utils/uuid/parse.cjs.map +1 -0
  1260. package/dist/utils/uuid/parse.d.cts +7 -0
  1261. package/dist/utils/uuid/parse.d.cts.map +1 -0
  1262. package/dist/utils/uuid/parse.d.ts +7 -0
  1263. package/dist/utils/uuid/parse.d.ts.map +1 -0
  1264. package/dist/utils/uuid/parse.js +11 -0
  1265. package/dist/utils/uuid/parse.js.map +1 -0
  1266. package/dist/utils/uuid/regex.cjs +6 -0
  1267. package/dist/utils/uuid/regex.cjs.map +1 -0
  1268. package/dist/utils/uuid/regex.js +6 -0
  1269. package/dist/utils/uuid/regex.js.map +1 -0
  1270. package/dist/utils/uuid/rng.cjs +9 -0
  1271. package/dist/utils/uuid/rng.cjs.map +1 -0
  1272. package/dist/utils/uuid/rng.js +9 -0
  1273. package/dist/utils/uuid/rng.js.map +1 -0
  1274. package/dist/utils/uuid/sha1.cjs +71 -0
  1275. package/dist/utils/uuid/sha1.cjs.map +1 -0
  1276. package/dist/utils/uuid/sha1.js +71 -0
  1277. package/dist/utils/uuid/sha1.js.map +1 -0
  1278. package/dist/utils/uuid/stringify.cjs +21 -0
  1279. package/dist/utils/uuid/stringify.cjs.map +1 -0
  1280. package/dist/utils/uuid/stringify.d.cts +5 -0
  1281. package/dist/utils/uuid/stringify.d.cts.map +1 -0
  1282. package/dist/utils/uuid/stringify.d.ts +5 -0
  1283. package/dist/utils/uuid/stringify.d.ts.map +1 -0
  1284. package/dist/utils/uuid/stringify.js +20 -0
  1285. package/dist/utils/uuid/stringify.js.map +1 -0
  1286. package/dist/utils/uuid/types.d.cts +26 -0
  1287. package/dist/utils/uuid/types.d.cts.map +1 -0
  1288. package/dist/utils/uuid/types.d.ts +26 -0
  1289. package/dist/utils/uuid/types.d.ts.map +1 -0
  1290. package/dist/utils/uuid/v1.cjs +69 -0
  1291. package/dist/utils/uuid/v1.cjs.map +1 -0
  1292. package/dist/utils/uuid/v1.d.cts +8 -0
  1293. package/dist/utils/uuid/v1.d.cts.map +1 -0
  1294. package/dist/utils/uuid/v1.d.ts +8 -0
  1295. package/dist/utils/uuid/v1.d.ts.map +1 -0
  1296. package/dist/utils/uuid/v1.js +69 -0
  1297. package/dist/utils/uuid/v1.js.map +1 -0
  1298. package/dist/utils/uuid/v1ToV6.cjs +14 -0
  1299. package/dist/utils/uuid/v1ToV6.cjs.map +1 -0
  1300. package/dist/utils/uuid/v1ToV6.js +14 -0
  1301. package/dist/utils/uuid/v1ToV6.js.map +1 -0
  1302. package/dist/utils/uuid/v35.cjs +36 -0
  1303. package/dist/utils/uuid/v35.cjs.map +1 -0
  1304. package/dist/utils/uuid/v35.js +34 -0
  1305. package/dist/utils/uuid/v35.js.map +1 -0
  1306. package/dist/utils/uuid/v4.cjs +25 -0
  1307. package/dist/utils/uuid/v4.cjs.map +1 -0
  1308. package/dist/utils/uuid/v4.d.cts +8 -0
  1309. package/dist/utils/uuid/v4.d.cts.map +1 -0
  1310. package/dist/utils/uuid/v4.d.ts +8 -0
  1311. package/dist/utils/uuid/v4.d.ts.map +1 -0
  1312. package/dist/utils/uuid/v4.js +25 -0
  1313. package/dist/utils/uuid/v4.js.map +1 -0
  1314. package/dist/utils/uuid/v5.cjs +12 -0
  1315. package/dist/utils/uuid/v5.cjs.map +1 -0
  1316. package/dist/utils/uuid/v5.d.cts +14 -0
  1317. package/dist/utils/uuid/v5.d.cts.map +1 -0
  1318. package/dist/utils/uuid/v5.d.ts +14 -0
  1319. package/dist/utils/uuid/v5.d.ts.map +1 -0
  1320. package/dist/utils/uuid/v5.js +12 -0
  1321. package/dist/utils/uuid/v5.js.map +1 -0
  1322. package/dist/utils/uuid/v6.cjs +23 -0
  1323. package/dist/utils/uuid/v6.cjs.map +1 -0
  1324. package/dist/utils/uuid/v6.d.cts +8 -0
  1325. package/dist/utils/uuid/v6.d.cts.map +1 -0
  1326. package/dist/utils/uuid/v6.d.ts +8 -0
  1327. package/dist/utils/uuid/v6.d.ts.map +1 -0
  1328. package/dist/utils/uuid/v6.js +23 -0
  1329. package/dist/utils/uuid/v6.js.map +1 -0
  1330. package/dist/utils/uuid/v7.cjs +57 -0
  1331. package/dist/utils/uuid/v7.cjs.map +1 -0
  1332. package/dist/utils/uuid/v7.d.cts +8 -0
  1333. package/dist/utils/uuid/v7.d.cts.map +1 -0
  1334. package/dist/utils/uuid/v7.d.ts +8 -0
  1335. package/dist/utils/uuid/v7.d.ts.map +1 -0
  1336. package/dist/utils/uuid/v7.js +57 -0
  1337. package/dist/utils/uuid/v7.js.map +1 -0
  1338. package/dist/utils/uuid/validate.cjs +9 -0
  1339. package/dist/utils/uuid/validate.cjs.map +1 -0
  1340. package/dist/utils/uuid/validate.d.cts +5 -0
  1341. package/dist/utils/uuid/validate.d.cts.map +1 -0
  1342. package/dist/utils/uuid/validate.d.ts +5 -0
  1343. package/dist/utils/uuid/validate.d.ts.map +1 -0
  1344. package/dist/utils/uuid/validate.js +9 -0
  1345. package/dist/utils/uuid/validate.js.map +1 -0
  1346. package/dist/utils/uuid/version.cjs +10 -0
  1347. package/dist/utils/uuid/version.cjs.map +1 -0
  1348. package/dist/utils/uuid/version.d.cts +5 -0
  1349. package/dist/utils/uuid/version.d.cts.map +1 -0
  1350. package/dist/utils/uuid/version.d.ts +5 -0
  1351. package/dist/utils/uuid/version.d.ts.map +1 -0
  1352. package/dist/utils/uuid/version.js +10 -0
  1353. package/dist/utils/uuid/version.js.map +1 -0
  1354. package/dist/utils/zod-to-json-schema/Options.cjs +1 -2
  1355. package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -1
  1356. package/dist/utils/zod-to-json-schema/Options.d.cts +1 -0
  1357. package/dist/utils/zod-to-json-schema/Options.d.ts +1 -3
  1358. package/dist/utils/zod-to-json-schema/Options.js +1 -1
  1359. package/dist/utils/zod-to-json-schema/Options.js.map +1 -1
  1360. package/dist/utils/zod-to-json-schema/Refs.cjs +2 -3
  1361. package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -1
  1362. package/dist/utils/zod-to-json-schema/Refs.d.cts +1 -0
  1363. package/dist/utils/zod-to-json-schema/Refs.d.ts +1 -3
  1364. package/dist/utils/zod-to-json-schema/Refs.js +1 -2
  1365. package/dist/utils/zod-to-json-schema/Refs.js.map +1 -1
  1366. package/dist/utils/zod-to-json-schema/errorMessages.cjs +1 -2
  1367. package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -1
  1368. package/dist/utils/zod-to-json-schema/errorMessages.d.cts +0 -1
  1369. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -1
  1370. package/dist/utils/zod-to-json-schema/errorMessages.d.ts +0 -2
  1371. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -1
  1372. package/dist/utils/zod-to-json-schema/errorMessages.js +1 -1
  1373. package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -1
  1374. package/dist/utils/zod-to-json-schema/getRelativePath.cjs +1 -2
  1375. package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -1
  1376. package/dist/utils/zod-to-json-schema/getRelativePath.js +1 -1
  1377. package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -1
  1378. package/dist/utils/zod-to-json-schema/index.cjs +37 -37
  1379. package/dist/utils/zod-to-json-schema/index.d.cts +24 -0
  1380. package/dist/utils/zod-to-json-schema/index.d.ts +1 -14
  1381. package/dist/utils/zod-to-json-schema/index.js +38 -37
  1382. package/dist/utils/zod-to-json-schema/parseDef.cjs +5 -6
  1383. package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -1
  1384. package/dist/utils/zod-to-json-schema/parseDef.d.cts +1 -0
  1385. package/dist/utils/zod-to-json-schema/parseDef.d.ts +1 -3
  1386. package/dist/utils/zod-to-json-schema/parseDef.js +1 -2
  1387. package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -1
  1388. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -1
  1389. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -1
  1390. package/dist/utils/zod-to-json-schema/parsers/any.cjs +2 -3
  1391. package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -1
  1392. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -1
  1393. package/dist/utils/zod-to-json-schema/parsers/any.d.ts +0 -2
  1394. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -1
  1395. package/dist/utils/zod-to-json-schema/parsers/any.js +1 -2
  1396. package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -1
  1397. package/dist/utils/zod-to-json-schema/parsers/array.cjs +5 -6
  1398. package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -1
  1399. package/dist/utils/zod-to-json-schema/parsers/array.d.cts +0 -1
  1400. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -1
  1401. package/dist/utils/zod-to-json-schema/parsers/array.d.ts +0 -3
  1402. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -1
  1403. package/dist/utils/zod-to-json-schema/parsers/array.js +1 -2
  1404. package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -1
  1405. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +2 -3
  1406. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -1
  1407. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +0 -1
  1408. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -1
  1409. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +0 -3
  1410. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -1
  1411. package/dist/utils/zod-to-json-schema/parsers/bigint.js +1 -2
  1412. package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -1
  1413. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs +1 -2
  1414. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -1
  1415. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -1
  1416. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -1
  1417. package/dist/utils/zod-to-json-schema/parsers/boolean.js +1 -1
  1418. package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -1
  1419. package/dist/utils/zod-to-json-schema/parsers/branded.cjs +2 -3
  1420. package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -1
  1421. package/dist/utils/zod-to-json-schema/parsers/branded.d.cts +1 -0
  1422. package/dist/utils/zod-to-json-schema/parsers/branded.d.ts +1 -3
  1423. package/dist/utils/zod-to-json-schema/parsers/branded.js +1 -2
  1424. package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -1
  1425. package/dist/utils/zod-to-json-schema/parsers/catch.cjs +2 -3
  1426. package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -1
  1427. package/dist/utils/zod-to-json-schema/parsers/catch.d.cts +1 -0
  1428. package/dist/utils/zod-to-json-schema/parsers/catch.d.ts +1 -3
  1429. package/dist/utils/zod-to-json-schema/parsers/catch.js +1 -2
  1430. package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -1
  1431. package/dist/utils/zod-to-json-schema/parsers/date.cjs +2 -3
  1432. package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -1
  1433. package/dist/utils/zod-to-json-schema/parsers/date.d.cts +0 -2
  1434. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -1
  1435. package/dist/utils/zod-to-json-schema/parsers/date.d.ts +0 -4
  1436. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -1
  1437. package/dist/utils/zod-to-json-schema/parsers/date.js +1 -2
  1438. package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -1
  1439. package/dist/utils/zod-to-json-schema/parsers/default.cjs +2 -3
  1440. package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -1
  1441. package/dist/utils/zod-to-json-schema/parsers/default.d.cts +1 -0
  1442. package/dist/utils/zod-to-json-schema/parsers/default.d.ts +1 -3
  1443. package/dist/utils/zod-to-json-schema/parsers/default.js +1 -2
  1444. package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -1
  1445. package/dist/utils/zod-to-json-schema/parsers/effects.cjs +3 -4
  1446. package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -1
  1447. package/dist/utils/zod-to-json-schema/parsers/effects.d.cts +1 -0
  1448. package/dist/utils/zod-to-json-schema/parsers/effects.d.ts +1 -3
  1449. package/dist/utils/zod-to-json-schema/parsers/effects.js +1 -2
  1450. package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -1
  1451. package/dist/utils/zod-to-json-schema/parsers/enum.cjs +1 -2
  1452. package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -1
  1453. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -1
  1454. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +0 -2
  1455. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -1
  1456. package/dist/utils/zod-to-json-schema/parsers/enum.js +1 -1
  1457. package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -1
  1458. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +3 -4
  1459. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -1
  1460. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +0 -1
  1461. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -1
  1462. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +0 -3
  1463. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -1
  1464. package/dist/utils/zod-to-json-schema/parsers/intersection.js +2 -3
  1465. package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -1
  1466. package/dist/utils/zod-to-json-schema/parsers/literal.cjs +1 -2
  1467. package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -1
  1468. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +0 -1
  1469. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -1
  1470. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +0 -3
  1471. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -1
  1472. package/dist/utils/zod-to-json-schema/parsers/literal.js +1 -1
  1473. package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -1
  1474. package/dist/utils/zod-to-json-schema/parsers/map.cjs +21 -24
  1475. package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -1
  1476. package/dist/utils/zod-to-json-schema/parsers/map.d.cts +0 -2
  1477. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -1
  1478. package/dist/utils/zod-to-json-schema/parsers/map.d.ts +0 -4
  1479. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -1
  1480. package/dist/utils/zod-to-json-schema/parsers/map.js +18 -21
  1481. package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -1
  1482. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +3 -5
  1483. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -1
  1484. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -1
  1485. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +0 -2
  1486. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -1
  1487. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +3 -4
  1488. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -1
  1489. package/dist/utils/zod-to-json-schema/parsers/never.cjs +2 -3
  1490. package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -1
  1491. package/dist/utils/zod-to-json-schema/parsers/never.d.cts +0 -1
  1492. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -1
  1493. package/dist/utils/zod-to-json-schema/parsers/never.d.ts +0 -2
  1494. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -1
  1495. package/dist/utils/zod-to-json-schema/parsers/never.js +1 -2
  1496. package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -1
  1497. package/dist/utils/zod-to-json-schema/parsers/null.cjs +1 -2
  1498. package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -1
  1499. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -1
  1500. package/dist/utils/zod-to-json-schema/parsers/null.d.ts +0 -2
  1501. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -1
  1502. package/dist/utils/zod-to-json-schema/parsers/null.js +1 -1
  1503. package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -1
  1504. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +8 -9
  1505. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -1
  1506. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +0 -1
  1507. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -1
  1508. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +0 -3
  1509. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -1
  1510. package/dist/utils/zod-to-json-schema/parsers/nullable.js +6 -7
  1511. package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -1
  1512. package/dist/utils/zod-to-json-schema/parsers/number.cjs +2 -3
  1513. package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -1
  1514. package/dist/utils/zod-to-json-schema/parsers/number.d.cts +0 -1
  1515. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -1
  1516. package/dist/utils/zod-to-json-schema/parsers/number.d.ts +0 -3
  1517. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -1
  1518. package/dist/utils/zod-to-json-schema/parsers/number.js +1 -2
  1519. package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -1
  1520. package/dist/utils/zod-to-json-schema/parsers/object.cjs +2 -3
  1521. package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -1
  1522. package/dist/utils/zod-to-json-schema/parsers/object.d.cts +0 -1
  1523. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -1
  1524. package/dist/utils/zod-to-json-schema/parsers/object.d.ts +0 -3
  1525. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -1
  1526. package/dist/utils/zod-to-json-schema/parsers/object.js +1 -2
  1527. package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -1
  1528. package/dist/utils/zod-to-json-schema/parsers/optional.cjs +3 -4
  1529. package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -1
  1530. package/dist/utils/zod-to-json-schema/parsers/optional.d.cts +1 -0
  1531. package/dist/utils/zod-to-json-schema/parsers/optional.d.ts +1 -3
  1532. package/dist/utils/zod-to-json-schema/parsers/optional.js +1 -2
  1533. package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -1
  1534. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +4 -6
  1535. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -1
  1536. package/dist/utils/zod-to-json-schema/parsers/pipeline.d.cts +1 -0
  1537. package/dist/utils/zod-to-json-schema/parsers/pipeline.d.ts +1 -4
  1538. package/dist/utils/zod-to-json-schema/parsers/pipeline.js +3 -5
  1539. package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -1
  1540. package/dist/utils/zod-to-json-schema/parsers/promise.cjs +2 -3
  1541. package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -1
  1542. package/dist/utils/zod-to-json-schema/parsers/promise.d.cts +1 -0
  1543. package/dist/utils/zod-to-json-schema/parsers/promise.d.ts +1 -3
  1544. package/dist/utils/zod-to-json-schema/parsers/promise.js +1 -2
  1545. package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -1
  1546. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs +2 -3
  1547. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -1
  1548. package/dist/utils/zod-to-json-schema/parsers/readonly.d.cts +1 -0
  1549. package/dist/utils/zod-to-json-schema/parsers/readonly.d.ts +1 -3
  1550. package/dist/utils/zod-to-json-schema/parsers/readonly.js +1 -2
  1551. package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -1
  1552. package/dist/utils/zod-to-json-schema/parsers/record.cjs +9 -10
  1553. package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -1
  1554. package/dist/utils/zod-to-json-schema/parsers/record.d.cts +0 -1
  1555. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -1
  1556. package/dist/utils/zod-to-json-schema/parsers/record.d.ts +0 -3
  1557. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -1
  1558. package/dist/utils/zod-to-json-schema/parsers/record.js +3 -4
  1559. package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -1
  1560. package/dist/utils/zod-to-json-schema/parsers/set.cjs +7 -9
  1561. package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -1
  1562. package/dist/utils/zod-to-json-schema/parsers/set.d.cts +0 -1
  1563. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -1
  1564. package/dist/utils/zod-to-json-schema/parsers/set.d.ts +0 -3
  1565. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -1
  1566. package/dist/utils/zod-to-json-schema/parsers/set.js +5 -7
  1567. package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -1
  1568. package/dist/utils/zod-to-json-schema/parsers/string.cjs +28 -3
  1569. package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -1
  1570. package/dist/utils/zod-to-json-schema/parsers/string.d.cts +0 -2
  1571. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -1
  1572. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +0 -4
  1573. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -1
  1574. package/dist/utils/zod-to-json-schema/parsers/string.js +27 -2
  1575. package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -1
  1576. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs +2 -3
  1577. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -1
  1578. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +0 -1
  1579. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -1
  1580. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +0 -3
  1581. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -1
  1582. package/dist/utils/zod-to-json-schema/parsers/tuple.js +1 -2
  1583. package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -1
  1584. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs +2 -3
  1585. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -1
  1586. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +0 -1
  1587. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -1
  1588. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +0 -2
  1589. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -1
  1590. package/dist/utils/zod-to-json-schema/parsers/undefined.js +1 -2
  1591. package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -1
  1592. package/dist/utils/zod-to-json-schema/parsers/union.cjs +5 -9
  1593. package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -1
  1594. package/dist/utils/zod-to-json-schema/parsers/union.d.cts +1 -2
  1595. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -1
  1596. package/dist/utils/zod-to-json-schema/parsers/union.d.ts +0 -3
  1597. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -1
  1598. package/dist/utils/zod-to-json-schema/parsers/union.js +4 -8
  1599. package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -1
  1600. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs +2 -3
  1601. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -1
  1602. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +0 -1
  1603. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -1
  1604. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +0 -2
  1605. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -1
  1606. package/dist/utils/zod-to-json-schema/parsers/unknown.js +1 -2
  1607. package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -1
  1608. package/dist/utils/zod-to-json-schema/selectParser.cjs +34 -35
  1609. package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -1
  1610. package/dist/utils/zod-to-json-schema/selectParser.d.cts +1 -0
  1611. package/dist/utils/zod-to-json-schema/selectParser.d.ts +0 -2
  1612. package/dist/utils/zod-to-json-schema/selectParser.js +2 -3
  1613. package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -1
  1614. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +7 -8
  1615. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -1
  1616. package/dist/utils/zod-to-json-schema/zodToJsonSchema.d.cts +1 -0
  1617. package/dist/utils/zod-to-json-schema/zodToJsonSchema.d.ts +1 -3
  1618. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +4 -5
  1619. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -1
  1620. package/dist/vectorstores.cjs +12 -14
  1621. package/dist/vectorstores.cjs.map +1 -1
  1622. package/dist/vectorstores.d.cts +0 -1
  1623. package/dist/vectorstores.d.cts.map +1 -1
  1624. package/dist/vectorstores.d.ts +0 -1
  1625. package/dist/vectorstores.d.ts.map +1 -1
  1626. package/dist/vectorstores.js +4 -7
  1627. package/dist/vectorstores.js.map +1 -1
  1628. package/document_loaders/base.cjs +1 -0
  1629. package/document_loaders/base.d.cts +1 -0
  1630. package/document_loaders/base.d.ts +1 -0
  1631. package/document_loaders/base.js +1 -0
  1632. package/document_loaders/langsmith.cjs +1 -0
  1633. package/document_loaders/langsmith.d.cts +1 -0
  1634. package/document_loaders/langsmith.d.ts +1 -0
  1635. package/document_loaders/langsmith.js +1 -0
  1636. package/documents.cjs +1 -0
  1637. package/documents.d.cts +1 -0
  1638. package/documents.d.ts +1 -0
  1639. package/documents.js +1 -0
  1640. package/embeddings.cjs +1 -0
  1641. package/embeddings.d.cts +1 -0
  1642. package/embeddings.d.ts +1 -0
  1643. package/embeddings.js +1 -0
  1644. package/errors.cjs +1 -0
  1645. package/errors.d.cts +1 -0
  1646. package/errors.d.ts +1 -0
  1647. package/errors.js +1 -0
  1648. package/example_selectors.cjs +1 -0
  1649. package/example_selectors.d.cts +1 -0
  1650. package/example_selectors.d.ts +1 -0
  1651. package/example_selectors.js +1 -0
  1652. package/indexing.cjs +1 -0
  1653. package/indexing.d.cts +1 -0
  1654. package/indexing.d.ts +1 -0
  1655. package/indexing.js +1 -0
  1656. package/language_models/base.cjs +1 -0
  1657. package/language_models/base.d.cts +1 -0
  1658. package/language_models/base.d.ts +1 -0
  1659. package/language_models/base.js +1 -0
  1660. package/language_models/chat_models.cjs +1 -0
  1661. package/language_models/chat_models.d.cts +1 -0
  1662. package/language_models/chat_models.d.ts +1 -0
  1663. package/language_models/chat_models.js +1 -0
  1664. package/language_models/compat.cjs +1 -0
  1665. package/language_models/compat.d.cts +1 -0
  1666. package/language_models/compat.d.ts +1 -0
  1667. package/language_models/compat.js +1 -0
  1668. package/language_models/event.cjs +1 -0
  1669. package/language_models/event.d.cts +1 -0
  1670. package/language_models/event.d.ts +1 -0
  1671. package/language_models/event.js +1 -0
  1672. package/language_models/llms.cjs +1 -0
  1673. package/language_models/llms.d.cts +1 -0
  1674. package/language_models/llms.d.ts +1 -0
  1675. package/language_models/llms.js +1 -0
  1676. package/language_models/openai_completions_stream.cjs +1 -0
  1677. package/language_models/openai_completions_stream.d.cts +1 -0
  1678. package/language_models/openai_completions_stream.d.ts +1 -0
  1679. package/language_models/openai_completions_stream.js +1 -0
  1680. package/language_models/profile.cjs +1 -0
  1681. package/language_models/profile.d.cts +1 -0
  1682. package/language_models/profile.d.ts +1 -0
  1683. package/language_models/profile.js +1 -0
  1684. package/language_models/stream.cjs +1 -0
  1685. package/language_models/stream.d.cts +1 -0
  1686. package/language_models/stream.d.ts +1 -0
  1687. package/language_models/stream.js +1 -0
  1688. package/language_models/structured_output.cjs +1 -0
  1689. package/language_models/structured_output.d.cts +1 -0
  1690. package/language_models/structured_output.d.ts +1 -0
  1691. package/language_models/structured_output.js +1 -0
  1692. package/load/serializable.cjs +1 -0
  1693. package/load/serializable.d.cts +1 -0
  1694. package/load/serializable.d.ts +1 -0
  1695. package/load/serializable.js +1 -0
  1696. package/load.cjs +1 -0
  1697. package/load.d.cts +1 -0
  1698. package/load.d.ts +1 -0
  1699. package/load.js +1 -0
  1700. package/memory.cjs +1 -0
  1701. package/memory.d.cts +1 -0
  1702. package/memory.d.ts +1 -0
  1703. package/memory.js +1 -0
  1704. package/messages/tool.cjs +1 -0
  1705. package/messages/tool.d.cts +1 -0
  1706. package/messages/tool.d.ts +1 -0
  1707. package/messages/tool.js +1 -0
  1708. package/messages.cjs +1 -0
  1709. package/messages.d.cts +1 -0
  1710. package/messages.d.ts +1 -0
  1711. package/messages.js +1 -0
  1712. package/output_parsers/openai_functions.cjs +1 -0
  1713. package/output_parsers/openai_functions.d.cts +1 -0
  1714. package/output_parsers/openai_functions.d.ts +1 -0
  1715. package/output_parsers/openai_functions.js +1 -0
  1716. package/output_parsers/openai_tools.cjs +1 -0
  1717. package/output_parsers/openai_tools.d.cts +1 -0
  1718. package/output_parsers/openai_tools.d.ts +1 -0
  1719. package/output_parsers/openai_tools.js +1 -0
  1720. package/output_parsers.cjs +1 -0
  1721. package/output_parsers.d.cts +1 -0
  1722. package/output_parsers.d.ts +1 -0
  1723. package/output_parsers.js +1 -0
  1724. package/outputs.cjs +1 -0
  1725. package/outputs.d.cts +1 -0
  1726. package/outputs.d.ts +1 -0
  1727. package/outputs.js +1 -0
  1728. package/package.json +144 -27
  1729. package/prompt_values.cjs +1 -0
  1730. package/prompt_values.d.cts +1 -0
  1731. package/prompt_values.d.ts +1 -0
  1732. package/prompt_values.js +1 -0
  1733. package/prompts.cjs +1 -0
  1734. package/prompts.d.cts +1 -0
  1735. package/prompts.d.ts +1 -0
  1736. package/prompts.js +1 -0
  1737. package/retrievers/document_compressors.cjs +1 -0
  1738. package/retrievers/document_compressors.d.cts +1 -0
  1739. package/retrievers/document_compressors.d.ts +1 -0
  1740. package/retrievers/document_compressors.js +1 -0
  1741. package/retrievers.cjs +1 -0
  1742. package/retrievers.d.cts +1 -0
  1743. package/retrievers.d.ts +1 -0
  1744. package/retrievers.js +1 -0
  1745. package/runnables/graph.cjs +1 -0
  1746. package/runnables/graph.d.cts +1 -0
  1747. package/runnables/graph.d.ts +1 -0
  1748. package/runnables/graph.js +1 -0
  1749. package/runnables.cjs +1 -0
  1750. package/runnables.d.cts +1 -0
  1751. package/runnables.d.ts +1 -0
  1752. package/runnables.js +1 -0
  1753. package/singletons.cjs +1 -0
  1754. package/singletons.d.cts +1 -0
  1755. package/singletons.d.ts +1 -0
  1756. package/singletons.js +1 -0
  1757. package/stores.cjs +1 -0
  1758. package/stores.d.cts +1 -0
  1759. package/stores.d.ts +1 -0
  1760. package/stores.js +1 -0
  1761. package/structured_query.cjs +1 -0
  1762. package/structured_query.d.cts +1 -0
  1763. package/structured_query.d.ts +1 -0
  1764. package/structured_query.js +1 -0
  1765. package/testing.cjs +1 -0
  1766. package/testing.d.cts +1 -0
  1767. package/testing.d.ts +1 -0
  1768. package/testing.js +1 -0
  1769. package/tools.cjs +1 -0
  1770. package/tools.d.cts +1 -0
  1771. package/tools.d.ts +1 -0
  1772. package/tools.js +1 -0
  1773. package/tracers/base.cjs +1 -0
  1774. package/tracers/base.d.cts +1 -0
  1775. package/tracers/base.d.ts +1 -0
  1776. package/tracers/base.js +1 -0
  1777. package/tracers/console.cjs +1 -0
  1778. package/tracers/console.d.cts +1 -0
  1779. package/tracers/console.d.ts +1 -0
  1780. package/tracers/console.js +1 -0
  1781. package/tracers/log_stream.cjs +1 -0
  1782. package/tracers/log_stream.d.cts +1 -0
  1783. package/tracers/log_stream.d.ts +1 -0
  1784. package/tracers/log_stream.js +1 -0
  1785. package/tracers/run_collector.cjs +1 -0
  1786. package/tracers/run_collector.d.cts +1 -0
  1787. package/tracers/run_collector.d.ts +1 -0
  1788. package/tracers/run_collector.js +1 -0
  1789. package/tracers/tracer_langchain.cjs +1 -0
  1790. package/tracers/tracer_langchain.d.cts +1 -0
  1791. package/tracers/tracer_langchain.d.ts +1 -0
  1792. package/tracers/tracer_langchain.js +1 -0
  1793. package/types/stream.cjs +1 -0
  1794. package/types/stream.d.cts +1 -0
  1795. package/types/stream.d.ts +1 -0
  1796. package/types/stream.js +1 -0
  1797. package/utils/async_caller.cjs +1 -0
  1798. package/utils/async_caller.d.cts +1 -0
  1799. package/utils/async_caller.d.ts +1 -0
  1800. package/utils/async_caller.js +1 -0
  1801. package/utils/chunk_array.cjs +1 -0
  1802. package/utils/chunk_array.d.cts +1 -0
  1803. package/utils/chunk_array.d.ts +1 -0
  1804. package/utils/chunk_array.js +1 -0
  1805. package/utils/context.cjs +1 -0
  1806. package/utils/context.d.cts +1 -0
  1807. package/utils/context.d.ts +1 -0
  1808. package/utils/context.js +1 -0
  1809. package/utils/env.cjs +1 -0
  1810. package/utils/env.d.cts +1 -0
  1811. package/utils/env.d.ts +1 -0
  1812. package/utils/env.js +1 -0
  1813. package/utils/event_source_parse.cjs +1 -0
  1814. package/utils/event_source_parse.d.cts +1 -0
  1815. package/utils/event_source_parse.d.ts +1 -0
  1816. package/utils/event_source_parse.js +1 -0
  1817. package/utils/format.cjs +1 -0
  1818. package/utils/format.d.cts +1 -0
  1819. package/utils/format.d.ts +1 -0
  1820. package/utils/format.js +1 -0
  1821. package/utils/function_calling.cjs +1 -0
  1822. package/utils/function_calling.d.cts +1 -0
  1823. package/utils/function_calling.d.ts +1 -0
  1824. package/utils/function_calling.js +1 -0
  1825. package/utils/hash.cjs +1 -0
  1826. package/utils/hash.d.cts +1 -0
  1827. package/utils/hash.d.ts +1 -0
  1828. package/utils/hash.js +1 -0
  1829. package/utils/json_patch.cjs +1 -0
  1830. package/utils/json_patch.d.cts +1 -0
  1831. package/utils/json_patch.d.ts +1 -0
  1832. package/utils/json_patch.js +1 -0
  1833. package/utils/json_schema.cjs +1 -0
  1834. package/utils/json_schema.d.cts +1 -0
  1835. package/utils/json_schema.d.ts +1 -0
  1836. package/utils/json_schema.js +1 -0
  1837. package/utils/math.cjs +1 -0
  1838. package/utils/math.d.cts +1 -0
  1839. package/utils/math.d.ts +1 -0
  1840. package/utils/math.js +1 -0
  1841. package/utils/ssrf.cjs +1 -0
  1842. package/utils/ssrf.d.cts +1 -0
  1843. package/utils/ssrf.d.ts +1 -0
  1844. package/utils/ssrf.js +1 -0
  1845. package/utils/standard_schema.cjs +1 -0
  1846. package/utils/standard_schema.d.cts +1 -0
  1847. package/utils/standard_schema.d.ts +1 -0
  1848. package/utils/standard_schema.js +1 -0
  1849. package/utils/stream.cjs +1 -0
  1850. package/utils/stream.d.cts +1 -0
  1851. package/utils/stream.d.ts +1 -0
  1852. package/utils/stream.js +1 -0
  1853. package/utils/testing.cjs +1 -0
  1854. package/utils/testing.d.cts +1 -0
  1855. package/utils/testing.d.ts +1 -0
  1856. package/utils/testing.js +1 -0
  1857. package/utils/tiktoken.cjs +1 -0
  1858. package/utils/tiktoken.d.cts +1 -0
  1859. package/utils/tiktoken.d.ts +1 -0
  1860. package/utils/tiktoken.js +1 -0
  1861. package/utils/types.cjs +1 -0
  1862. package/utils/types.d.cts +1 -0
  1863. package/utils/types.d.ts +1 -0
  1864. package/utils/types.js +1 -0
  1865. package/utils/uuid.cjs +1 -0
  1866. package/utils/uuid.d.cts +1 -0
  1867. package/utils/uuid.d.ts +1 -0
  1868. package/utils/uuid.js +1 -0
  1869. package/vectorstores.cjs +1 -0
  1870. package/vectorstores.d.cts +1 -0
  1871. package/vectorstores.d.ts +1 -0
  1872. package/vectorstores.js +1 -0
  1873. package/dist/_virtual/rolldown_runtime.js +0 -11
@@ -1,14 +1,13 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_utils = require('./utils.cjs');
3
- const require_graph_mermaid = require('./graph_mermaid.cjs');
4
- const require_utils_json_schema = require('../utils/json_schema.cjs');
5
- const uuid = require_rolldown_runtime.__toESM(require("uuid"));
6
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
+ const require_utils_uuid_index = require("../utils/uuid/index.cjs");
4
+ const require_utils = require("./utils.cjs");
5
+ const require_graph_mermaid = require("./graph_mermaid.cjs");
6
+ const require_utils_json_schema = require("../utils/json_schema.cjs");
7
7
  //#region src/runnables/graph.ts
8
- var graph_exports = {};
9
- require_rolldown_runtime.__export(graph_exports, { Graph: () => Graph });
8
+ var graph_exports = /* @__PURE__ */ require_runtime.__exportAll({ Graph: () => Graph });
10
9
  function nodeDataStr(id, data) {
11
- if (id !== void 0 && !(0, uuid.validate)(id)) return id;
10
+ if (id !== void 0 && !require_utils_uuid_index.validate(id)) return id;
12
11
  else if (require_utils.isRunnableInterface(data)) try {
13
12
  let dataStr = data.getName();
14
13
  dataStr = dataStr.startsWith("Runnable") ? dataStr.slice(8) : dataStr;
@@ -44,7 +43,7 @@ var Graph = class Graph {
44
43
  toJSON() {
45
44
  const stableNodeIds = {};
46
45
  Object.values(this.nodes).forEach((node, i) => {
47
- stableNodeIds[node.id] = (0, uuid.validate)(node.id) ? i : node.id;
46
+ stableNodeIds[node.id] = require_utils_uuid_index.validate(node.id) ? i : node.id;
48
47
  });
49
48
  return {
50
49
  nodes: Object.values(this.nodes).map((node) => ({
@@ -64,7 +63,7 @@ var Graph = class Graph {
64
63
  }
65
64
  addNode(data, id, metadata) {
66
65
  if (id !== void 0 && this.nodes[id] !== void 0) throw new Error(`Node with id ${id} already exists`);
67
- const nodeId = id ?? (0, uuid.v4)();
66
+ const nodeId = id ?? require_utils_uuid_index.v4();
68
67
  const node = {
69
68
  id: nodeId,
70
69
  data,
@@ -102,8 +101,7 @@ var Graph = class Graph {
102
101
  */
103
102
  extend(graph, prefix = "") {
104
103
  let finalPrefix = prefix;
105
- const nodeIds = Object.values(graph.nodes).map((node) => node.id);
106
- if (nodeIds.every(uuid.validate)) finalPrefix = "";
104
+ if (Object.values(graph.nodes).map((node) => node.id).every(require_utils_uuid_index.validate)) finalPrefix = "";
107
105
  const prefixed = (id) => {
108
106
  return finalPrefix ? `${finalPrefix}:${id}` : id;
109
107
  };
@@ -151,7 +149,7 @@ var Graph = class Graph {
151
149
  });
152
150
  const getNodeId = (nodeId) => {
153
151
  const label = nodeLabels[nodeId];
154
- if ((0, uuid.validate)(nodeId) && nodeLabelCounts.get(label) === 1) return label;
152
+ if (require_utils_uuid_index.validate(nodeId) && nodeLabelCounts.get(label) === 1) return label;
155
153
  else return nodeId;
156
154
  };
157
155
  return new Graph({
@@ -185,8 +183,7 @@ var Graph = class Graph {
185
183
  });
186
184
  }
187
185
  async drawMermaidPng(params) {
188
- const mermaidSyntax = this.drawMermaid(params);
189
- return require_graph_mermaid.drawMermaidImage(mermaidSyntax, { backgroundColor: params?.backgroundColor });
186
+ return require_graph_mermaid.drawMermaidImage(this.drawMermaid(params), { backgroundColor: params?.backgroundColor });
190
187
  }
191
188
  };
192
189
  /**
@@ -213,13 +210,13 @@ function _lastNode(graph, exclude = []) {
213
210
  for (const node of Object.values(graph.nodes)) if (!exclude.includes(node.id) && !sources.has(node.id)) found.push(node);
214
211
  return found.length === 1 ? found[0] : void 0;
215
212
  }
216
-
217
213
  //#endregion
218
214
  exports.Graph = Graph;
219
- Object.defineProperty(exports, 'graph_exports', {
220
- enumerable: true,
221
- get: function () {
222
- return graph_exports;
223
- }
215
+ Object.defineProperty(exports, "graph_exports", {
216
+ enumerable: true,
217
+ get: function() {
218
+ return graph_exports;
219
+ }
224
220
  });
221
+
225
222
  //# sourceMappingURL=graph.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph.cjs","names":["id: string | undefined","data: RunnableInterface | RunnableIOSchema","isRunnableInterface","node: Node","toJsonSchema","params?: { nodes: Record<string, Node>; edges: Edge[] }","stableNodeIds: Record<string, string | number>","item: Record<string, unknown>","id?: string","metadata?: Record<string, any>","source: Node","target: Node","data?: string","conditional?: boolean","edge: Edge","graph: Graph","isUuid","id: string","nodeLabels: Record<string, string>","nodeId: string","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }","drawMermaid","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }","drawMermaidImage","exclude: string[]","found: Node[]"],"sources":["../../src/runnables/graph.ts"],"sourcesContent":["import { v4 as uuidv4, validate as isUuid } from \"uuid\";\nimport type {\n RunnableInterface,\n RunnableIOSchema,\n Node,\n Edge,\n} from \"./types.js\";\nimport { isRunnableInterface } from \"./utils.js\";\nimport { drawMermaid, drawMermaidImage } from \"./graph_mermaid.js\";\nimport { toJsonSchema } from \"../utils/json_schema.js\";\n\nexport { Node, Edge };\n\nfunction nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n}\n\nfunction nodeDataJson(node: Node) {\n // if node.data implements Runnable\n if (isRunnableInterface(node.data)) {\n return {\n type: \"runnable\",\n data: {\n id: node.data.lc_id,\n name: node.data.getName(),\n },\n };\n } else {\n return {\n type: \"schema\",\n data: { ...toJsonSchema(node.data.schema), title: node.data.name },\n };\n }\n}\n\nexport class Graph {\n nodes: Record<string, Node> = {};\n\n edges: Edge[] = [];\n\n constructor(params?: { nodes: Record<string, Node>; edges: Edge[] }) {\n this.nodes = params?.nodes ?? this.nodes;\n this.edges = params?.edges ?? this.edges;\n }\n\n // Convert the graph to a JSON-serializable format.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(): Record<string, any> {\n const stableNodeIds: Record<string, string | number> = {};\n Object.values(this.nodes).forEach((node, i) => {\n stableNodeIds[node.id] = isUuid(node.id) ? i : node.id;\n });\n\n return {\n nodes: Object.values(this.nodes).map((node) => ({\n id: stableNodeIds[node.id],\n ...nodeDataJson(node),\n })),\n edges: this.edges.map((edge) => {\n const item: Record<string, unknown> = {\n source: stableNodeIds[edge.source],\n target: stableNodeIds[edge.target],\n };\n\n if (typeof edge.data !== \"undefined\") {\n item.data = edge.data;\n }\n\n if (typeof edge.conditional !== \"undefined\") {\n item.conditional = edge.conditional;\n }\n return item;\n }),\n };\n }\n\n addNode(\n data: RunnableInterface | RunnableIOSchema,\n id?: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): Node {\n if (id !== undefined && this.nodes[id] !== undefined) {\n throw new Error(`Node with id ${id} already exists`);\n }\n const nodeId = id ?? uuidv4();\n const node: Node = {\n id: nodeId,\n data,\n name: nodeDataStr(id, data),\n metadata,\n };\n this.nodes[nodeId] = node;\n return node;\n }\n\n removeNode(node: Node): void {\n // Remove the node from the nodes map\n delete this.nodes[node.id];\n\n // Filter out edges connected to the node\n this.edges = this.edges.filter(\n (edge) => edge.source !== node.id && edge.target !== node.id\n );\n }\n\n addEdge(\n source: Node,\n target: Node,\n data?: string,\n conditional?: boolean\n ): Edge {\n if (this.nodes[source.id] === undefined) {\n throw new Error(`Source node ${source.id} not in graph`);\n }\n if (this.nodes[target.id] === undefined) {\n throw new Error(`Target node ${target.id} not in graph`);\n }\n const edge: Edge = {\n source: source.id,\n target: target.id,\n data,\n conditional,\n };\n this.edges.push(edge);\n return edge;\n }\n\n firstNode(): Node | undefined {\n return _firstNode(this);\n }\n\n lastNode(): Node | undefined {\n return _lastNode(this);\n }\n\n /**\n * Add all nodes and edges from another graph.\n * Note this doesn't check for duplicates, nor does it connect the graphs.\n */\n extend(graph: Graph, prefix = \"\") {\n let finalPrefix = prefix;\n const nodeIds = Object.values(graph.nodes).map((node) => node.id);\n if (nodeIds.every(isUuid)) {\n finalPrefix = \"\";\n }\n\n const prefixed = (id: string) => {\n return finalPrefix ? `${finalPrefix}:${id}` : id;\n };\n\n Object.entries(graph.nodes).forEach(([key, value]) => {\n this.nodes[prefixed(key)] = { ...value, id: prefixed(key) };\n });\n\n const newEdges = graph.edges.map((edge) => {\n return {\n ...edge,\n source: prefixed(edge.source),\n target: prefixed(edge.target),\n };\n });\n // Add all edges from the other graph\n this.edges = [...this.edges, ...newEdges];\n const first = graph.firstNode();\n const last = graph.lastNode();\n return [\n first ? { id: prefixed(first.id), data: first.data } : undefined,\n last ? { id: prefixed(last.id), data: last.data } : undefined,\n ];\n }\n\n trimFirstNode(): void {\n const firstNode = this.firstNode();\n if (firstNode && _firstNode(this, [firstNode.id])) {\n this.removeNode(firstNode);\n }\n }\n\n trimLastNode(): void {\n const lastNode = this.lastNode();\n if (lastNode && _lastNode(this, [lastNode.id])) {\n this.removeNode(lastNode);\n }\n }\n\n /**\n * Return a new graph with all nodes re-identified,\n * using their unique, readable names where possible.\n */\n reid(): Graph {\n const nodeLabels: Record<string, string> = Object.fromEntries(\n Object.values(this.nodes).map((node) => [node.id, node.name])\n );\n const nodeLabelCounts = new Map<string, number>();\n Object.values(nodeLabels).forEach((label) => {\n nodeLabelCounts.set(label, (nodeLabelCounts.get(label) || 0) + 1);\n });\n\n const getNodeId = (nodeId: string): string => {\n const label = nodeLabels[nodeId];\n if (isUuid(nodeId) && nodeLabelCounts.get(label) === 1) {\n return label;\n } else {\n return nodeId;\n }\n };\n\n return new Graph({\n nodes: Object.fromEntries(\n Object.entries(this.nodes).map(([id, node]) => [\n getNodeId(id),\n { ...node, id: getNodeId(id) },\n ])\n ),\n edges: this.edges.map((edge) => ({\n ...edge,\n source: getNodeId(edge.source),\n target: getNodeId(edge.target),\n })),\n });\n }\n\n drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }): string {\n const {\n withStyles,\n curveStyle,\n nodeColors = {\n default: \"fill:#f2f0ff,line-height:1.2\",\n first: \"fill-opacity:0\",\n last: \"fill:#bfb6fc\",\n },\n wrapLabelNWords,\n } = params ?? {};\n const graph = this.reid();\n const firstNode = graph.firstNode();\n\n const lastNode = graph.lastNode();\n\n return drawMermaid(graph.nodes, graph.edges, {\n firstNode: firstNode?.id,\n lastNode: lastNode?.id,\n withStyles,\n curveStyle,\n nodeColors,\n wrapLabelNWords,\n });\n }\n\n async drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Blob> {\n const mermaidSyntax = this.drawMermaid(params);\n return drawMermaidImage(mermaidSyntax, {\n backgroundColor: params?.backgroundColor,\n });\n }\n}\n/**\n * Find the single node that is not a target of any edge.\n * Exclude nodes/sources with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the origin.\n */\nfunction _firstNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const targets = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.source))\n .map((edge) => edge.target)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !targets.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n\n/**\n * Find the single node that is not a source of any edge.\n * Exclude nodes/targets with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the destination.\n */\nfunction _lastNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const sources = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.target))\n .map((edge) => edge.source)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !sources.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n"],"mappings":";;;;;;;;;AAaA,SAAS,YACPA,IACAC,MACQ;AACR,KAAI,OAAO,UAAa,oBAAQ,GAAG,CACjC,QAAO;UACEC,kCAAoB,KAAK,CAClC,KAAI;EACF,IAAI,UAAU,KAAK,SAAS;EAC5B,UAAU,QAAQ,WAAW,WAAW,GACpC,QAAQ,MAAM,EAAkB,GAChC;AACJ,SAAO;CACR,QAAO;AACN,SAAO,KAAK,SAAS;CACtB;KAED,QAAO,KAAK,QAAQ;AAEvB;AAED,SAAS,aAAaC,MAAY;AAEhC,KAAID,kCAAoB,KAAK,KAAK,CAChC,QAAO;EACL,MAAM;EACN,MAAM;GACJ,IAAI,KAAK,KAAK;GACd,MAAM,KAAK,KAAK,SAAS;EAC1B;CACF;KAED,Q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AAK;AACxC"}
1
+ {"version":3,"file":"graph.cjs","names":["isUuid","isRunnableInterface","toJsonSchema","uuidv4","drawMermaid","drawMermaidImage"],"sources":["../../src/runnables/graph.ts"],"sourcesContent":["import { v4 as uuidv4, validate as isUuid } from \"../utils/uuid/index.js\";\nimport type {\n RunnableInterface,\n RunnableIOSchema,\n Node,\n Edge,\n} from \"./types.js\";\nimport { isRunnableInterface } from \"./utils.js\";\nimport { drawMermaid, drawMermaidImage } from \"./graph_mermaid.js\";\nimport { toJsonSchema } from \"../utils/json_schema.js\";\n\nexport { Node, Edge };\n\nfunction nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n}\n\nfunction nodeDataJson(node: Node) {\n // if node.data implements Runnable\n if (isRunnableInterface(node.data)) {\n return {\n type: \"runnable\",\n data: {\n id: node.data.lc_id,\n name: node.data.getName(),\n },\n };\n } else {\n return {\n type: \"schema\",\n data: { ...toJsonSchema(node.data.schema), title: node.data.name },\n };\n }\n}\n\nexport class Graph {\n nodes: Record<string, Node> = {};\n\n edges: Edge[] = [];\n\n constructor(params?: { nodes: Record<string, Node>; edges: Edge[] }) {\n this.nodes = params?.nodes ?? this.nodes;\n this.edges = params?.edges ?? this.edges;\n }\n\n // Convert the graph to a JSON-serializable format.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(): Record<string, any> {\n const stableNodeIds: Record<string, string | number> = {};\n Object.values(this.nodes).forEach((node, i) => {\n stableNodeIds[node.id] = isUuid(node.id) ? i : node.id;\n });\n\n return {\n nodes: Object.values(this.nodes).map((node) => ({\n id: stableNodeIds[node.id],\n ...nodeDataJson(node),\n })),\n edges: this.edges.map((edge) => {\n const item: Record<string, unknown> = {\n source: stableNodeIds[edge.source],\n target: stableNodeIds[edge.target],\n };\n\n if (typeof edge.data !== \"undefined\") {\n item.data = edge.data;\n }\n\n if (typeof edge.conditional !== \"undefined\") {\n item.conditional = edge.conditional;\n }\n return item;\n }),\n };\n }\n\n addNode(\n data: RunnableInterface | RunnableIOSchema,\n id?: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): Node {\n if (id !== undefined && this.nodes[id] !== undefined) {\n throw new Error(`Node with id ${id} already exists`);\n }\n const nodeId = id ?? uuidv4();\n const node: Node = {\n id: nodeId,\n data,\n name: nodeDataStr(id, data),\n metadata,\n };\n this.nodes[nodeId] = node;\n return node;\n }\n\n removeNode(node: Node): void {\n // Remove the node from the nodes map\n delete this.nodes[node.id];\n\n // Filter out edges connected to the node\n this.edges = this.edges.filter(\n (edge) => edge.source !== node.id && edge.target !== node.id\n );\n }\n\n addEdge(\n source: Node,\n target: Node,\n data?: string,\n conditional?: boolean\n ): Edge {\n if (this.nodes[source.id] === undefined) {\n throw new Error(`Source node ${source.id} not in graph`);\n }\n if (this.nodes[target.id] === undefined) {\n throw new Error(`Target node ${target.id} not in graph`);\n }\n const edge: Edge = {\n source: source.id,\n target: target.id,\n data,\n conditional,\n };\n this.edges.push(edge);\n return edge;\n }\n\n firstNode(): Node | undefined {\n return _firstNode(this);\n }\n\n lastNode(): Node | undefined {\n return _lastNode(this);\n }\n\n /**\n * Add all nodes and edges from another graph.\n * Note this doesn't check for duplicates, nor does it connect the graphs.\n */\n extend(graph: Graph, prefix = \"\") {\n let finalPrefix = prefix;\n const nodeIds = Object.values(graph.nodes).map((node) => node.id);\n if (nodeIds.every(isUuid)) {\n finalPrefix = \"\";\n }\n\n const prefixed = (id: string) => {\n return finalPrefix ? `${finalPrefix}:${id}` : id;\n };\n\n Object.entries(graph.nodes).forEach(([key, value]) => {\n this.nodes[prefixed(key)] = { ...value, id: prefixed(key) };\n });\n\n const newEdges = graph.edges.map((edge) => {\n return {\n ...edge,\n source: prefixed(edge.source),\n target: prefixed(edge.target),\n };\n });\n // Add all edges from the other graph\n this.edges = [...this.edges, ...newEdges];\n const first = graph.firstNode();\n const last = graph.lastNode();\n return [\n first ? { id: prefixed(first.id), data: first.data } : undefined,\n last ? { id: prefixed(last.id), data: last.data } : undefined,\n ];\n }\n\n trimFirstNode(): void {\n const firstNode = this.firstNode();\n if (firstNode && _firstNode(this, [firstNode.id])) {\n this.removeNode(firstNode);\n }\n }\n\n trimLastNode(): void {\n const lastNode = this.lastNode();\n if (lastNode && _lastNode(this, [lastNode.id])) {\n this.removeNode(lastNode);\n }\n }\n\n /**\n * Return a new graph with all nodes re-identified,\n * using their unique, readable names where possible.\n */\n reid(): Graph {\n const nodeLabels: Record<string, string> = Object.fromEntries(\n Object.values(this.nodes).map((node) => [node.id, node.name])\n );\n const nodeLabelCounts = new Map<string, number>();\n Object.values(nodeLabels).forEach((label) => {\n nodeLabelCounts.set(label, (nodeLabelCounts.get(label) || 0) + 1);\n });\n\n const getNodeId = (nodeId: string): string => {\n const label = nodeLabels[nodeId];\n if (isUuid(nodeId) && nodeLabelCounts.get(label) === 1) {\n return label;\n } else {\n return nodeId;\n }\n };\n\n return new Graph({\n nodes: Object.fromEntries(\n Object.entries(this.nodes).map(([id, node]) => [\n getNodeId(id),\n { ...node, id: getNodeId(id) },\n ])\n ),\n edges: this.edges.map((edge) => ({\n ...edge,\n source: getNodeId(edge.source),\n target: getNodeId(edge.target),\n })),\n });\n }\n\n drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }): string {\n const {\n withStyles,\n curveStyle,\n nodeColors = {\n default: \"fill:#f2f0ff,line-height:1.2\",\n first: \"fill-opacity:0\",\n last: \"fill:#bfb6fc\",\n },\n wrapLabelNWords,\n } = params ?? {};\n const graph = this.reid();\n const firstNode = graph.firstNode();\n\n const lastNode = graph.lastNode();\n\n return drawMermaid(graph.nodes, graph.edges, {\n firstNode: firstNode?.id,\n lastNode: lastNode?.id,\n withStyles,\n curveStyle,\n nodeColors,\n wrapLabelNWords,\n });\n }\n\n async drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Blob> {\n const mermaidSyntax = this.drawMermaid(params);\n return drawMermaidImage(mermaidSyntax, {\n backgroundColor: params?.backgroundColor,\n });\n }\n}\n/**\n * Find the single node that is not a target of any edge.\n * Exclude nodes/sources with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the origin.\n */\nfunction _firstNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const targets = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.source))\n .map((edge) => edge.target)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !targets.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n\n/**\n * Find the single node that is not a source of any edge.\n * Exclude nodes/targets with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the destination.\n */\nfunction _lastNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const sources = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.target))\n .map((edge) => edge.source)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !sources.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n"],"mappings":";;;;;;;;AAaA,SAAS,YACP,IACA,MACQ;AACR,KAAI,OAAO,KAAA,KAAa,CAACA,yBAAAA,SAAO,GAAG,CACjC,QAAO;UACEC,cAAAA,oBAAoB,KAAK,CAClC,KAAI;EACF,IAAI,UAAU,KAAK,SAAS;AAC5B,YAAU,QAAQ,WAAW,WAAW,GAC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AAK,GAAG,CACrD,OAAM,KAAK,KAAK;AAGpB,QAAO,MAAM,WAAW,IAAI,MAAM,KAAK,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.cts","names":["RunnableInterface","RunnableIOSchema","Node","Edge","Graph","Record","__types_js0","RunnableConfig","Blob","Promise"],"sources":["../../src/runnables/graph.d.ts"],"sourcesContent":["import type { RunnableInterface, RunnableIOSchema, Node, Edge } from \"./types.js\";\nexport { Node, Edge };\nexport declare class Graph {\n nodes: Record<string, Node>;\n edges: Edge[];\n constructor(params?: {\n nodes: Record<string, Node>;\n edges: Edge[];\n });\n toJSON(): Record<string, any>;\n addNode(data: RunnableInterface | RunnableIOSchema, id?: string, metadata?: Record<string, any>): Node;\n removeNode(node: Node): void;\n addEdge(source: Node, target: Node, data?: string, conditional?: boolean): Edge;\n firstNode(): Node | undefined;\n lastNode(): Node | undefined;\n /**\n * Add all nodes and edges from another graph.\n * Note this doesn't check for duplicates, nor does it connect the graphs.\n */\n extend(graph: Graph, prefix?: string): ({\n id: string;\n data: RunnableIOSchema | RunnableInterface<any, any, import(\"./types.js\").RunnableConfig<Record<string, any>>>;\n } | undefined)[];\n trimFirstNode(): void;\n trimLastNode(): void;\n /**\n * Return a new graph with all nodes re-identified,\n * using their unique, readable names where possible.\n */\n reid(): Graph;\n drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }): string;\n drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Blob>;\n}\n//# sourceMappingURL=graph.d.ts.map"],"mappings":";;;cAEqBI,KAAAA;EAAAA,KAAAA,EACVC,MADe,CAAA,MAAA,EACAH,IADA,CAAA;EACAA,KAAAA,EACfC,IADeD,EAAAA;EAAfG,WAAAA,CAAAA,MAGIA,CAHJA,EAAAA;IACAF,KAAAA,EAEIE,MAFJ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MAA;;;MAGbI,QAAQD"}
1
+ {"version":3,"file":"graph.d.cts","names":[],"sources":["../../src/runnables/graph.ts"],"mappings":";;;cAoDa,KAAA;EACX,KAAA,EAAO,MAAA,SAAe,IAAA;EAEtB,KAAA,EAAO,IAAA;EAEP,WAAA,CAAY,MAAA;IAAW,KAAA,EAAO,MAAA,SAAe,IAAA;IAAO,KAAA,EAAO,IAAA;EAAA;EAO3D,MAAA,CAAA,GAAU,MAAA;EA6BV,OAAA,CACE,IAAA,EAAM,iBAAA,GAAoB,gBAAA,EAC1B,EAAA,WAEA,QAAA,GAAW,MAAA,gBACV,IAAA;EAeH,UAAA,CAAW,IAAA,EAAM,IAAA;EAUjB,OAAA,CACE,MAAA,EAAQ,IAAA,EACR,MAAA,EAAQ,IAAA,EACR,IAAA,WACA,WAAA,aACC,IAAA;EAiBH,SAAA,CAAA,GAAa,IAAA;EAIb,QAAA,CAAA,GAAY,IAAA;EApDC;;;;EA4Db,MAAA,CAAO,KAAA,EAAO,KAAA,EAAO,MAAA;;;;EAgCrB,aAAA,CAAA;EAOA,YAAA,CAAA;;;;;EAWA,IAAA,CAAA,GAAQ,KAAA;EAiCR,WAAA,CAAY,MAAA;IACV,UAAA;IACA,UAAA;IACA,UAAA,GAAa,MAAA;IACb,eAAA;EAAA;EA2BI,cAAA,CAAe,MAAA;IACnB,UAAA;IACA,UAAA;IACA,UAAA,GAAa,MAAA;IACb,eAAA;IACA,eAAA;EAAA,IACE,OAAA,CAAQ,IAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","names":["RunnableInterface","RunnableIOSchema","Node","Edge","Graph","Record","__types_js0","RunnableConfig","Blob","Promise"],"sources":["../../src/runnables/graph.d.ts"],"sourcesContent":["import type { RunnableInterface, RunnableIOSchema, Node, Edge } from \"./types.js\";\nexport { Node, Edge };\nexport declare class Graph {\n nodes: Record<string, Node>;\n edges: Edge[];\n constructor(params?: {\n nodes: Record<string, Node>;\n edges: Edge[];\n });\n toJSON(): Record<string, any>;\n addNode(data: RunnableInterface | RunnableIOSchema, id?: string, metadata?: Record<string, any>): Node;\n removeNode(node: Node): void;\n addEdge(source: Node, target: Node, data?: string, conditional?: boolean): Edge;\n firstNode(): Node | undefined;\n lastNode(): Node | undefined;\n /**\n * Add all nodes and edges from another graph.\n * Note this doesn't check for duplicates, nor does it connect the graphs.\n */\n extend(graph: Graph, prefix?: string): ({\n id: string;\n data: RunnableIOSchema | RunnableInterface<any, any, import(\"./types.js\").RunnableConfig<Record<string, any>>>;\n } | undefined)[];\n trimFirstNode(): void;\n trimLastNode(): void;\n /**\n * Return a new graph with all nodes re-identified,\n * using their unique, readable names where possible.\n */\n reid(): Graph;\n drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }): string;\n drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Blob>;\n}\n//# sourceMappingURL=graph.d.ts.map"],"mappings":";;;cAEqBI,KAAAA;EAAAA,KAAAA,EACVC,MADe,CAAA,MAAA,EACAH,IADA,CAAA;EACAA,KAAAA,EACfC,IADeD,EAAAA;EAAfG,WAAAA,CAAAA,MAGIA,CAHJA,EAAAA;IACAF,KAAAA,EAEIE,MAFJF,CAAAA,MAAAA,EAEmBD,IAFnBC,CAAAA;IAEmBD,KAAAA,EACfC,IADeD,EAAAA;EAAfG,CAAAA;EACAF,MAAAA,CAAAA,CAAAA,EAEDE,MAFCF,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAEDE,OAAAA,CAAAA,IAAAA,EACIL,iBADJK,GACwBJ,gBADxBI,EAAAA,EAAAA,CAAAA,EAAAA,MAAAA,EAAAA,QAAAA,CAAAA,EACkEA,MADlEA,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,EACwFH,IADxFG;EACIL,UAAAA,CAAAA,IAAAA,EAC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eH,UAAA,CAAW,IAAA,EAAM,IAAA;EAUjB,OAAA,CACE,MAAA,EAAQ,IAAA,EACR,MAAA,EAAQ,IAAA,EACR,IAAA,WACA,WAAA,aACC,IAAA;EAiBH,SAAA,CAAA,GAAa,IAAA;EAIb,QAAA,CAAA,GAAY,IAAA;EApDC;;;;EA4Db,MAAA,CAAO,KAAA,EAAO,KAAA,EAAO,MAAA;;;;EAgCrB,aAAA,CAAA;EAOA,YAAA,CAAA;;;;;EAWA,IAAA,CAAA,GAAQ,KAAA;EAiCR,WAAA,CAAY,MAAA;IACV,UAAA;IACA,UAAA;IACA,UAAA,GAAa,MAAA;IACb,eAAA;EAAA;EA2BI,cAAA,CAAe,MAAA;IACnB,UAAA;IACA,UAAA;IACA,UAAA,GAAa,MAAA;IACb,eAAA;IACA,eAAA;EAAA,IACE,OAAA,CAAQ,IAAA;AAAA"}
@@ -1,12 +1,10 @@
1
- import { __export } from "../_virtual/rolldown_runtime.js";
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { v4, validate } from "../utils/uuid/index.js";
2
3
  import { isRunnableInterface } from "./utils.js";
3
4
  import { drawMermaid, drawMermaidImage } from "./graph_mermaid.js";
4
5
  import { toJsonSchema } from "../utils/json_schema.js";
5
- import { v4, validate } from "uuid";
6
-
7
6
  //#region src/runnables/graph.ts
8
- var graph_exports = {};
9
- __export(graph_exports, { Graph: () => Graph });
7
+ var graph_exports = /* @__PURE__ */ __exportAll({ Graph: () => Graph });
10
8
  function nodeDataStr(id, data) {
11
9
  if (id !== void 0 && !validate(id)) return id;
12
10
  else if (isRunnableInterface(data)) try {
@@ -102,8 +100,7 @@ var Graph = class Graph {
102
100
  */
103
101
  extend(graph, prefix = "") {
104
102
  let finalPrefix = prefix;
105
- const nodeIds = Object.values(graph.nodes).map((node) => node.id);
106
- if (nodeIds.every(validate)) finalPrefix = "";
103
+ if (Object.values(graph.nodes).map((node) => node.id).every(validate)) finalPrefix = "";
107
104
  const prefixed = (id) => {
108
105
  return finalPrefix ? `${finalPrefix}:${id}` : id;
109
106
  };
@@ -185,8 +182,7 @@ var Graph = class Graph {
185
182
  });
186
183
  }
187
184
  async drawMermaidPng(params) {
188
- const mermaidSyntax = this.drawMermaid(params);
189
- return drawMermaidImage(mermaidSyntax, { backgroundColor: params?.backgroundColor });
185
+ return drawMermaidImage(this.drawMermaid(params), { backgroundColor: params?.backgroundColor });
190
186
  }
191
187
  };
192
188
  /**
@@ -213,7 +209,7 @@ function _lastNode(graph, exclude = []) {
213
209
  for (const node of Object.values(graph.nodes)) if (!exclude.includes(node.id) && !sources.has(node.id)) found.push(node);
214
210
  return found.length === 1 ? found[0] : void 0;
215
211
  }
216
-
217
212
  //#endregion
218
213
  export { Graph, graph_exports };
214
+
219
215
  //# sourceMappingURL=graph.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph.js","names":["id: string | undefined","data: RunnableInterface | RunnableIOSchema","isUuid","node: Node","params?: { nodes: Record<string, Node>; edges: Edge[] }","stableNodeIds: Record<string, string | number>","item: Record<string, unknown>","id?: string","metadata?: Record<string, any>","uuidv4","source: Node","target: Node","data?: string","conditional?: boolean","edge: Edge","graph: Graph","id: string","nodeLabels: Record<string, string>","nodeId: string","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }","params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }","exclude: string[]","found: Node[]"],"sources":["../../src/runnables/graph.ts"],"sourcesContent":["import { v4 as uuidv4, validate as isUuid } from \"uuid\";\nimport type {\n RunnableInterface,\n RunnableIOSchema,\n Node,\n Edge,\n} from \"./types.js\";\nimport { isRunnableInterface } from \"./utils.js\";\nimport { drawMermaid, drawMermaidImage } from \"./graph_mermaid.js\";\nimport { toJsonSchema } from \"../utils/json_schema.js\";\n\nexport { Node, Edge };\n\nfunction nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n}\n\nfunction nodeDataJson(node: Node) {\n // if node.data implements Runnable\n if (isRunnableInterface(node.data)) {\n return {\n type: \"runnable\",\n data: {\n id: node.data.lc_id,\n name: node.data.getName(),\n },\n };\n } else {\n return {\n type: \"schema\",\n data: { ...toJsonSchema(node.data.schema), title: node.data.name },\n };\n }\n}\n\nexport class Graph {\n nodes: Record<string, Node> = {};\n\n edges: Edge[] = [];\n\n constructor(params?: { nodes: Record<string, Node>; edges: Edge[] }) {\n this.nodes = params?.nodes ?? this.nodes;\n this.edges = params?.edges ?? this.edges;\n }\n\n // Convert the graph to a JSON-serializable format.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(): Record<string, any> {\n const stableNodeIds: Record<string, string | number> = {};\n Object.values(this.nodes).forEach((node, i) => {\n stableNodeIds[node.id] = isUuid(node.id) ? i : node.id;\n });\n\n return {\n nodes: Object.values(this.nodes).map((node) => ({\n id: stableNodeIds[node.id],\n ...nodeDataJson(node),\n })),\n edges: this.edges.map((edge) => {\n const item: Record<string, unknown> = {\n source: stableNodeIds[edge.source],\n target: stableNodeIds[edge.target],\n };\n\n if (typeof edge.data !== \"undefined\") {\n item.data = edge.data;\n }\n\n if (typeof edge.conditional !== \"undefined\") {\n item.conditional = edge.conditional;\n }\n return item;\n }),\n };\n }\n\n addNode(\n data: RunnableInterface | RunnableIOSchema,\n id?: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): Node {\n if (id !== undefined && this.nodes[id] !== undefined) {\n throw new Error(`Node with id ${id} already exists`);\n }\n const nodeId = id ?? uuidv4();\n const node: Node = {\n id: nodeId,\n data,\n name: nodeDataStr(id, data),\n metadata,\n };\n this.nodes[nodeId] = node;\n return node;\n }\n\n removeNode(node: Node): void {\n // Remove the node from the nodes map\n delete this.nodes[node.id];\n\n // Filter out edges connected to the node\n this.edges = this.edges.filter(\n (edge) => edge.source !== node.id && edge.target !== node.id\n );\n }\n\n addEdge(\n source: Node,\n target: Node,\n data?: string,\n conditional?: boolean\n ): Edge {\n if (this.nodes[source.id] === undefined) {\n throw new Error(`Source node ${source.id} not in graph`);\n }\n if (this.nodes[target.id] === undefined) {\n throw new Error(`Target node ${target.id} not in graph`);\n }\n const edge: Edge = {\n source: source.id,\n target: target.id,\n data,\n conditional,\n };\n this.edges.push(edge);\n return edge;\n }\n\n firstNode(): Node | undefined {\n return _firstNode(this);\n }\n\n lastNode(): Node | undefined {\n return _lastNode(this);\n }\n\n /**\n * Add all nodes and edges from another graph.\n * Note this doesn't check for duplicates, nor does it connect the graphs.\n */\n extend(graph: Graph, prefix = \"\") {\n let finalPrefix = prefix;\n const nodeIds = Object.values(graph.nodes).map((node) => node.id);\n if (nodeIds.every(isUuid)) {\n finalPrefix = \"\";\n }\n\n const prefixed = (id: string) => {\n return finalPrefix ? `${finalPrefix}:${id}` : id;\n };\n\n Object.entries(graph.nodes).forEach(([key, value]) => {\n this.nodes[prefixed(key)] = { ...value, id: prefixed(key) };\n });\n\n const newEdges = graph.edges.map((edge) => {\n return {\n ...edge,\n source: prefixed(edge.source),\n target: prefixed(edge.target),\n };\n });\n // Add all edges from the other graph\n this.edges = [...this.edges, ...newEdges];\n const first = graph.firstNode();\n const last = graph.lastNode();\n return [\n first ? { id: prefixed(first.id), data: first.data } : undefined,\n last ? { id: prefixed(last.id), data: last.data } : undefined,\n ];\n }\n\n trimFirstNode(): void {\n const firstNode = this.firstNode();\n if (firstNode && _firstNode(this, [firstNode.id])) {\n this.removeNode(firstNode);\n }\n }\n\n trimLastNode(): void {\n const lastNode = this.lastNode();\n if (lastNode && _lastNode(this, [lastNode.id])) {\n this.removeNode(lastNode);\n }\n }\n\n /**\n * Return a new graph with all nodes re-identified,\n * using their unique, readable names where possible.\n */\n reid(): Graph {\n const nodeLabels: Record<string, string> = Object.fromEntries(\n Object.values(this.nodes).map((node) => [node.id, node.name])\n );\n const nodeLabelCounts = new Map<string, number>();\n Object.values(nodeLabels).forEach((label) => {\n nodeLabelCounts.set(label, (nodeLabelCounts.get(label) || 0) + 1);\n });\n\n const getNodeId = (nodeId: string): string => {\n const label = nodeLabels[nodeId];\n if (isUuid(nodeId) && nodeLabelCounts.get(label) === 1) {\n return label;\n } else {\n return nodeId;\n }\n };\n\n return new Graph({\n nodes: Object.fromEntries(\n Object.entries(this.nodes).map(([id, node]) => [\n getNodeId(id),\n { ...node, id: getNodeId(id) },\n ])\n ),\n edges: this.edges.map((edge) => ({\n ...edge,\n source: getNodeId(edge.source),\n target: getNodeId(edge.target),\n })),\n });\n }\n\n drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }): string {\n const {\n withStyles,\n curveStyle,\n nodeColors = {\n default: \"fill:#f2f0ff,line-height:1.2\",\n first: \"fill-opacity:0\",\n last: \"fill:#bfb6fc\",\n },\n wrapLabelNWords,\n } = params ?? {};\n const graph = this.reid();\n const firstNode = graph.firstNode();\n\n const lastNode = graph.lastNode();\n\n return drawMermaid(graph.nodes, graph.edges, {\n firstNode: firstNode?.id,\n lastNode: lastNode?.id,\n withStyles,\n curveStyle,\n nodeColors,\n wrapLabelNWords,\n });\n }\n\n async drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Blob> {\n const mermaidSyntax = this.drawMermaid(params);\n return drawMermaidImage(mermaidSyntax, {\n backgroundColor: params?.backgroundColor,\n });\n }\n}\n/**\n * Find the single node that is not a target of any edge.\n * Exclude nodes/sources with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the origin.\n */\nfunction _firstNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const targets = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.source))\n .map((edge) => edge.target)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !targets.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n\n/**\n * Find the single node that is not a source of any edge.\n * Exclude nodes/targets with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the destination.\n */\nfunction _lastNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const sources = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.target))\n .map((edge) => edge.source)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !sources.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n"],"mappings":";;;;;;;;;AAaA,SAAS,YACPA,IACAC,MACQ;AACR,KAAI,OAAO,UAAa,CAACC,SAAO,GAAG,CACjC,QAAO;UACE,oBAAoB,KAAK,CAClC,KAAI;EACF,IAAI,UAAU,KAAK,SAAS;EAC5B,UAAU,QAAQ,WAAW,WAAW,GACpC,QAAQ,MAAM,EAAkB,GAChC;AACJ,SAAO;CACR,QAAO;AACN,SAAO,KAAK,SAAS;CACtB;KAED,QAAO,KAAK,QAAQ;AAEvB;AAED,SAAS,aAAaC,MAAY;AAEhC,KAAI,oBAAoB,KAAK,KAAK,CAChC,QAAO;EACL,MAAM;EACN,MAAM;GACJ,IAAI,KAAK,KAAK;GACd,MAAM,KAAK,KAAK,SAAS;EAC1B;CACF;KAED,QAAO;EACL,MAAM;EACN,MAAM;GAAE,GAAG,aAAa,KAAK,KAAK,OAAO;GAAE,OAAO,KAAK,KAAK;EAAM;CACnE;AAEJ;AAED,IAAa,QAAb,MAAa,MAAM;CACjB,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C,MAAM,WAAW,MAAM,UAAU;AAEjC,SAAO,YAAY,MAAM,OAAO,MAAM,OAAO;GAC3C,WAAW,WAAW;GACtB,UAAU,UAAU;GACpB;GACA;GACA;GACA;EACD,EAAC;CACH;CAED,MAAM,eAAeC,QAMH;EAChB,MAAM,gBAAgB,KAAK,YAAY,OAAO;AAC9C,SAAO,iBAAiB,eAAe,EACrC,iBAAiB,QAAQ,gBAC1B,EAAC;CACH;AACF;;;;;;;AAOD,SAAS,WAAWL,OAAcM,UAAoB,CAAE,GAAoB;CAC1E,MAAM,UAAU,IAAI,IAClB,MAAM,MACH,OAAO,CAAC,SAAS,CAAC,QAAQ,SAAS,KAAK,OAAO,CAAC,CAChD,IAAI,CAAC,SAAS,KAAK,OAAO;CAG/B,MAAMC,QAAgB,CAAE;AACxB,MAAK,MAAM,QAAQ,OAAO,OAAO,MAAM,MAAM,CAC3C,KAAI,CAAC,QAAQ,SAAS,KAAK,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,GAAG,EACrD,MAAM,KAAK,KAAK;AAGpB,QAAO,MAAM,WAAW,IAAI,MAAM,KAAK;AACxC;;;;;;;AAQD,SAAS,UAAUP,OAAcM,UAAoB,CAAE,GAAoB;CACzE,MAAM,UAAU,IAAI,IAClB,MAAM,MACH,OAAO,CAAC,SAAS,CAAC,QAAQ,SAAS,KAAK,OAAO,CAAC,CAChD,IAAI,CAAC,SAAS,KAAK,OAAO;CAG/B,MAAMC,QAAgB,CAAE;AACxB,MAAK,MAAM,QAAQ,OAAO,OAAO,MAAM,MAAM,CAC3C,KAAI,CAAC,QAAQ,SAAS,KAAK,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,GAAG,EACrD,MAAM,KAAK,KAAK;AAGpB,QAAO,MAAM,WAAW,IAAI,MAAM,KAAK;AACxC"}
1
+ {"version":3,"file":"graph.js","names":["isUuid","uuidv4"],"sources":["../../src/runnables/graph.ts"],"sourcesContent":["import { v4 as uuidv4, validate as isUuid } from \"../utils/uuid/index.js\";\nimport type {\n RunnableInterface,\n RunnableIOSchema,\n Node,\n Edge,\n} from \"./types.js\";\nimport { isRunnableInterface } from \"./utils.js\";\nimport { drawMermaid, drawMermaidImage } from \"./graph_mermaid.js\";\nimport { toJsonSchema } from \"../utils/json_schema.js\";\n\nexport { Node, Edge };\n\nfunction nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n}\n\nfunction nodeDataJson(node: Node) {\n // if node.data implements Runnable\n if (isRunnableInterface(node.data)) {\n return {\n type: \"runnable\",\n data: {\n id: node.data.lc_id,\n name: node.data.getName(),\n },\n };\n } else {\n return {\n type: \"schema\",\n data: { ...toJsonSchema(node.data.schema), title: node.data.name },\n };\n }\n}\n\nexport class Graph {\n nodes: Record<string, Node> = {};\n\n edges: Edge[] = [];\n\n constructor(params?: { nodes: Record<string, Node>; edges: Edge[] }) {\n this.nodes = params?.nodes ?? this.nodes;\n this.edges = params?.edges ?? this.edges;\n }\n\n // Convert the graph to a JSON-serializable format.\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n toJSON(): Record<string, any> {\n const stableNodeIds: Record<string, string | number> = {};\n Object.values(this.nodes).forEach((node, i) => {\n stableNodeIds[node.id] = isUuid(node.id) ? i : node.id;\n });\n\n return {\n nodes: Object.values(this.nodes).map((node) => ({\n id: stableNodeIds[node.id],\n ...nodeDataJson(node),\n })),\n edges: this.edges.map((edge) => {\n const item: Record<string, unknown> = {\n source: stableNodeIds[edge.source],\n target: stableNodeIds[edge.target],\n };\n\n if (typeof edge.data !== \"undefined\") {\n item.data = edge.data;\n }\n\n if (typeof edge.conditional !== \"undefined\") {\n item.conditional = edge.conditional;\n }\n return item;\n }),\n };\n }\n\n addNode(\n data: RunnableInterface | RunnableIOSchema,\n id?: string,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n metadata?: Record<string, any>\n ): Node {\n if (id !== undefined && this.nodes[id] !== undefined) {\n throw new Error(`Node with id ${id} already exists`);\n }\n const nodeId = id ?? uuidv4();\n const node: Node = {\n id: nodeId,\n data,\n name: nodeDataStr(id, data),\n metadata,\n };\n this.nodes[nodeId] = node;\n return node;\n }\n\n removeNode(node: Node): void {\n // Remove the node from the nodes map\n delete this.nodes[node.id];\n\n // Filter out edges connected to the node\n this.edges = this.edges.filter(\n (edge) => edge.source !== node.id && edge.target !== node.id\n );\n }\n\n addEdge(\n source: Node,\n target: Node,\n data?: string,\n conditional?: boolean\n ): Edge {\n if (this.nodes[source.id] === undefined) {\n throw new Error(`Source node ${source.id} not in graph`);\n }\n if (this.nodes[target.id] === undefined) {\n throw new Error(`Target node ${target.id} not in graph`);\n }\n const edge: Edge = {\n source: source.id,\n target: target.id,\n data,\n conditional,\n };\n this.edges.push(edge);\n return edge;\n }\n\n firstNode(): Node | undefined {\n return _firstNode(this);\n }\n\n lastNode(): Node | undefined {\n return _lastNode(this);\n }\n\n /**\n * Add all nodes and edges from another graph.\n * Note this doesn't check for duplicates, nor does it connect the graphs.\n */\n extend(graph: Graph, prefix = \"\") {\n let finalPrefix = prefix;\n const nodeIds = Object.values(graph.nodes).map((node) => node.id);\n if (nodeIds.every(isUuid)) {\n finalPrefix = \"\";\n }\n\n const prefixed = (id: string) => {\n return finalPrefix ? `${finalPrefix}:${id}` : id;\n };\n\n Object.entries(graph.nodes).forEach(([key, value]) => {\n this.nodes[prefixed(key)] = { ...value, id: prefixed(key) };\n });\n\n const newEdges = graph.edges.map((edge) => {\n return {\n ...edge,\n source: prefixed(edge.source),\n target: prefixed(edge.target),\n };\n });\n // Add all edges from the other graph\n this.edges = [...this.edges, ...newEdges];\n const first = graph.firstNode();\n const last = graph.lastNode();\n return [\n first ? { id: prefixed(first.id), data: first.data } : undefined,\n last ? { id: prefixed(last.id), data: last.data } : undefined,\n ];\n }\n\n trimFirstNode(): void {\n const firstNode = this.firstNode();\n if (firstNode && _firstNode(this, [firstNode.id])) {\n this.removeNode(firstNode);\n }\n }\n\n trimLastNode(): void {\n const lastNode = this.lastNode();\n if (lastNode && _lastNode(this, [lastNode.id])) {\n this.removeNode(lastNode);\n }\n }\n\n /**\n * Return a new graph with all nodes re-identified,\n * using their unique, readable names where possible.\n */\n reid(): Graph {\n const nodeLabels: Record<string, string> = Object.fromEntries(\n Object.values(this.nodes).map((node) => [node.id, node.name])\n );\n const nodeLabelCounts = new Map<string, number>();\n Object.values(nodeLabels).forEach((label) => {\n nodeLabelCounts.set(label, (nodeLabelCounts.get(label) || 0) + 1);\n });\n\n const getNodeId = (nodeId: string): string => {\n const label = nodeLabels[nodeId];\n if (isUuid(nodeId) && nodeLabelCounts.get(label) === 1) {\n return label;\n } else {\n return nodeId;\n }\n };\n\n return new Graph({\n nodes: Object.fromEntries(\n Object.entries(this.nodes).map(([id, node]) => [\n getNodeId(id),\n { ...node, id: getNodeId(id) },\n ])\n ),\n edges: this.edges.map((edge) => ({\n ...edge,\n source: getNodeId(edge.source),\n target: getNodeId(edge.target),\n })),\n });\n }\n\n drawMermaid(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }): string {\n const {\n withStyles,\n curveStyle,\n nodeColors = {\n default: \"fill:#f2f0ff,line-height:1.2\",\n first: \"fill-opacity:0\",\n last: \"fill:#bfb6fc\",\n },\n wrapLabelNWords,\n } = params ?? {};\n const graph = this.reid();\n const firstNode = graph.firstNode();\n\n const lastNode = graph.lastNode();\n\n return drawMermaid(graph.nodes, graph.edges, {\n firstNode: firstNode?.id,\n lastNode: lastNode?.id,\n withStyles,\n curveStyle,\n nodeColors,\n wrapLabelNWords,\n });\n }\n\n async drawMermaidPng(params?: {\n withStyles?: boolean;\n curveStyle?: string;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n backgroundColor?: string;\n }): Promise<Blob> {\n const mermaidSyntax = this.drawMermaid(params);\n return drawMermaidImage(mermaidSyntax, {\n backgroundColor: params?.backgroundColor,\n });\n }\n}\n/**\n * Find the single node that is not a target of any edge.\n * Exclude nodes/sources with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the origin.\n */\nfunction _firstNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const targets = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.source))\n .map((edge) => edge.target)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !targets.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n\n/**\n * Find the single node that is not a source of any edge.\n * Exclude nodes/targets with ids in the exclude list.\n * If there is no such node, or there are multiple, return undefined.\n * When drawing the graph, this node would be the destination.\n */\nfunction _lastNode(graph: Graph, exclude: string[] = []): Node | undefined {\n const sources = new Set(\n graph.edges\n .filter((edge) => !exclude.includes(edge.target))\n .map((edge) => edge.source)\n );\n\n const found: Node[] = [];\n for (const node of Object.values(graph.nodes)) {\n if (!exclude.includes(node.id) && !sources.has(node.id)) {\n found.push(node);\n }\n }\n return found.length === 1 ? found[0] : undefined;\n}\n"],"mappings":";;;;;;;AAaA,SAAS,YACP,IACA,MACQ;AACR,KAAI,OAAO,KAAA,KAAa,CAACA,SAAO,GAAG,CACjC,QAAO;UACE,oBAAoB,KAAK,CAClC,KAAI;EACF,IAAI,UAAU,KAAK,SAAS;AAC5B,YAAU,QAAQ,WAAW,WAAW,GACpC,QAAQ,MAAM,EAAkB,GAChC;AACJ,SAAO;SACD;AACN,SAAO,KAAK,SAAS;;KAGvB,QAAO,KAAK,QAAQ;;AAIxB,SAAS,aAAa,MAAY;AAEhC,KAAI,oBAAoB,KAAK,KAAK,CAChC,QAAO;EACL,MAAM;EACN,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AM,WAAW,MAAM,UAAU;AAEjC,SAAO,YAAY,MAAM,OAAO,MAAM,OAAO;GAC3C,WAAW,WAAW;GACtB,UAAU,UAAU;GACpB;GACA;GACA;GACA;GACD,CAAC;;CAGJ,MAAM,eAAe,QAMH;AAEhB,SAAO,iBADe,KAAK,YAAY,OACF,EAAE,EACrC,iBAAiB,QAAQ,iBAC1B,CAAC;;;;;;;;;AASN,SAAS,WAAW,OAAc,UAAoB,EAAE,EAAoB;CAC1E,MAAM,UAAU,IAAI,IAClB,MAAM,MACH,QAAQ,SAAS,CAAC,QAAQ,SAAS,KAAK,OAAO,CAAC,CAChD,KAAK,SAAS,KAAK,OAAO,CAC9B;CAED,MAAM,QAAgB,EAAE;AACxB,MAAK,MAAM,QAAQ,OAAO,OAAO,MAAM,MAAM,CAC3C,KAAI,CAAC,QAAQ,SAAS,KAAK,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,GAAG,CACrD,OAAM,KAAK,KAAK;AAGpB,QAAO,MAAM,WAAW,IAAI,MAAM,KAAK,KAAA;;;;;;;;AASzC,SAAS,UAAU,OAAc,UAAoB,EAAE,EAAoB;CACzE,MAAM,UAAU,IAAI,IAClB,MAAM,MACH,QAAQ,SAAS,CAAC,QAAQ,SAAS,KAAK,OAAO,CAAC,CAChD,KAAK,SAAS,KAAK,OAAO,CAC9B;CAED,MAAM,QAAgB,EAAE;AACxB,MAAK,MAAM,QAAQ,OAAO,OAAO,MAAM,MAAM,CAC3C,KAAI,CAAC,QAAQ,SAAS,KAAK,GAAG,IAAI,CAAC,QAAQ,IAAI,KAAK,GAAG,CACrD,OAAM,KAAK,KAAK;AAGpB,QAAO,MAAM,WAAW,IAAI,MAAM,KAAK,KAAA"}
@@ -1,5 +1,4 @@
1
- const require_utils = require('./utils.cjs');
2
-
1
+ const require_utils = require("./utils.cjs");
3
2
  //#region src/runnables/graph_mermaid.ts
4
3
  function _escapeNodeLabel(nodeLabel) {
5
4
  return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, "_");
@@ -27,8 +26,7 @@ function drawMermaid(nodes, edges, config) {
27
26
  if (lastNode !== void 0) formatDict[lastNode] = "{0}([{1}]):::last";
28
27
  for (const [key, node] of Object.entries(nodes)) {
29
28
  const nodeName = node.name.split(":").pop() ?? "";
30
- const label = MARKDOWN_SPECIAL_CHARS.some((char) => nodeName.startsWith(char) && nodeName.endsWith(char)) ? `<p>${nodeName}</p>` : nodeName;
31
- let finalLabel = label;
29
+ let finalLabel = MARKDOWN_SPECIAL_CHARS.some((char) => nodeName.startsWith(char) && nodeName.endsWith(char)) ? `<p>${nodeName}</p>` : nodeName;
32
30
  if (Object.keys(node.metadata ?? {}).length) finalLabel += `<hr/><small><em>${Object.entries(node.metadata ?? {}).map(([k, v]) => `${k} = ${v}`).join("\n")}</em></small>`;
33
31
  const nodeLabel = (formatDict[key] ?? formatDict[defaultClassLabel]).replace("{0}", _escapeNodeLabel(key)).replace("{1}", finalLabel);
34
32
  mermaidGraph += `\t${nodeLabel}\n`;
@@ -48,8 +46,8 @@ function drawMermaid(nodes, edges, config) {
48
46
  return a.split(":").length - b.split(":").length;
49
47
  });
50
48
  }
51
- function addSubgraph(edges$1, prefix) {
52
- const selfLoop = edges$1.length === 1 && edges$1[0].source === edges$1[0].target;
49
+ function addSubgraph(edges, prefix) {
50
+ const selfLoop = edges.length === 1 && edges[0].source === edges[0].target;
53
51
  if (prefix && !selfLoop) {
54
52
  const subgraph = prefix.split(":").pop();
55
53
  if (seenSubgraphs.has(prefix)) throw new Error(`Found duplicate subgraph '${subgraph}' at '${prefix} -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);
@@ -58,7 +56,7 @@ function drawMermaid(nodes, edges, config) {
58
56
  }
59
57
  const nestedPrefixes = sortPrefixesByDepth(Object.keys(edgeGroups).filter((nestedPrefix) => nestedPrefix.startsWith(`${prefix}:`) && nestedPrefix !== prefix && nestedPrefix.split(":").length === prefix.split(":").length + 1));
60
58
  for (const nestedPrefix of nestedPrefixes) addSubgraph(edgeGroups[nestedPrefix], nestedPrefix);
61
- for (const edge of edges$1) {
59
+ for (const edge of edges) {
62
60
  const { source, target, data, conditional } = edge;
63
61
  let edgeLabel = "";
64
62
  if (data !== void 0) {
@@ -97,8 +95,7 @@ async function drawMermaidImage(mermaidSyntax, config) {
97
95
  const imageType = config?.imageType ?? "png";
98
96
  const mermaidSyntaxEncoded = require_utils.toBase64Url(mermaidSyntax);
99
97
  if (backgroundColor !== void 0) {
100
- const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
101
- if (!hexColorPattern.test(backgroundColor)) backgroundColor = `!${backgroundColor}`;
98
+ if (!/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(backgroundColor)) backgroundColor = `!${backgroundColor}`;
102
99
  }
103
100
  const imageUrl = `https://mermaid.ink/img/${mermaidSyntaxEncoded}?bgColor=${backgroundColor}&type=${imageType}`;
104
101
  const res = await fetch(imageUrl);
@@ -107,11 +104,10 @@ async function drawMermaidImage(mermaidSyntax, config) {
107
104
  `Status code: ${res.status}`,
108
105
  `Status text: ${res.statusText}`
109
106
  ].join("\n"));
110
- const content = await res.blob();
111
- return content;
107
+ return await res.blob();
112
108
  }
113
-
114
109
  //#endregion
115
110
  exports.drawMermaid = drawMermaid;
116
111
  exports.drawMermaidImage = drawMermaidImage;
112
+
117
113
  //# sourceMappingURL=graph_mermaid.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph_mermaid.cjs","names":["nodeLabel: string","nodeColors: Record<string, string>","nodes: Record<string, Node>","edges: Edge[]","config?: {\n firstNode?: string;\n lastNode?: string;\n curveStyle?: string;\n withStyles?: boolean;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }","formatDict: Record<string, string>","edgeGroups: Record<string, Edge[]>","prefixes: string[]","prefix: string","edges","mermaidSyntax: string","config?: {\n /**\n * The type of image to render.\n * @default \"png\"\n */\n imageType?: \"png\" | \"jpeg\" | \"webp\";\n backgroundColor?: string;\n }","toBase64Url"],"sources":["../../src/runnables/graph_mermaid.ts"],"sourcesContent":["import { Edge, Node } from \"./types.js\";\nimport { toBase64Url } from \"./utils.js\";\n\nfunction _escapeNodeLabel(nodeLabel: string): string {\n // Escapes the node label for Mermaid syntax.\n return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, \"_\");\n}\n\nconst MARKDOWN_SPECIAL_CHARS = [\"*\", \"_\", \"`\"];\n\nfunction _generateMermaidGraphStyles(\n nodeColors: Record<string, string>\n): string {\n let styles = \"\";\n for (const [className, color] of Object.entries(nodeColors)) {\n styles += `\\tclassDef ${className} ${color};\\n`;\n }\n return styles;\n}\n\n/**\n * Draws a Mermaid graph using the provided graph data\n */\nexport function drawMermaid(\n nodes: Record<string, Node>,\n edges: Edge[],\n config?: {\n firstNode?: string;\n lastNode?: string;\n curveStyle?: string;\n withStyles?: boolean;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }\n): string {\n const {\n firstNode,\n lastNode,\n nodeColors,\n withStyles = true,\n curveStyle = \"linear\",\n wrapLabelNWords = 9,\n } = config ?? {};\n // Initialize Mermaid graph configuration\n let mermaidGraph = withStyles\n ? `%%{init: {'flowchart': {'curve': '${curveStyle}'}}}%%\\ngraph TD;\\n`\n : \"graph TD;\\n\";\n if (withStyles) {\n // Node formatting templates\n const defaultClassLabel = \"default\";\n const formatDict: Record<string, string> = {\n [defaultClassLabel]: \"{0}({1})\",\n };\n if (firstNode !== undefined) {\n formatDict[firstNode] = \"{0}([{1}]):::first\";\n }\n if (lastNode !== undefined) {\n formatDict[lastNode] = \"{0}([{1}]):::last\";\n }\n\n // Add nodes to the graph\n for (const [key, node] of Object.entries(nodes)) {\n const nodeName = node.name.split(\":\").pop() ?? \"\";\n const label = MARKDOWN_SPECIAL_CHARS.some(\n (char) => nodeName.startsWith(char) && nodeName.endsWith(char)\n )\n ? `<p>${nodeName}</p>`\n : nodeName;\n\n let finalLabel = label;\n if (Object.keys(node.metadata ?? {}).length) {\n finalLabel += `<hr/><small><em>${Object.entries(node.metadata ?? {})\n .map(([k, v]) => `${k} = ${v}`)\n .join(\"\\n\")}</em></small>`;\n }\n\n const nodeLabel = (formatDict[key] ?? formatDict[defaultClassLabel])\n .replace(\"{0}\", _escapeNodeLabel(key))\n .replace(\"{1}\", finalLabel);\n\n mermaidGraph += `\\t${nodeLabel}\\n`;\n }\n }\n\n // Group edges by their common prefixes\n const edgeGroups: Record<string, Edge[]> = {};\n for (const edge of edges) {\n const srcParts = edge.source.split(\":\");\n const tgtParts = edge.target.split(\":\");\n const commonPrefix = srcParts\n .filter((src, i) => src === tgtParts[i])\n .join(\":\");\n if (!edgeGroups[commonPrefix]) {\n edgeGroups[commonPrefix] = [];\n }\n edgeGroups[commonPrefix].push(edge);\n }\n\n const seenSubgraphs = new Set<string>();\n\n // sort prefixes by path length for correct nesting\n function sortPrefixesByDepth(prefixes: string[]): string[] {\n return [...prefixes].sort((a, b) => {\n return a.split(\":\").length - b.split(\":\").length;\n });\n }\n\n function addSubgraph(edges: Edge[], prefix: string): void {\n const selfLoop = edges.length === 1 && edges[0].source === edges[0].target;\n if (prefix && !selfLoop) {\n const subgraph = prefix.split(\":\").pop()!;\n\n if (seenSubgraphs.has(prefix)) {\n throw new Error(\n `Found duplicate subgraph '${subgraph}' at '${prefix} -- this likely means that ` +\n \"you're reusing a subgraph node with the same name. \" +\n \"Please adjust your graph to have subgraph nodes with unique names.\"\n );\n }\n\n seenSubgraphs.add(prefix);\n mermaidGraph += `\\tsubgraph ${subgraph}\\n`;\n }\n\n // all nested prefixes for this level, sorted by depth\n const nestedPrefixes = sortPrefixesByDepth(\n Object.keys(edgeGroups).filter(\n (nestedPrefix) =>\n nestedPrefix.startsWith(`${prefix}:`) &&\n nestedPrefix !== prefix &&\n nestedPrefix.split(\":\").length === prefix.split(\":\").length + 1\n )\n );\n\n for (const nestedPrefix of nestedPrefixes) {\n addSubgraph(edgeGroups[nestedPrefix], nestedPrefix);\n }\n\n for (const edge of edges) {\n const { source, target, data, conditional } = edge;\n\n let edgeLabel = \"\";\n if (data !== undefined) {\n let edgeData = data;\n const words = edgeData.split(\" \");\n if (words.length > wrapLabelNWords) {\n edgeData = Array.from(\n { length: Math.ceil(words.length / wrapLabelNWords) },\n (_, i) =>\n words\n .slice(i * wrapLabelNWords, (i + 1) * wrapLabelNWords)\n .join(\" \")\n ).join(\"&nbsp;<br>&nbsp;\");\n }\n edgeLabel = conditional\n ? ` -. &nbsp;${edgeData}&nbsp; .-> `\n : ` -- &nbsp;${edgeData}&nbsp; --> `;\n } else {\n edgeLabel = conditional ? \" -.-> \" : \" --> \";\n }\n\n mermaidGraph += `\\t${_escapeNodeLabel(\n source\n )}${edgeLabel}${_escapeNodeLabel(target)};\\n`;\n }\n\n if (prefix && !selfLoop) {\n mermaidGraph += \"\\tend\\n\";\n }\n }\n\n // Start with the top-level edges (no common prefix)\n addSubgraph(edgeGroups[\"\"] ?? [], \"\");\n\n // Add remaining top-level subgraphs\n for (const prefix in edgeGroups) {\n if (!prefix.includes(\":\") && prefix !== \"\") {\n addSubgraph(edgeGroups[prefix], prefix);\n }\n }\n\n // Add custom styles for nodes\n if (withStyles) {\n mermaidGraph += _generateMermaidGraphStyles(nodeColors ?? {});\n }\n\n return mermaidGraph;\n}\n\n/**\n * Renders Mermaid graph using the Mermaid.INK API.\n *\n * @example\n * ```javascript\n * const image = await drawMermaidImage(mermaidSyntax, {\n * backgroundColor: \"white\",\n * imageType: \"png\",\n * });\n * fs.writeFileSync(\"image.png\", image);\n * ```\n *\n * @param mermaidSyntax - The Mermaid syntax to render.\n * @param config - The configuration for the image.\n * @returns The image as a Blob.\n */\nexport async function drawMermaidImage(\n mermaidSyntax: string,\n config?: {\n /**\n * The type of image to render.\n * @default \"png\"\n */\n imageType?: \"png\" | \"jpeg\" | \"webp\";\n backgroundColor?: string;\n }\n) {\n let backgroundColor = config?.backgroundColor ?? \"white\";\n const imageType = config?.imageType ?? \"png\";\n\n const mermaidSyntaxEncoded = toBase64Url(mermaidSyntax);\n\n // Check if the background color is a hexadecimal color code using regex\n if (backgroundColor !== undefined) {\n const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;\n if (!hexColorPattern.test(backgroundColor)) {\n backgroundColor = `!${backgroundColor}`;\n }\n }\n const imageUrl = `https://mermaid.ink/img/${mermaidSyntaxEncoded}?bgColor=${backgroundColor}&type=${imageType}`;\n const res = await fetch(imageUrl);\n if (!res.ok) {\n throw new Error(\n [\n `Failed to render the graph using the Mermaid.INK API.`,\n `Status code: ${res.status}`,\n `Status text: ${res.statusText}`,\n ].join(\"\\n\")\n );\n }\n const content = await res.blob();\n return content;\n}\n"],"mappings":";;;AAGA,SAAS,iBAAiBA,WAA2B;AAEnD,QAAO,UAAU,QAAQ,mBAAmB,IAAI;AACjD;AAED,MAAM,yBAAyB;CAAC;CAAK;CAAK;AAAI;AAE9C,SAAS,4BACPC,YACQ;CACR,IAAI,SAAS;AACb,MAAK,MAAM,CAAC,WAAW,MAAM,IAAI,OAAO,QAAQ,WAAW,EACzD,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC;AAEjD,QAAO;AACR;;;;AAKD,SAAgB,YACdC,OACAC,OACAC,QAQQ;CACR,MAAM,EACJ,WACA,UACA,YACA,aAAa,MACb,aAAa,UACb,kBAAkB,GACnB,GAAG,UAAU,CAAE;CAEhB,IAAI,eAAe,aACf,CAAC,kCAAkC,EAAE,WAAW,mBAAmB,CAAC,GACpE;AACJ,KAAI,YAAY;EAEd,MAAM,oBAAoB;EAC1B,MAAMC,aAAqC,GACxC,oBAAoB,WACtB;AACD,MAAI,cAAc,QAChB,WAAW,aAAa;AAE1B,MAAI,aAAa,QACf,WAAW,YAAY;AAIzB,OAAK,MAAM,CAAC,KAAK,KAAK,IAAI,OAAO,QAAQ,MAAM,EAAE;GAC/C,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI,CAAC,KAAK,IAAI;GAC/C,MAAM,QAAQ,uBA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I,WAAW,IACtC,YAAY,WAAW,SAAS,OAAO;AAK3C,KAAI,YACF,gBAAgB,4BAA4B,cAAc,CAAE,EAAC;AAG/D,QAAO;AACR;;;;;;;;;;;;;;;;;AAkBD,eAAsB,iBACpBC,eACAC,QAQA;CACA,IAAI,kBAAkB,QAAQ,mBAAmB;CACjD,MAAM,YAAY,QAAQ,aAAa;CAEvC,MAAM,uBAAuBC,0BAAY,cAAc;AAGvD,KAAI,oBAAoB,QAAW;EACjC,MAAM,kBAAkB;AACxB,MAAI,CAAC,gBAAgB,KAAK,gBAAgB,EACxC,kBAAkB,CAAC,CAAC,EAAE,iBAAiB;CAE1C;CACD,MAAM,WAAW,CAAC,wBAAwB,EAAE,qBAAqB,SAAS,EAAE,gBAAgB,MAAM,EAAE,WAAW;CAC/G,MAAM,MAAM,MAAM,MAAM,SAAS;AACjC,KAAI,CAAC,IAAI,GACP,OAAM,IAAI,MACR;EACE,CAAC,qDAAqD,CAAC;EACvD,CAAC,aAAa,EAAE,IAAI,QAAQ;EAC5B,CAAC,aAAa,EAAE,IAAI,YAAY;CACjC,EAAC,KAAK,KAAK;CAGhB,MAAM,UAAU,MAAM,IAAI,MAAM;AAChC,QAAO;AACR"}
1
+ {"version":3,"file":"graph_mermaid.cjs","names":["toBase64Url"],"sources":["../../src/runnables/graph_mermaid.ts"],"sourcesContent":["import { Edge, Node } from \"./types.js\";\nimport { toBase64Url } from \"./utils.js\";\n\nfunction _escapeNodeLabel(nodeLabel: string): string {\n // Escapes the node label for Mermaid syntax.\n return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, \"_\");\n}\n\nconst MARKDOWN_SPECIAL_CHARS = [\"*\", \"_\", \"`\"];\n\nfunction _generateMermaidGraphStyles(\n nodeColors: Record<string, string>\n): string {\n let styles = \"\";\n for (const [className, color] of Object.entries(nodeColors)) {\n styles += `\\tclassDef ${className} ${color};\\n`;\n }\n return styles;\n}\n\n/**\n * Draws a Mermaid graph using the provided graph data\n */\nexport function drawMermaid(\n nodes: Record<string, Node>,\n edges: Edge[],\n config?: {\n firstNode?: string;\n lastNode?: string;\n curveStyle?: string;\n withStyles?: boolean;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }\n): string {\n const {\n firstNode,\n lastNode,\n nodeColors,\n withStyles = true,\n curveStyle = \"linear\",\n wrapLabelNWords = 9,\n } = config ?? {};\n // Initialize Mermaid graph configuration\n let mermaidGraph = withStyles\n ? `%%{init: {'flowchart': {'curve': '${curveStyle}'}}}%%\\ngraph TD;\\n`\n : \"graph TD;\\n\";\n if (withStyles) {\n // Node formatting templates\n const defaultClassLabel = \"default\";\n const formatDict: Record<string, string> = {\n [defaultClassLabel]: \"{0}({1})\",\n };\n if (firstNode !== undefined) {\n formatDict[firstNode] = \"{0}([{1}]):::first\";\n }\n if (lastNode !== undefined) {\n formatDict[lastNode] = \"{0}([{1}]):::last\";\n }\n\n // Add nodes to the graph\n for (const [key, node] of Object.entries(nodes)) {\n const nodeName = node.name.split(\":\").pop() ?? \"\";\n const label = MARKDOWN_SPECIAL_CHARS.some(\n (char) => nodeName.startsWith(char) && nodeName.endsWith(char)\n )\n ? `<p>${nodeName}</p>`\n : nodeName;\n\n let finalLabel = label;\n if (Object.keys(node.metadata ?? {}).length) {\n finalLabel += `<hr/><small><em>${Object.entries(node.metadata ?? {})\n .map(([k, v]) => `${k} = ${v}`)\n .join(\"\\n\")}</em></small>`;\n }\n\n const nodeLabel = (formatDict[key] ?? formatDict[defaultClassLabel])\n .replace(\"{0}\", _escapeNodeLabel(key))\n .replace(\"{1}\", finalLabel);\n\n mermaidGraph += `\\t${nodeLabel}\\n`;\n }\n }\n\n // Group edges by their common prefixes\n const edgeGroups: Record<string, Edge[]> = {};\n for (const edge of edges) {\n const srcParts = edge.source.split(\":\");\n const tgtParts = edge.target.split(\":\");\n const commonPrefix = srcParts\n .filter((src, i) => src === tgtParts[i])\n .join(\":\");\n if (!edgeGroups[commonPrefix]) {\n edgeGroups[commonPrefix] = [];\n }\n edgeGroups[commonPrefix].push(edge);\n }\n\n const seenSubgraphs = new Set<string>();\n\n // sort prefixes by path length for correct nesting\n function sortPrefixesByDepth(prefixes: string[]): string[] {\n return [...prefixes].sort((a, b) => {\n return a.split(\":\").length - b.split(\":\").length;\n });\n }\n\n function addSubgraph(edges: Edge[], prefix: string): void {\n const selfLoop = edges.length === 1 && edges[0].source === edges[0].target;\n if (prefix && !selfLoop) {\n const subgraph = prefix.split(\":\").pop()!;\n\n if (seenSubgraphs.has(prefix)) {\n throw new Error(\n `Found duplicate subgraph '${subgraph}' at '${prefix} -- this likely means that ` +\n \"you're reusing a subgraph node with the same name. \" +\n \"Please adjust your graph to have subgraph nodes with unique names.\"\n );\n }\n\n seenSubgraphs.add(prefix);\n mermaidGraph += `\\tsubgraph ${subgraph}\\n`;\n }\n\n // all nested prefixes for this level, sorted by depth\n const nestedPrefixes = sortPrefixesByDepth(\n Object.keys(edgeGroups).filter(\n (nestedPrefix) =>\n nestedPrefix.startsWith(`${prefix}:`) &&\n nestedPrefix !== prefix &&\n nestedPrefix.split(\":\").length === prefix.split(\":\").length + 1\n )\n );\n\n for (const nestedPrefix of nestedPrefixes) {\n addSubgraph(edgeGroups[nestedPrefix], nestedPrefix);\n }\n\n for (const edge of edges) {\n const { source, target, data, conditional } = edge;\n\n let edgeLabel = \"\";\n if (data !== undefined) {\n let edgeData = data;\n const words = edgeData.split(\" \");\n if (words.length > wrapLabelNWords) {\n edgeData = Array.from(\n { length: Math.ceil(words.length / wrapLabelNWords) },\n (_, i) =>\n words\n .slice(i * wrapLabelNWords, (i + 1) * wrapLabelNWords)\n .join(\" \")\n ).join(\"&nbsp;<br>&nbsp;\");\n }\n edgeLabel = conditional\n ? ` -. &nbsp;${edgeData}&nbsp; .-> `\n : ` -- &nbsp;${edgeData}&nbsp; --> `;\n } else {\n edgeLabel = conditional ? \" -.-> \" : \" --> \";\n }\n\n mermaidGraph += `\\t${_escapeNodeLabel(\n source\n )}${edgeLabel}${_escapeNodeLabel(target)};\\n`;\n }\n\n if (prefix && !selfLoop) {\n mermaidGraph += \"\\tend\\n\";\n }\n }\n\n // Start with the top-level edges (no common prefix)\n addSubgraph(edgeGroups[\"\"] ?? [], \"\");\n\n // Add remaining top-level subgraphs\n for (const prefix in edgeGroups) {\n if (!prefix.includes(\":\") && prefix !== \"\") {\n addSubgraph(edgeGroups[prefix], prefix);\n }\n }\n\n // Add custom styles for nodes\n if (withStyles) {\n mermaidGraph += _generateMermaidGraphStyles(nodeColors ?? {});\n }\n\n return mermaidGraph;\n}\n\n/**\n * Renders Mermaid graph using the Mermaid.INK API.\n *\n * @example\n * ```javascript\n * const image = await drawMermaidImage(mermaidSyntax, {\n * backgroundColor: \"white\",\n * imageType: \"png\",\n * });\n * fs.writeFileSync(\"image.png\", image);\n * ```\n *\n * @param mermaidSyntax - The Mermaid syntax to render.\n * @param config - The configuration for the image.\n * @returns The image as a Blob.\n */\nexport async function drawMermaidImage(\n mermaidSyntax: string,\n config?: {\n /**\n * The type of image to render.\n * @default \"png\"\n */\n imageType?: \"png\" | \"jpeg\" | \"webp\";\n backgroundColor?: string;\n }\n) {\n let backgroundColor = config?.backgroundColor ?? \"white\";\n const imageType = config?.imageType ?? \"png\";\n\n const mermaidSyntaxEncoded = toBase64Url(mermaidSyntax);\n\n // Check if the background color is a hexadecimal color code using regex\n if (backgroundColor !== undefined) {\n const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;\n if (!hexColorPattern.test(backgroundColor)) {\n backgroundColor = `!${backgroundColor}`;\n }\n }\n const imageUrl = `https://mermaid.ink/img/${mermaidSyntaxEncoded}?bgColor=${backgroundColor}&type=${imageType}`;\n const res = await fetch(imageUrl);\n if (!res.ok) {\n throw new Error(\n [\n `Failed to render the graph using the Mermaid.INK API.`,\n `Status code: ${res.status}`,\n `Status text: ${res.statusText}`,\n ].join(\"\\n\")\n );\n }\n const content = await res.blob();\n return content;\n}\n"],"mappings":";;AAGA,SAAS,iBAAiB,WAA2B;AAEnD,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AAG,MACF,MACG,MAAM,IAAI,kBAAkB,IAAI,KAAK,gBAAgB,CACrD,KAAK,IAAI,CACf,CAAC,KAAK,mBAAmB;AAE5B,gBAAY,cACR,aAAa,SAAS,eACtB,aAAa,SAAS;SAE1B,aAAY,cAAc,WAAW;AAGvC,mBAAgB,KAAK,iBACnB,OACD,GAAG,YAAY,iBAAiB,OAAO,CAAC;;AAG3C,MAAI,UAAU,CAAC,SACb,iBAAgB;;AAKpB,aAAY,WAAW,OAAO,EAAE,EAAE,GAAG;AAGrC,MAAK,MAAM,UAAU,WACnB,KAAI,CAAC,OAAO,SAAS,IAAI,IAAI,WAAW,GACtC,aAAY,WAAW,SAAS,OAAO;AAK3C,KAAI,WACF,iBAAgB,4BAA4B,cAAc,EAAE,CAAC;AAG/D,QAAO;;;;;;;;;;;;;;;;;;AAmBT,eAAsB,iBACpB,eACA,QAQA;CACA,IAAI,kBAAkB,QAAQ,mBAAmB;CACjD,MAAM,YAAY,QAAQ,aAAa;CAEvC,MAAM,uBAAuBA,cAAAA,YAAY,cAAc;AAGvD,KAAI,oBAAoB,KAAA;MAElB,CAAC,6BAAgB,KAAK,gBAAgB,CACxC,mBAAkB,IAAI;;CAG1B,MAAM,WAAW,2BAA2B,qBAAqB,WAAW,gBAAgB,QAAQ;CACpG,MAAM,MAAM,MAAM,MAAM,SAAS;AACjC,KAAI,CAAC,IAAI,GACP,OAAM,IAAI,MACR;EACE;EACA,gBAAgB,IAAI;EACpB,gBAAgB,IAAI;EACrB,CAAC,KAAK,KAAK,CACb;AAGH,QAAO,MADe,IAAI,MAAM"}
@@ -1,5 +1,4 @@
1
1
  import { toBase64Url } from "./utils.js";
2
-
3
2
  //#region src/runnables/graph_mermaid.ts
4
3
  function _escapeNodeLabel(nodeLabel) {
5
4
  return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, "_");
@@ -27,8 +26,7 @@ function drawMermaid(nodes, edges, config) {
27
26
  if (lastNode !== void 0) formatDict[lastNode] = "{0}([{1}]):::last";
28
27
  for (const [key, node] of Object.entries(nodes)) {
29
28
  const nodeName = node.name.split(":").pop() ?? "";
30
- const label = MARKDOWN_SPECIAL_CHARS.some((char) => nodeName.startsWith(char) && nodeName.endsWith(char)) ? `<p>${nodeName}</p>` : nodeName;
31
- let finalLabel = label;
29
+ let finalLabel = MARKDOWN_SPECIAL_CHARS.some((char) => nodeName.startsWith(char) && nodeName.endsWith(char)) ? `<p>${nodeName}</p>` : nodeName;
32
30
  if (Object.keys(node.metadata ?? {}).length) finalLabel += `<hr/><small><em>${Object.entries(node.metadata ?? {}).map(([k, v]) => `${k} = ${v}`).join("\n")}</em></small>`;
33
31
  const nodeLabel = (formatDict[key] ?? formatDict[defaultClassLabel]).replace("{0}", _escapeNodeLabel(key)).replace("{1}", finalLabel);
34
32
  mermaidGraph += `\t${nodeLabel}\n`;
@@ -48,8 +46,8 @@ function drawMermaid(nodes, edges, config) {
48
46
  return a.split(":").length - b.split(":").length;
49
47
  });
50
48
  }
51
- function addSubgraph(edges$1, prefix) {
52
- const selfLoop = edges$1.length === 1 && edges$1[0].source === edges$1[0].target;
49
+ function addSubgraph(edges, prefix) {
50
+ const selfLoop = edges.length === 1 && edges[0].source === edges[0].target;
53
51
  if (prefix && !selfLoop) {
54
52
  const subgraph = prefix.split(":").pop();
55
53
  if (seenSubgraphs.has(prefix)) throw new Error(`Found duplicate subgraph '${subgraph}' at '${prefix} -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);
@@ -58,7 +56,7 @@ function drawMermaid(nodes, edges, config) {
58
56
  }
59
57
  const nestedPrefixes = sortPrefixesByDepth(Object.keys(edgeGroups).filter((nestedPrefix) => nestedPrefix.startsWith(`${prefix}:`) && nestedPrefix !== prefix && nestedPrefix.split(":").length === prefix.split(":").length + 1));
60
58
  for (const nestedPrefix of nestedPrefixes) addSubgraph(edgeGroups[nestedPrefix], nestedPrefix);
61
- for (const edge of edges$1) {
59
+ for (const edge of edges) {
62
60
  const { source, target, data, conditional } = edge;
63
61
  let edgeLabel = "";
64
62
  if (data !== void 0) {
@@ -97,8 +95,7 @@ async function drawMermaidImage(mermaidSyntax, config) {
97
95
  const imageType = config?.imageType ?? "png";
98
96
  const mermaidSyntaxEncoded = toBase64Url(mermaidSyntax);
99
97
  if (backgroundColor !== void 0) {
100
- const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;
101
- if (!hexColorPattern.test(backgroundColor)) backgroundColor = `!${backgroundColor}`;
98
+ if (!/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(backgroundColor)) backgroundColor = `!${backgroundColor}`;
102
99
  }
103
100
  const imageUrl = `https://mermaid.ink/img/${mermaidSyntaxEncoded}?bgColor=${backgroundColor}&type=${imageType}`;
104
101
  const res = await fetch(imageUrl);
@@ -107,10 +104,9 @@ async function drawMermaidImage(mermaidSyntax, config) {
107
104
  `Status code: ${res.status}`,
108
105
  `Status text: ${res.statusText}`
109
106
  ].join("\n"));
110
- const content = await res.blob();
111
- return content;
107
+ return await res.blob();
112
108
  }
113
-
114
109
  //#endregion
115
110
  export { drawMermaid, drawMermaidImage };
111
+
116
112
  //# sourceMappingURL=graph_mermaid.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"graph_mermaid.js","names":["nodeLabel: string","nodeColors: Record<string, string>","nodes: Record<string, Node>","edges: Edge[]","config?: {\n firstNode?: string;\n lastNode?: string;\n curveStyle?: string;\n withStyles?: boolean;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }","formatDict: Record<string, string>","edgeGroups: Record<string, Edge[]>","prefixes: string[]","prefix: string","edges","mermaidSyntax: string","config?: {\n /**\n * The type of image to render.\n * @default \"png\"\n */\n imageType?: \"png\" | \"jpeg\" | \"webp\";\n backgroundColor?: string;\n }"],"sources":["../../src/runnables/graph_mermaid.ts"],"sourcesContent":["import { Edge, Node } from \"./types.js\";\nimport { toBase64Url } from \"./utils.js\";\n\nfunction _escapeNodeLabel(nodeLabel: string): string {\n // Escapes the node label for Mermaid syntax.\n return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, \"_\");\n}\n\nconst MARKDOWN_SPECIAL_CHARS = [\"*\", \"_\", \"`\"];\n\nfunction _generateMermaidGraphStyles(\n nodeColors: Record<string, string>\n): string {\n let styles = \"\";\n for (const [className, color] of Object.entries(nodeColors)) {\n styles += `\\tclassDef ${className} ${color};\\n`;\n }\n return styles;\n}\n\n/**\n * Draws a Mermaid graph using the provided graph data\n */\nexport function drawMermaid(\n nodes: Record<string, Node>,\n edges: Edge[],\n config?: {\n firstNode?: string;\n lastNode?: string;\n curveStyle?: string;\n withStyles?: boolean;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }\n): string {\n const {\n firstNode,\n lastNode,\n nodeColors,\n withStyles = true,\n curveStyle = \"linear\",\n wrapLabelNWords = 9,\n } = config ?? {};\n // Initialize Mermaid graph configuration\n let mermaidGraph = withStyles\n ? `%%{init: {'flowchart': {'curve': '${curveStyle}'}}}%%\\ngraph TD;\\n`\n : \"graph TD;\\n\";\n if (withStyles) {\n // Node formatting templates\n const defaultClassLabel = \"default\";\n const formatDict: Record<string, string> = {\n [defaultClassLabel]: \"{0}({1})\",\n };\n if (firstNode !== undefined) {\n formatDict[firstNode] = \"{0}([{1}]):::first\";\n }\n if (lastNode !== undefined) {\n formatDict[lastNode] = \"{0}([{1}]):::last\";\n }\n\n // Add nodes to the graph\n for (const [key, node] of Object.entries(nodes)) {\n const nodeName = node.name.split(\":\").pop() ?? \"\";\n const label = MARKDOWN_SPECIAL_CHARS.some(\n (char) => nodeName.startsWith(char) && nodeName.endsWith(char)\n )\n ? `<p>${nodeName}</p>`\n : nodeName;\n\n let finalLabel = label;\n if (Object.keys(node.metadata ?? {}).length) {\n finalLabel += `<hr/><small><em>${Object.entries(node.metadata ?? {})\n .map(([k, v]) => `${k} = ${v}`)\n .join(\"\\n\")}</em></small>`;\n }\n\n const nodeLabel = (formatDict[key] ?? formatDict[defaultClassLabel])\n .replace(\"{0}\", _escapeNodeLabel(key))\n .replace(\"{1}\", finalLabel);\n\n mermaidGraph += `\\t${nodeLabel}\\n`;\n }\n }\n\n // Group edges by their common prefixes\n const edgeGroups: Record<string, Edge[]> = {};\n for (const edge of edges) {\n const srcParts = edge.source.split(\":\");\n const tgtParts = edge.target.split(\":\");\n const commonPrefix = srcParts\n .filter((src, i) => src === tgtParts[i])\n .join(\":\");\n if (!edgeGroups[commonPrefix]) {\n edgeGroups[commonPrefix] = [];\n }\n edgeGroups[commonPrefix].push(edge);\n }\n\n const seenSubgraphs = new Set<string>();\n\n // sort prefixes by path length for correct nesting\n function sortPrefixesByDepth(prefixes: string[]): string[] {\n return [...prefixes].sort((a, b) => {\n return a.split(\":\").length - b.split(\":\").length;\n });\n }\n\n function addSubgraph(edges: Edge[], prefix: string): void {\n const selfLoop = edges.length === 1 && edges[0].source === edges[0].target;\n if (prefix && !selfLoop) {\n const subgraph = prefix.split(\":\").pop()!;\n\n if (seenSubgraphs.has(prefix)) {\n throw new Error(\n `Found duplicate subgraph '${subgraph}' at '${prefix} -- this likely means that ` +\n \"you're reusing a subgraph node with the same name. \" +\n \"Please adjust your graph to have subgraph nodes with unique names.\"\n );\n }\n\n seenSubgraphs.add(prefix);\n mermaidGraph += `\\tsubgraph ${subgraph}\\n`;\n }\n\n // all nested prefixes for this level, sorted by depth\n const nestedPrefixes = sortPrefixesByDepth(\n Object.keys(edgeGroups).filter(\n (nestedPrefix) =>\n nestedPrefix.startsWith(`${prefix}:`) &&\n nestedPrefix !== prefix &&\n nestedPrefix.split(\":\").length === prefix.split(\":\").length + 1\n )\n );\n\n for (const nestedPrefix of nestedPrefixes) {\n addSubgraph(edgeGroups[nestedPrefix], nestedPrefix);\n }\n\n for (const edge of edges) {\n const { source, target, data, conditional } = edge;\n\n let edgeLabel = \"\";\n if (data !== undefined) {\n let edgeData = data;\n const words = edgeData.split(\" \");\n if (words.length > wrapLabelNWords) {\n edgeData = Array.from(\n { length: Math.ceil(words.length / wrapLabelNWords) },\n (_, i) =>\n words\n .slice(i * wrapLabelNWords, (i + 1) * wrapLabelNWords)\n .join(\" \")\n ).join(\"&nbsp;<br>&nbsp;\");\n }\n edgeLabel = conditional\n ? ` -. &nbsp;${edgeData}&nbsp; .-> `\n : ` -- &nbsp;${edgeData}&nbsp; --> `;\n } else {\n edgeLabel = conditional ? \" -.-> \" : \" --> \";\n }\n\n mermaidGraph += `\\t${_escapeNodeLabel(\n source\n )}${edgeLabel}${_escapeNodeLabel(target)};\\n`;\n }\n\n if (prefix && !selfLoop) {\n mermaidGraph += \"\\tend\\n\";\n }\n }\n\n // Start with the top-level edges (no common prefix)\n addSubgraph(edgeGroups[\"\"] ?? [], \"\");\n\n // Add remaining top-level subgraphs\n for (const prefix in edgeGroups) {\n if (!prefix.includes(\":\") && prefix !== \"\") {\n addSubgraph(edgeGroups[prefix], prefix);\n }\n }\n\n // Add custom styles for nodes\n if (withStyles) {\n mermaidGraph += _generateMermaidGraphStyles(nodeColors ?? {});\n }\n\n return mermaidGraph;\n}\n\n/**\n * Renders Mermaid graph using the Mermaid.INK API.\n *\n * @example\n * ```javascript\n * const image = await drawMermaidImage(mermaidSyntax, {\n * backgroundColor: \"white\",\n * imageType: \"png\",\n * });\n * fs.writeFileSync(\"image.png\", image);\n * ```\n *\n * @param mermaidSyntax - The Mermaid syntax to render.\n * @param config - The configuration for the image.\n * @returns The image as a Blob.\n */\nexport async function drawMermaidImage(\n mermaidSyntax: string,\n config?: {\n /**\n * The type of image to render.\n * @default \"png\"\n */\n imageType?: \"png\" | \"jpeg\" | \"webp\";\n backgroundColor?: string;\n }\n) {\n let backgroundColor = config?.backgroundColor ?? \"white\";\n const imageType = config?.imageType ?? \"png\";\n\n const mermaidSyntaxEncoded = toBase64Url(mermaidSyntax);\n\n // Check if the background color is a hexadecimal color code using regex\n if (backgroundColor !== undefined) {\n const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;\n if (!hexColorPattern.test(backgroundColor)) {\n backgroundColor = `!${backgroundColor}`;\n }\n }\n const imageUrl = `https://mermaid.ink/img/${mermaidSyntaxEncoded}?bgColor=${backgroundColor}&type=${imageType}`;\n const res = await fetch(imageUrl);\n if (!res.ok) {\n throw new Error(\n [\n `Failed to render the graph using the Mermaid.INK API.`,\n `Status code: ${res.status}`,\n `Status text: ${res.statusText}`,\n ].join(\"\\n\")\n );\n }\n const content = await res.blob();\n return content;\n}\n"],"mappings":";;;AAGA,SAAS,iBAAiBA,WAA2B;AAEnD,QAAO,UAAU,QAAQ,mBAAmB,IAAI;AACjD;AAED,MAAM,yBAAyB;CAAC;CAAK;CAAK;AAAI;AAE9C,SAAS,4BACPC,YACQ;CACR,IAAI,SAAS;AACb,MAAK,MAAM,CAAC,WAAW,MAAM,IAAI,OAAO,QAAQ,WAAW,EACzD,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC;AAEjD,QAAO;AACR;;;;AAKD,SAAgB,YACdC,OACAC,OACAC,QAQQ;CACR,MAAM,EACJ,WACA,UACA,YACA,aAAa,MACb,aAAa,UACb,kBAAkB,GACnB,GAAG,UAAU,CAAE;CAEhB,IAAI,eAAe,aACf,CAAC,kCAAkC,EAAE,WAAW,mBAAmB,CAAC,GACpE;AACJ,KAAI,YAAY;EAEd,MAAM,oBAAoB;EAC1B,MAAMC,aAAqC,GACxC,oBAAoB,WACtB;AACD,MAAI,cAAc,QAChB,WAAW,aAAa;AAE1B,MAAI,aAAa,QACf,WAAW,YAAY;AAIzB,OAAK,MAAM,CAAC,KAAK,KAAK,IAAI,OAAO,QAAQ,MAAM,EAAE;GAC/C,MAAM,WAAW,KAAK,KAAK,MAAM,IAAI,CAAC,KAAK,IAAI;GAC/C,MAAM,QAAQ,uBAAuB,KACnC,CAAC,SAAS,SAAS,WAAW,KAAK,IAAI,SAAS,SAAS,KAAK,CAC/D,GACG,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,GACpB;GAEJ,IAAI,aAAa;AACjB,OAAI,O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eACAC,QAQA;CACA,IAAI,kBAAkB,QAAQ,mBAAmB;CACjD,MAAM,YAAY,QAAQ,aAAa;CAEvC,MAAM,uBAAuB,YAAY,cAAc;AAGvD,KAAI,oBAAoB,QAAW;EACjC,MAAM,kBAAkB;AACxB,MAAI,CAAC,gBAAgB,KAAK,gBAAgB,EACxC,kBAAkB,CAAC,CAAC,EAAE,iBAAiB;CAE1C;CACD,MAAM,WAAW,CAAC,wBAAwB,EAAE,qBAAqB,SAAS,EAAE,gBAAgB,MAAM,EAAE,WAAW;CAC/G,MAAM,MAAM,MAAM,MAAM,SAAS;AACjC,KAAI,CAAC,IAAI,GACP,OAAM,IAAI,MACR;EACE,CAAC,qDAAqD,CAAC;EACvD,CAAC,aAAa,EAAE,IAAI,QAAQ;EAC5B,CAAC,aAAa,EAAE,IAAI,YAAY;CACjC,EAAC,KAAK,KAAK;CAGhB,MAAM,UAAU,MAAM,IAAI,MAAM;AAChC,QAAO;AACR"}
1
+ {"version":3,"file":"graph_mermaid.js","names":[],"sources":["../../src/runnables/graph_mermaid.ts"],"sourcesContent":["import { Edge, Node } from \"./types.js\";\nimport { toBase64Url } from \"./utils.js\";\n\nfunction _escapeNodeLabel(nodeLabel: string): string {\n // Escapes the node label for Mermaid syntax.\n return nodeLabel.replace(/[^a-zA-Z-_0-9]/g, \"_\");\n}\n\nconst MARKDOWN_SPECIAL_CHARS = [\"*\", \"_\", \"`\"];\n\nfunction _generateMermaidGraphStyles(\n nodeColors: Record<string, string>\n): string {\n let styles = \"\";\n for (const [className, color] of Object.entries(nodeColors)) {\n styles += `\\tclassDef ${className} ${color};\\n`;\n }\n return styles;\n}\n\n/**\n * Draws a Mermaid graph using the provided graph data\n */\nexport function drawMermaid(\n nodes: Record<string, Node>,\n edges: Edge[],\n config?: {\n firstNode?: string;\n lastNode?: string;\n curveStyle?: string;\n withStyles?: boolean;\n nodeColors?: Record<string, string>;\n wrapLabelNWords?: number;\n }\n): string {\n const {\n firstNode,\n lastNode,\n nodeColors,\n withStyles = true,\n curveStyle = \"linear\",\n wrapLabelNWords = 9,\n } = config ?? {};\n // Initialize Mermaid graph configuration\n let mermaidGraph = withStyles\n ? `%%{init: {'flowchart': {'curve': '${curveStyle}'}}}%%\\ngraph TD;\\n`\n : \"graph TD;\\n\";\n if (withStyles) {\n // Node formatting templates\n const defaultClassLabel = \"default\";\n const formatDict: Record<string, string> = {\n [defaultClassLabel]: \"{0}({1})\",\n };\n if (firstNode !== undefined) {\n formatDict[firstNode] = \"{0}([{1}]):::first\";\n }\n if (lastNode !== undefined) {\n formatDict[lastNode] = \"{0}([{1}]):::last\";\n }\n\n // Add nodes to the graph\n for (const [key, node] of Object.entries(nodes)) {\n const nodeName = node.name.split(\":\").pop() ?? \"\";\n const label = MARKDOWN_SPECIAL_CHARS.some(\n (char) => nodeName.startsWith(char) && nodeName.endsWith(char)\n )\n ? `<p>${nodeName}</p>`\n : nodeName;\n\n let finalLabel = label;\n if (Object.keys(node.metadata ?? {}).length) {\n finalLabel += `<hr/><small><em>${Object.entries(node.metadata ?? {})\n .map(([k, v]) => `${k} = ${v}`)\n .join(\"\\n\")}</em></small>`;\n }\n\n const nodeLabel = (formatDict[key] ?? formatDict[defaultClassLabel])\n .replace(\"{0}\", _escapeNodeLabel(key))\n .replace(\"{1}\", finalLabel);\n\n mermaidGraph += `\\t${nodeLabel}\\n`;\n }\n }\n\n // Group edges by their common prefixes\n const edgeGroups: Record<string, Edge[]> = {};\n for (const edge of edges) {\n const srcParts = edge.source.split(\":\");\n const tgtParts = edge.target.split(\":\");\n const commonPrefix = srcParts\n .filter((src, i) => src === tgtParts[i])\n .join(\":\");\n if (!edgeGroups[commonPrefix]) {\n edgeGroups[commonPrefix] = [];\n }\n edgeGroups[commonPrefix].push(edge);\n }\n\n const seenSubgraphs = new Set<string>();\n\n // sort prefixes by path length for correct nesting\n function sortPrefixesByDepth(prefixes: string[]): string[] {\n return [...prefixes].sort((a, b) => {\n return a.split(\":\").length - b.split(\":\").length;\n });\n }\n\n function addSubgraph(edges: Edge[], prefix: string): void {\n const selfLoop = edges.length === 1 && edges[0].source === edges[0].target;\n if (prefix && !selfLoop) {\n const subgraph = prefix.split(\":\").pop()!;\n\n if (seenSubgraphs.has(prefix)) {\n throw new Error(\n `Found duplicate subgraph '${subgraph}' at '${prefix} -- this likely means that ` +\n \"you're reusing a subgraph node with the same name. \" +\n \"Please adjust your graph to have subgraph nodes with unique names.\"\n );\n }\n\n seenSubgraphs.add(prefix);\n mermaidGraph += `\\tsubgraph ${subgraph}\\n`;\n }\n\n // all nested prefixes for this level, sorted by depth\n const nestedPrefixes = sortPrefixesByDepth(\n Object.keys(edgeGroups).filter(\n (nestedPrefix) =>\n nestedPrefix.startsWith(`${prefix}:`) &&\n nestedPrefix !== prefix &&\n nestedPrefix.split(\":\").length === prefix.split(\":\").length + 1\n )\n );\n\n for (const nestedPrefix of nestedPrefixes) {\n addSubgraph(edgeGroups[nestedPrefix], nestedPrefix);\n }\n\n for (const edge of edges) {\n const { source, target, data, conditional } = edge;\n\n let edgeLabel = \"\";\n if (data !== undefined) {\n let edgeData = data;\n const words = edgeData.split(\" \");\n if (words.length > wrapLabelNWords) {\n edgeData = Array.from(\n { length: Math.ceil(words.length / wrapLabelNWords) },\n (_, i) =>\n words\n .slice(i * wrapLabelNWords, (i + 1) * wrapLabelNWords)\n .join(\" \")\n ).join(\"&nbsp;<br>&nbsp;\");\n }\n edgeLabel = conditional\n ? ` -. &nbsp;${edgeData}&nbsp; .-> `\n : ` -- &nbsp;${edgeData}&nbsp; --> `;\n } else {\n edgeLabel = conditional ? \" -.-> \" : \" --> \";\n }\n\n mermaidGraph += `\\t${_escapeNodeLabel(\n source\n )}${edgeLabel}${_escapeNodeLabel(target)};\\n`;\n }\n\n if (prefix && !selfLoop) {\n mermaidGraph += \"\\tend\\n\";\n }\n }\n\n // Start with the top-level edges (no common prefix)\n addSubgraph(edgeGroups[\"\"] ?? [], \"\");\n\n // Add remaining top-level subgraphs\n for (const prefix in edgeGroups) {\n if (!prefix.includes(\":\") && prefix !== \"\") {\n addSubgraph(edgeGroups[prefix], prefix);\n }\n }\n\n // Add custom styles for nodes\n if (withStyles) {\n mermaidGraph += _generateMermaidGraphStyles(nodeColors ?? {});\n }\n\n return mermaidGraph;\n}\n\n/**\n * Renders Mermaid graph using the Mermaid.INK API.\n *\n * @example\n * ```javascript\n * const image = await drawMermaidImage(mermaidSyntax, {\n * backgroundColor: \"white\",\n * imageType: \"png\",\n * });\n * fs.writeFileSync(\"image.png\", image);\n * ```\n *\n * @param mermaidSyntax - The Mermaid syntax to render.\n * @param config - The configuration for the image.\n * @returns The image as a Blob.\n */\nexport async function drawMermaidImage(\n mermaidSyntax: string,\n config?: {\n /**\n * The type of image to render.\n * @default \"png\"\n */\n imageType?: \"png\" | \"jpeg\" | \"webp\";\n backgroundColor?: string;\n }\n) {\n let backgroundColor = config?.backgroundColor ?? \"white\";\n const imageType = config?.imageType ?? \"png\";\n\n const mermaidSyntaxEncoded = toBase64Url(mermaidSyntax);\n\n // Check if the background color is a hexadecimal color code using regex\n if (backgroundColor !== undefined) {\n const hexColorPattern = /^#(?:[0-9a-fA-F]{3}){1,2}$/;\n if (!hexColorPattern.test(backgroundColor)) {\n backgroundColor = `!${backgroundColor}`;\n }\n }\n const imageUrl = `https://mermaid.ink/img/${mermaidSyntaxEncoded}?bgColor=${backgroundColor}&type=${imageType}`;\n const res = await fetch(imageUrl);\n if (!res.ok) {\n throw new Error(\n [\n `Failed to render the graph using the Mermaid.INK API.`,\n `Status code: ${res.status}`,\n `Status text: ${res.statusText}`,\n ].join(\"\\n\")\n );\n }\n const content = await res.blob();\n return content;\n}\n"],"mappings":";;AAGA,SAAS,iBAAiB,WAA2B;AAEnD,QAAO,UAAU,QAAQ,mBAAmB,IAAI;;AAGlD,MAAM,yBAAyB;CAAC;CAAK;CAAK;CAAI;AAE9C,SAAS,4BACP,YACQ;CACR,IAAI,SAAS;AACb,MAAK,MAAM,CAAC,WAAW,UAAU,OAAO,Q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