@langchain/core 1.1.39 → 1.1.40-dev-1777128506086

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (325) hide show
  1. package/dist/callbacks/base.cjs +1 -1
  2. package/dist/callbacks/base.d.cts.map +1 -1
  3. package/dist/language_models/base.cjs +1 -1
  4. package/dist/language_models/base.cjs.map +1 -1
  5. package/dist/language_models/base.js +1 -1
  6. package/dist/language_models/base.js.map +1 -1
  7. package/dist/language_models/chat_models.cjs +60 -0
  8. package/dist/language_models/chat_models.cjs.map +1 -1
  9. package/dist/language_models/chat_models.d.cts +55 -0
  10. package/dist/language_models/chat_models.d.cts.map +1 -1
  11. package/dist/language_models/chat_models.d.ts +55 -0
  12. package/dist/language_models/chat_models.d.ts.map +1 -1
  13. package/dist/language_models/chat_models.js +60 -0
  14. package/dist/language_models/chat_models.js.map +1 -1
  15. package/dist/language_models/compat.cjs +232 -0
  16. package/dist/language_models/compat.cjs.map +1 -0
  17. package/dist/language_models/compat.d.cts +20 -0
  18. package/dist/language_models/compat.d.cts.map +1 -0
  19. package/dist/language_models/compat.d.ts +20 -0
  20. package/dist/language_models/compat.d.ts.map +1 -0
  21. package/dist/language_models/compat.js +224 -0
  22. package/dist/language_models/compat.js.map +1 -0
  23. package/dist/language_models/event.cjs +12 -0
  24. package/dist/language_models/event.cjs.map +1 -0
  25. package/dist/language_models/event.d.cts +141 -0
  26. package/dist/language_models/event.d.cts.map +1 -0
  27. package/dist/language_models/event.d.ts +141 -0
  28. package/dist/language_models/event.d.ts.map +1 -0
  29. package/dist/language_models/event.js +7 -0
  30. package/dist/language_models/event.js.map +1 -0
  31. package/dist/language_models/stream.cjs +412 -0
  32. package/dist/language_models/stream.cjs.map +1 -0
  33. package/dist/language_models/stream.d.cts +106 -0
  34. package/dist/language_models/stream.d.cts.map +1 -0
  35. package/dist/language_models/stream.d.ts +106 -0
  36. package/dist/language_models/stream.d.ts.map +1 -0
  37. package/dist/language_models/stream.js +401 -0
  38. package/dist/language_models/stream.js.map +1 -0
  39. package/dist/load/import_map.cjs +6 -0
  40. package/dist/load/import_map.cjs.map +1 -1
  41. package/dist/load/import_map.js +8 -2
  42. package/dist/load/import_map.js.map +1 -1
  43. package/dist/load/map_keys.cjs +2 -2
  44. package/dist/messages/content/index.cjs.map +1 -1
  45. package/dist/messages/content/index.d.cts +5 -1
  46. package/dist/messages/content/index.d.cts.map +1 -1
  47. package/dist/messages/content/index.d.ts +5 -1
  48. package/dist/messages/content/index.d.ts.map +1 -1
  49. package/dist/messages/content/index.js.map +1 -1
  50. package/dist/messages/index.d.cts +2 -2
  51. package/dist/messages/index.d.ts +2 -2
  52. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -1
  53. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
  54. package/dist/prompts/template.cjs +1 -1
  55. package/dist/singletons/callbacks.cjs +1 -1
  56. package/dist/tracers/console.cjs +1 -1
  57. package/dist/types/type-utils.d.cts +2 -1
  58. package/dist/types/type-utils.d.cts.map +1 -1
  59. package/dist/types/type-utils.d.ts +2 -1
  60. package/dist/types/type-utils.d.ts.map +1 -1
  61. package/dist/utils/async_caller.cjs +3 -2
  62. package/dist/utils/async_caller.cjs.map +1 -1
  63. package/dist/utils/async_caller.js +2 -1
  64. package/dist/utils/async_caller.js.map +1 -1
  65. package/dist/utils/event_source_parse.cjs +5 -12
  66. package/dist/utils/event_source_parse.cjs.map +1 -1
  67. package/dist/utils/event_source_parse.js +5 -12
  68. package/dist/utils/event_source_parse.js.map +1 -1
  69. package/package.json +34 -1
  70. package/agents.cjs +0 -1
  71. package/agents.d.cts +0 -1
  72. package/agents.d.ts +0 -1
  73. package/agents.js +0 -1
  74. package/caches.cjs +0 -1
  75. package/caches.d.cts +0 -1
  76. package/caches.d.ts +0 -1
  77. package/caches.js +0 -1
  78. package/callbacks/base.cjs +0 -1
  79. package/callbacks/base.d.cts +0 -1
  80. package/callbacks/base.d.ts +0 -1
  81. package/callbacks/base.js +0 -1
  82. package/callbacks/dispatch/web.cjs +0 -1
  83. package/callbacks/dispatch/web.d.cts +0 -1
  84. package/callbacks/dispatch/web.d.ts +0 -1
  85. package/callbacks/dispatch/web.js +0 -1
  86. package/callbacks/dispatch.cjs +0 -1
  87. package/callbacks/dispatch.d.cts +0 -1
  88. package/callbacks/dispatch.d.ts +0 -1
  89. package/callbacks/dispatch.js +0 -1
  90. package/callbacks/manager.cjs +0 -1
  91. package/callbacks/manager.d.cts +0 -1
  92. package/callbacks/manager.d.ts +0 -1
  93. package/callbacks/manager.js +0 -1
  94. package/callbacks/promises.cjs +0 -1
  95. package/callbacks/promises.d.cts +0 -1
  96. package/callbacks/promises.d.ts +0 -1
  97. package/callbacks/promises.js +0 -1
  98. package/chat_history.cjs +0 -1
  99. package/chat_history.d.cts +0 -1
  100. package/chat_history.d.ts +0 -1
  101. package/chat_history.js +0 -1
  102. package/context.cjs +0 -1
  103. package/context.d.cts +0 -1
  104. package/context.d.ts +0 -1
  105. package/context.js +0 -1
  106. package/document_loaders/base.cjs +0 -1
  107. package/document_loaders/base.d.cts +0 -1
  108. package/document_loaders/base.d.ts +0 -1
  109. package/document_loaders/base.js +0 -1
  110. package/document_loaders/langsmith.cjs +0 -1
  111. package/document_loaders/langsmith.d.cts +0 -1
  112. package/document_loaders/langsmith.d.ts +0 -1
  113. package/document_loaders/langsmith.js +0 -1
  114. package/documents.cjs +0 -1
  115. package/documents.d.cts +0 -1
  116. package/documents.d.ts +0 -1
  117. package/documents.js +0 -1
  118. package/embeddings.cjs +0 -1
  119. package/embeddings.d.cts +0 -1
  120. package/embeddings.d.ts +0 -1
  121. package/embeddings.js +0 -1
  122. package/errors.cjs +0 -1
  123. package/errors.d.cts +0 -1
  124. package/errors.d.ts +0 -1
  125. package/errors.js +0 -1
  126. package/example_selectors.cjs +0 -1
  127. package/example_selectors.d.cts +0 -1
  128. package/example_selectors.d.ts +0 -1
  129. package/example_selectors.js +0 -1
  130. package/indexing.cjs +0 -1
  131. package/indexing.d.cts +0 -1
  132. package/indexing.d.ts +0 -1
  133. package/indexing.js +0 -1
  134. package/language_models/base.cjs +0 -1
  135. package/language_models/base.d.cts +0 -1
  136. package/language_models/base.d.ts +0 -1
  137. package/language_models/base.js +0 -1
  138. package/language_models/chat_models.cjs +0 -1
  139. package/language_models/chat_models.d.cts +0 -1
  140. package/language_models/chat_models.d.ts +0 -1
  141. package/language_models/chat_models.js +0 -1
  142. package/language_models/llms.cjs +0 -1
  143. package/language_models/llms.d.cts +0 -1
  144. package/language_models/llms.d.ts +0 -1
  145. package/language_models/llms.js +0 -1
  146. package/language_models/profile.cjs +0 -1
  147. package/language_models/profile.d.cts +0 -1
  148. package/language_models/profile.d.ts +0 -1
  149. package/language_models/profile.js +0 -1
  150. package/language_models/structured_output.cjs +0 -1
  151. package/language_models/structured_output.d.cts +0 -1
  152. package/language_models/structured_output.d.ts +0 -1
  153. package/language_models/structured_output.js +0 -1
  154. package/load/serializable.cjs +0 -1
  155. package/load/serializable.d.cts +0 -1
  156. package/load/serializable.d.ts +0 -1
  157. package/load/serializable.js +0 -1
  158. package/load.cjs +0 -1
  159. package/load.d.cts +0 -1
  160. package/load.d.ts +0 -1
  161. package/load.js +0 -1
  162. package/memory.cjs +0 -1
  163. package/memory.d.cts +0 -1
  164. package/memory.d.ts +0 -1
  165. package/memory.js +0 -1
  166. package/messages/tool.cjs +0 -1
  167. package/messages/tool.d.cts +0 -1
  168. package/messages/tool.d.ts +0 -1
  169. package/messages/tool.js +0 -1
  170. package/messages.cjs +0 -1
  171. package/messages.d.cts +0 -1
  172. package/messages.d.ts +0 -1
  173. package/messages.js +0 -1
  174. package/output_parsers/openai_functions.cjs +0 -1
  175. package/output_parsers/openai_functions.d.cts +0 -1
  176. package/output_parsers/openai_functions.d.ts +0 -1
  177. package/output_parsers/openai_functions.js +0 -1
  178. package/output_parsers/openai_tools.cjs +0 -1
  179. package/output_parsers/openai_tools.d.cts +0 -1
  180. package/output_parsers/openai_tools.d.ts +0 -1
  181. package/output_parsers/openai_tools.js +0 -1
  182. package/output_parsers.cjs +0 -1
  183. package/output_parsers.d.cts +0 -1
  184. package/output_parsers.d.ts +0 -1
  185. package/output_parsers.js +0 -1
  186. package/outputs.cjs +0 -1
  187. package/outputs.d.cts +0 -1
  188. package/outputs.d.ts +0 -1
  189. package/outputs.js +0 -1
  190. package/prompt_values.cjs +0 -1
  191. package/prompt_values.d.cts +0 -1
  192. package/prompt_values.d.ts +0 -1
  193. package/prompt_values.js +0 -1
  194. package/prompts.cjs +0 -1
  195. package/prompts.d.cts +0 -1
  196. package/prompts.d.ts +0 -1
  197. package/prompts.js +0 -1
  198. package/retrievers/document_compressors.cjs +0 -1
  199. package/retrievers/document_compressors.d.cts +0 -1
  200. package/retrievers/document_compressors.d.ts +0 -1
  201. package/retrievers/document_compressors.js +0 -1
  202. package/retrievers.cjs +0 -1
  203. package/retrievers.d.cts +0 -1
  204. package/retrievers.d.ts +0 -1
  205. package/retrievers.js +0 -1
  206. package/runnables/graph.cjs +0 -1
  207. package/runnables/graph.d.cts +0 -1
  208. package/runnables/graph.d.ts +0 -1
  209. package/runnables/graph.js +0 -1
  210. package/runnables.cjs +0 -1
  211. package/runnables.d.cts +0 -1
  212. package/runnables.d.ts +0 -1
  213. package/runnables.js +0 -1
  214. package/singletons.cjs +0 -1
  215. package/singletons.d.cts +0 -1
  216. package/singletons.d.ts +0 -1
  217. package/singletons.js +0 -1
  218. package/stores.cjs +0 -1
  219. package/stores.d.cts +0 -1
  220. package/stores.d.ts +0 -1
  221. package/stores.js +0 -1
  222. package/structured_query.cjs +0 -1
  223. package/structured_query.d.cts +0 -1
  224. package/structured_query.d.ts +0 -1
  225. package/structured_query.js +0 -1
  226. package/tools.cjs +0 -1
  227. package/tools.d.cts +0 -1
  228. package/tools.d.ts +0 -1
  229. package/tools.js +0 -1
  230. package/tracers/base.cjs +0 -1
  231. package/tracers/base.d.cts +0 -1
  232. package/tracers/base.d.ts +0 -1
  233. package/tracers/base.js +0 -1
  234. package/tracers/console.cjs +0 -1
  235. package/tracers/console.d.cts +0 -1
  236. package/tracers/console.d.ts +0 -1
  237. package/tracers/console.js +0 -1
  238. package/tracers/log_stream.cjs +0 -1
  239. package/tracers/log_stream.d.cts +0 -1
  240. package/tracers/log_stream.d.ts +0 -1
  241. package/tracers/log_stream.js +0 -1
  242. package/tracers/run_collector.cjs +0 -1
  243. package/tracers/run_collector.d.cts +0 -1
  244. package/tracers/run_collector.d.ts +0 -1
  245. package/tracers/run_collector.js +0 -1
  246. package/tracers/tracer_langchain.cjs +0 -1
  247. package/tracers/tracer_langchain.d.cts +0 -1
  248. package/tracers/tracer_langchain.d.ts +0 -1
  249. package/tracers/tracer_langchain.js +0 -1
  250. package/types/stream.cjs +0 -1
  251. package/types/stream.d.cts +0 -1
  252. package/types/stream.d.ts +0 -1
  253. package/types/stream.js +0 -1
  254. package/utils/async_caller.cjs +0 -1
  255. package/utils/async_caller.d.cts +0 -1
  256. package/utils/async_caller.d.ts +0 -1
  257. package/utils/async_caller.js +0 -1
  258. package/utils/chunk_array.cjs +0 -1
  259. package/utils/chunk_array.d.cts +0 -1
  260. package/utils/chunk_array.d.ts +0 -1
  261. package/utils/chunk_array.js +0 -1
  262. package/utils/context.cjs +0 -1
  263. package/utils/context.d.cts +0 -1
  264. package/utils/context.d.ts +0 -1
  265. package/utils/context.js +0 -1
  266. package/utils/env.cjs +0 -1
  267. package/utils/env.d.cts +0 -1
  268. package/utils/env.d.ts +0 -1
  269. package/utils/env.js +0 -1
  270. package/utils/event_source_parse.cjs +0 -1
  271. package/utils/event_source_parse.d.cts +0 -1
  272. package/utils/event_source_parse.d.ts +0 -1
  273. package/utils/event_source_parse.js +0 -1
  274. package/utils/format.cjs +0 -1
  275. package/utils/format.d.cts +0 -1
  276. package/utils/format.d.ts +0 -1
  277. package/utils/format.js +0 -1
  278. package/utils/function_calling.cjs +0 -1
  279. package/utils/function_calling.d.cts +0 -1
  280. package/utils/function_calling.d.ts +0 -1
  281. package/utils/function_calling.js +0 -1
  282. package/utils/hash.cjs +0 -1
  283. package/utils/hash.d.cts +0 -1
  284. package/utils/hash.d.ts +0 -1
  285. package/utils/hash.js +0 -1
  286. package/utils/json_patch.cjs +0 -1
  287. package/utils/json_patch.d.cts +0 -1
  288. package/utils/json_patch.d.ts +0 -1
  289. package/utils/json_patch.js +0 -1
  290. package/utils/json_schema.cjs +0 -1
  291. package/utils/json_schema.d.cts +0 -1
  292. package/utils/json_schema.d.ts +0 -1
  293. package/utils/json_schema.js +0 -1
  294. package/utils/math.cjs +0 -1
  295. package/utils/math.d.cts +0 -1
  296. package/utils/math.d.ts +0 -1
  297. package/utils/math.js +0 -1
  298. package/utils/ssrf.cjs +0 -1
  299. package/utils/ssrf.d.cts +0 -1
  300. package/utils/ssrf.d.ts +0 -1
  301. package/utils/ssrf.js +0 -1
  302. package/utils/standard_schema.cjs +0 -1
  303. package/utils/standard_schema.d.cts +0 -1
  304. package/utils/standard_schema.d.ts +0 -1
  305. package/utils/standard_schema.js +0 -1
  306. package/utils/stream.cjs +0 -1
  307. package/utils/stream.d.cts +0 -1
  308. package/utils/stream.d.ts +0 -1
  309. package/utils/stream.js +0 -1
  310. package/utils/testing.cjs +0 -1
  311. package/utils/testing.d.cts +0 -1
  312. package/utils/testing.d.ts +0 -1
  313. package/utils/testing.js +0 -1
  314. package/utils/tiktoken.cjs +0 -1
  315. package/utils/tiktoken.d.cts +0 -1
  316. package/utils/tiktoken.d.ts +0 -1
  317. package/utils/tiktoken.js +0 -1
  318. package/utils/types.cjs +0 -1
  319. package/utils/types.d.cts +0 -1
  320. package/utils/types.d.ts +0 -1
  321. package/utils/types.js +0 -1
  322. package/vectorstores.cjs +0 -1
  323. package/vectorstores.d.cts +0 -1
  324. package/vectorstores.d.ts +0 -1
  325. package/vectorstores.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"import_map.js","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as agents from \"../agents.js\";\nexport * as caches from \"../caches/index.js\";\nexport * as callbacks__base from \"../callbacks/base.js\";\nexport * as callbacks__manager from \"../callbacks/manager.js\";\nexport * as callbacks__promises from \"../callbacks/promises.js\";\nexport * as chat_history from \"../chat_history.js\";\nexport * as document_loaders__base from \"../document_loaders/base.js\";\nexport * as document_loaders__langsmith from \"../document_loaders/langsmith.js\";\nexport * as documents from \"../documents/index.js\";\nexport * as embeddings from \"../embeddings.js\";\nexport * as errors from \"../errors/index.js\";\nexport * as example_selectors from \"../example_selectors/index.js\";\nexport * as index from \"../index.js\";\nexport * as indexing from \"../indexing/index.js\";\nexport * as language_models__base from \"../language_models/base.js\";\nexport * as language_models__chat_models from \"../language_models/chat_models.js\";\nexport * as language_models__llms from \"../language_models/llms.js\";\nexport * as language_models__profile from \"../language_models/profile.js\";\nexport * as language_models__structured_output from \"../language_models/structured_output.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as memory from \"../memory.js\";\nexport * as messages from \"../messages/index.js\";\nexport * as messages__tool from \"../messages/tool.js\";\nexport * as output_parsers from \"../output_parsers/index.js\";\nexport * as output_parsers__openai_functions from \"../output_parsers/openai_functions/index.js\";\nexport * as output_parsers__openai_tools from \"../output_parsers/openai_tools/index.js\";\nexport * as outputs from \"../outputs.js\";\nexport * as prompt_values from \"../prompt_values.js\";\nexport * as prompts from \"../prompts/index.js\";\nexport * as retrievers__document_compressors from \"../retrievers/document_compressors/index.js\";\nexport * as retrievers from \"../retrievers/index.js\";\nexport * as runnables__graph from \"../runnables/graph.js\";\nexport * as runnables from \"../runnables/index.js\";\nexport * as singletons from \"../singletons/index.js\";\nexport * as stores from \"../stores.js\";\nexport * as structured_query from \"../structured_query/index.js\";\nexport * as testing from \"../testing/index.js\";\nexport * as tools from \"../tools/index.js\";\nexport * as tracers__base from \"../tracers/base.js\";\nexport * as tracers__console from \"../tracers/console.js\";\nexport * as tracers__log_stream from \"../tracers/log_stream.js\";\nexport * as tracers__run_collector from \"../tracers/run_collector.js\";\nexport * as tracers__tracer_langchain from \"../tracers/tracer_langchain.js\";\nexport * as types__stream from \"../types/stream.js\";\nexport * as utils__async_caller from \"../utils/async_caller.js\";\nexport * as utils__chunk_array from \"../utils/chunk_array.js\";\nexport * as utils__context from \"../utils/context.js\";\nexport * as utils__env from \"../utils/env.js\";\nexport * as utils__event_source_parse from \"../utils/event_source_parse.js\";\nexport * as utils__format from \"../utils/format.js\";\nexport * as utils__function_calling from \"../utils/function_calling.js\";\nexport * as utils__hash from \"../utils/hash.js\";\nexport * as utils__json_patch from \"../utils/json_patch.js\";\nexport * as utils__json_schema from \"../utils/json_schema.js\";\nexport * as utils__math from \"../utils/math.js\";\nexport * as utils__ssrf from \"../utils/ssrf.js\";\nexport * as utils__standard_schema from \"../utils/standard_schema.js\";\nexport * as utils__stream from \"../utils/stream.js\";\nexport * as utils__testing from \"../utils/testing/index.js\";\nexport * as utils__tiktoken from \"../utils/tiktoken.js\";\nexport * as utils__types from \"../utils/types/index.js\";\nexport * as vectorstores from \"../vectorstores.js\";\n"],"mappings":""}
1
+ {"version":3,"file":"import_map.js","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as agents from \"../agents.js\";\nexport * as caches from \"../caches/index.js\";\nexport * as callbacks__base from \"../callbacks/base.js\";\nexport * as callbacks__manager from \"../callbacks/manager.js\";\nexport * as callbacks__promises from \"../callbacks/promises.js\";\nexport * as chat_history from \"../chat_history.js\";\nexport * as document_loaders__base from \"../document_loaders/base.js\";\nexport * as document_loaders__langsmith from \"../document_loaders/langsmith.js\";\nexport * as documents from \"../documents/index.js\";\nexport * as embeddings from \"../embeddings.js\";\nexport * as errors from \"../errors/index.js\";\nexport * as example_selectors from \"../example_selectors/index.js\";\nexport * as index from \"../index.js\";\nexport * as indexing from \"../indexing/index.js\";\nexport * as language_models__base from \"../language_models/base.js\";\nexport * as language_models__chat_models from \"../language_models/chat_models.js\";\nexport * as language_models__compat from \"../language_models/compat.js\";\nexport * as language_models__event from \"../language_models/event.js\";\nexport * as language_models__llms from \"../language_models/llms.js\";\nexport * as language_models__profile from \"../language_models/profile.js\";\nexport * as language_models__stream from \"../language_models/stream.js\";\nexport * as language_models__structured_output from \"../language_models/structured_output.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as memory from \"../memory.js\";\nexport * as messages from \"../messages/index.js\";\nexport * as messages__tool from \"../messages/tool.js\";\nexport * as output_parsers from \"../output_parsers/index.js\";\nexport * as output_parsers__openai_functions from \"../output_parsers/openai_functions/index.js\";\nexport * as output_parsers__openai_tools from \"../output_parsers/openai_tools/index.js\";\nexport * as outputs from \"../outputs.js\";\nexport * as prompt_values from \"../prompt_values.js\";\nexport * as prompts from \"../prompts/index.js\";\nexport * as retrievers__document_compressors from \"../retrievers/document_compressors/index.js\";\nexport * as retrievers from \"../retrievers/index.js\";\nexport * as runnables__graph from \"../runnables/graph.js\";\nexport * as runnables from \"../runnables/index.js\";\nexport * as singletons from \"../singletons/index.js\";\nexport * as stores from \"../stores.js\";\nexport * as structured_query from \"../structured_query/index.js\";\nexport * as testing from \"../testing/index.js\";\nexport * as tools from \"../tools/index.js\";\nexport * as tracers__base from \"../tracers/base.js\";\nexport * as tracers__console from \"../tracers/console.js\";\nexport * as tracers__log_stream from \"../tracers/log_stream.js\";\nexport * as tracers__run_collector from \"../tracers/run_collector.js\";\nexport * as tracers__tracer_langchain from \"../tracers/tracer_langchain.js\";\nexport * as types__stream from \"../types/stream.js\";\nexport * as utils__async_caller from \"../utils/async_caller.js\";\nexport * as utils__chunk_array from \"../utils/chunk_array.js\";\nexport * as utils__context from \"../utils/context.js\";\nexport * as utils__env from \"../utils/env.js\";\nexport * as utils__event_source_parse from \"../utils/event_source_parse.js\";\nexport * as utils__format from \"../utils/format.js\";\nexport * as utils__function_calling from \"../utils/function_calling.js\";\nexport * as utils__hash from \"../utils/hash.js\";\nexport * as utils__json_patch from \"../utils/json_patch.js\";\nexport * as utils__json_schema from \"../utils/json_schema.js\";\nexport * as utils__math from \"../utils/math.js\";\nexport * as utils__ssrf from \"../utils/ssrf.js\";\nexport * as utils__standard_schema from \"../utils/standard_schema.js\";\nexport * as utils__stream from \"../utils/stream.js\";\nexport * as utils__testing from \"../utils/testing/index.js\";\nexport * as utils__tiktoken from \"../utils/tiktoken.js\";\nexport * as utils__types from \"../utils/types/index.js\";\nexport * as vectorstores from \"../vectorstores.js\";\n"],"mappings":""}
@@ -1,8 +1,8 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  let decamelize = require("decamelize");
3
- decamelize = require_runtime.__toESM(decamelize);
3
+ decamelize = require_runtime.__toESM(decamelize, 1);
4
4
  let camelcase = require("camelcase");
5
- camelcase = require_runtime.__toESM(camelcase);
5
+ camelcase = require_runtime.__toESM(camelcase, 1);
6
6
  //#region src/load/map_keys.ts
7
7
  function keyToJson(key, map) {
8
8
  return map?.[key] || (0, decamelize.default)(key);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;AAaA,MAAa,oBAAoB;CAC/B;CACA;CACA,GAAGA,cAAAA;CACH,GAAGC,mBAAAA;CACJ"}
1
+ {"version":3,"file":"index.cjs","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nimport { type DeepPartial } from \"../../types/type-utils.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport type PartialContentBlock<T extends ContentBlock = ContentBlock> = {\n readonly type: T[\"type\"];\n} & DeepPartial<Exclude<T, \"type\">>;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;AAkBA,MAAa,oBAAoB;CAC/B;CACA;CACA,GAAGA,cAAAA;CACH,GAAGC,mBAAAA;CACJ"}
@@ -2,9 +2,13 @@ import { BaseContentBlock } from "./base.cjs";
2
2
  import { Tools } from "./tools.cjs";
3
3
  import { Multimodal } from "./multimodal.cjs";
4
4
  import { Data } from "./data.cjs";
5
+ import { DeepPartial } from "../../types/type-utils.cjs";
5
6
 
6
7
  //#region src/messages/content/index.d.ts
7
8
  interface ContentBlock extends BaseContentBlock {}
9
+ type PartialContentBlock<T extends ContentBlock = ContentBlock> = {
10
+ readonly type: T["type"];
11
+ } & DeepPartial<Exclude<T, "type">>;
8
12
  declare const KNOWN_BLOCK_TYPES: string[];
9
13
  declare namespace ContentBlock {
10
14
  /**
@@ -113,5 +117,5 @@ declare namespace ContentBlock {
113
117
  export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;
114
118
  }
115
119
  //#endregion
116
- export { ContentBlock, KNOWN_BLOCK_TYPES };
120
+ export { ContentBlock, KNOWN_BLOCK_TYPES, PartialContentBlock };
117
121
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":";;;;;;UAWiB,YAAA,SAAqB,gBAAA;AAAA,cAEzB,iBAAA;AAAA,kBAQY,YAAA;;;;mBAIN,QAAA;IAPlB;;;IAAA,SAWY,IAAA;IARY;;;IAYrB,MAAA;IAmD+B;;;IA/C/B,GAAA;IAgFe;;;;;IA1Ef,KAAA;IAwFO;;;;;IAlFP,UAAA;IAyFqB;;;;;IAnFrB,QAAA;IAZA;;;IAgBA,SAAA;EAAA;EAS4B;;;;;;EAAA,iBAAb,IAAA,SAAa,YAAA;IAgBG;;;IAAA,SAZtB,IAAA;IA6BT;;;IAzBA,IAAA;IAyCe;;;IArCf,KAAA;IA8CA;;;IA1CA,WAAA,GAAc,KAAA,CAAM,QAAA,GAAW,gBAAA;EAAA;EA8CxB;;;EAAA,iBAxCQ,SAAA,SAAkB,YAAA;IA4C/B;;;IAAA,SAxCO,IAAA;IA2CD;;;;;;IApCR,SAAA;;;;IAIA,KAAA;EAAA;;;;;;;;mBAUe,WAAA,gBAEA,MAAA,gBAAsB,MAAA,uBAC7B,YAAA;;;;IAIR,IAAA;;;;IAIA,KAAA,EAAO,MAAA;EAAA;EAAA,SAGA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;EAAA,YAEG,QAAA,GACR,IAAA,GACA,SAAA,GACA,WAAA,GACA,KAAA,CAAM,QAAA,GACN,UAAA,CAAW,QAAA;AAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":";;;;;;;UAYiB,YAAA,SAAqB,gBAAA;AAAA,KAE1B,mBAAA,WAA8B,YAAA,GAAe,YAAA;EAAA,SAC9C,IAAA,EAAM,CAAA;AAAA,IACb,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA,cAEX,iBAAA;AAAA,kBAQY,YAAA;EAZb;;;EAAA,iBAgBO,QAAA;IAhBsC;;;IAAA,SAoB5C,IAAA;IAlBT;;;IAsBA,MAAA;IAxBsC;;;IA4BtC,GAAA;IA1BA;;;;;IAgCA,KAAA;IAzBH;;;;AAGD;IA4BI,UAAA;IA5BiC;;;;;IAkCjC,QAAA;IA8De;;;IA1Df,SAAA;EAAA;EAuEO;;;;;;EAAA,iBA9DQ,IAAA,SAAa,YAAA;IAsEP;;;IAAA,SAlEZ,IAAA;IAvCT;;;IA2CA,IAAA;IArBA;;;IAyBA,KAAA;IARS;;;IAYT,WAAA,GAAc,KAAA,CAAM,QAAA,GAAW,gBAAA;EAAA;EAAX;;;EAAA,iBAML,SAAA,SAAkB,YAAA;IAIxB;;;IAAA,SAAA,IAAA;IAuBT;;;;;;IAhBA,SAAA;IA4BO;;;IAxBP,KAAA;EAAA;EA0BO;;;;;;;EAAA,iBAhBQ,WAAA,gBAEA,MAAA,gBAAsB,MAAA,uBAC7B,YAAA;IAoBK;;;IAhBb,IAAA;;;;IAIA,KAAA,EAAO,MAAA;EAAA;EAAA,SAGA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;EAAA,YAEG,QAAA,GACR,IAAA,GACA,SAAA,GACA,WAAA,GACA,KAAA,CAAM,QAAA,GACN,UAAA,CAAW,QAAA;AAAA"}
@@ -2,9 +2,13 @@ import { BaseContentBlock } from "./base.js";
2
2
  import { Tools } from "./tools.js";
3
3
  import { Multimodal } from "./multimodal.js";
4
4
  import { Data } from "./data.js";
5
+ import { DeepPartial } from "../../types/type-utils.js";
5
6
 
6
7
  //#region src/messages/content/index.d.ts
7
8
  interface ContentBlock extends BaseContentBlock {}
9
+ type PartialContentBlock<T extends ContentBlock = ContentBlock> = {
10
+ readonly type: T["type"];
11
+ } & DeepPartial<Exclude<T, "type">>;
8
12
  declare const KNOWN_BLOCK_TYPES: string[];
9
13
  declare namespace ContentBlock {
10
14
  /**
@@ -113,5 +117,5 @@ declare namespace ContentBlock {
113
117
  export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;
114
118
  }
115
119
  //#endregion
116
- export { ContentBlock, KNOWN_BLOCK_TYPES };
120
+ export { ContentBlock, KNOWN_BLOCK_TYPES, PartialContentBlock };
117
121
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":";;;;;;UAWiB,YAAA,SAAqB,gBAAA;AAAA,cAEzB,iBAAA;AAAA,kBAQY,YAAA;;;;mBAIN,QAAA;IAPlB;;;IAAA,SAWY,IAAA;IARY;;;IAYrB,MAAA;IAmD+B;;;IA/C/B,GAAA;IAgFe;;;;;IA1Ef,KAAA;IAwFO;;;;;IAlFP,UAAA;IAyFqB;;;;;IAnFrB,QAAA;IAZA;;;IAgBA,SAAA;EAAA;EAS4B;;;;;;EAAA,iBAAb,IAAA,SAAa,YAAA;IAgBG;;;IAAA,SAZtB,IAAA;IA6BT;;;IAzBA,IAAA;IAyCe;;;IArCf,KAAA;IA8CA;;;IA1CA,WAAA,GAAc,KAAA,CAAM,QAAA,GAAW,gBAAA;EAAA;EA8CxB;;;EAAA,iBAxCQ,SAAA,SAAkB,YAAA;IA4C/B;;;IAAA,SAxCO,IAAA;IA2CD;;;;;;IApCR,SAAA;;;;IAIA,KAAA;EAAA;;;;;;;;mBAUe,WAAA,gBAEA,MAAA,gBAAsB,MAAA,uBAC7B,YAAA;;;;IAIR,IAAA;;;;IAIA,KAAA,EAAO,MAAA;EAAA;EAAA,SAGA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;EAAA,YAEG,QAAA,GACR,IAAA,GACA,SAAA,GACA,WAAA,GACA,KAAA,CAAM,QAAA,GACN,UAAA,CAAW,QAAA;AAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/messages/content/index.ts"],"mappings":";;;;;;;UAYiB,YAAA,SAAqB,gBAAA;AAAA,KAE1B,mBAAA,WAA8B,YAAA,GAAe,YAAA;EAAA,SAC9C,IAAA,EAAM,CAAA;AAAA,IACb,WAAA,CAAY,OAAA,CAAQ,CAAA;AAAA,cAEX,iBAAA;AAAA,kBAQY,YAAA;EAZb;;;EAAA,iBAgBO,QAAA;IAhBsC;;;IAAA,SAoB5C,IAAA;IAlBT;;;IAsBA,MAAA;IAxBsC;;;IA4BtC,GAAA;IA1BA;;;;;IAgCA,KAAA;IAzBH;;;;AAGD;IA4BI,UAAA;IA5BiC;;;;;IAkCjC,QAAA;IA8De;;;IA1Df,SAAA;EAAA;EAuEO;;;;;;EAAA,iBA9DQ,IAAA,SAAa,YAAA;IAsEP;;;IAAA,SAlEZ,IAAA;IAvCT;;;IA2CA,IAAA;IArBA;;;IAyBA,KAAA;IARS;;;IAYT,WAAA,GAAc,KAAA,CAAM,QAAA,GAAW,gBAAA;EAAA;EAAX;;;EAAA,iBAML,SAAA,SAAkB,YAAA;IAIxB;;;IAAA,SAAA,IAAA;IAuBT;;;;;;IAhBA,SAAA;IA4BO;;;IAxBP,KAAA;EAAA;EA0BO;;;;;;;EAAA,iBAhBQ,WAAA,gBAEA,MAAA,gBAAsB,MAAA,uBAC7B,YAAA;IAoBK;;;IAhBb,IAAA;;;;IAIA,KAAA,EAAO,MAAA;EAAA;EAAA,SAGA,KAAA;EAAA,SACA,UAAA;EAAA,SACA,IAAA;EAAA,YAEG,QAAA,GACR,IAAA,GACA,SAAA,GACA,WAAA,GACA,KAAA,CAAM,QAAA,GACN,UAAA,CAAW,QAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;AAaA,MAAa,oBAAoB;CAC/B;CACA;CACA,GAAGA;CACH,GAAGC;CACJ"}
1
+ {"version":3,"file":"index.js","names":["KNOWN_TOOL_BLOCK_TYPES","KNOWN_MULTIMODAL_BLOCK_TYPES"],"sources":["../../../src/messages/content/index.ts"],"sourcesContent":["import type { BaseContentBlock } from \"./base.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_TOOL_BLOCK_TYPES,\n type Tools,\n} from \"./tools.js\";\nimport {\n KNOWN_BLOCK_TYPES as KNOWN_MULTIMODAL_BLOCK_TYPES,\n type Multimodal,\n} from \"./multimodal.js\";\nimport { type Data } from \"./data.js\";\nimport { type DeepPartial } from \"../../types/type-utils.js\";\n\nexport interface ContentBlock extends BaseContentBlock {}\n\nexport type PartialContentBlock<T extends ContentBlock = ContentBlock> = {\n readonly type: T[\"type\"];\n} & DeepPartial<Exclude<T, \"type\">>;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"text\",\n \"reasoning\",\n ...KNOWN_TOOL_BLOCK_TYPES,\n ...KNOWN_MULTIMODAL_BLOCK_TYPES,\n];\n\n// oxlint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: string | number;\n }\n\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>,\n > extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n\n export { Tools };\n export { Multimodal };\n export { Data };\n\n export type Standard =\n | Text\n | Reasoning\n | NonStandard\n | Tools.Standard\n | Multimodal.Standard;\n}\n"],"mappings":";;;AAkBA,MAAa,oBAAoB;CAC/B;CACA;CACA,GAAGA;CACH,GAAGC;CACJ"}
@@ -1,5 +1,5 @@
1
1
  import { Data, ImageDetail, MessageContentComplex, MessageContentImageUrl, MessageContentText, ProviderFormatTypes, StandardContentBlockConverter, convertToOpenAIImageBlock, convertToProviderContentBlock, isBase64ContentBlock, isDataContentBlock, isIDContentBlock, isPlainTextContentBlock, isURLContentBlock, parseBase64DataUrl, parseMimeType } from "./content/data.cjs";
2
- import { ContentBlock, KNOWN_BLOCK_TYPES } from "./content/index.cjs";
2
+ import { ContentBlock, KNOWN_BLOCK_TYPES, PartialContentBlock } from "./content/index.cjs";
3
3
  import { InputTokenDetails, ModalitiesTokenDetails, OutputTokenDetails, ResponseMetadata, UsageMetadata, mergeResponseMetadata, mergeUsageMetadata } from "./metadata.cjs";
4
4
  import { BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, DEFAULT_MERGE_IGNORE_KEYS, FunctionCall, MergeDictsOptions, MessageContent, MessageFieldWithRole, OpenAIToolCall, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, isBaseMessage, isBaseMessageChunk, isOpenAIToolCallArray, mergeContent } from "./base.cjs";
5
5
  import { DirectToolOutput, InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, defaultToolCallParser, isDirectToolOutput, isToolMessage, isToolMessageChunk } from "./tool.cjs";
@@ -12,4 +12,4 @@ import { $Expand, $MergeDiscriminatedUnion, $MergeObjects, Constructor, coerceMe
12
12
  import { $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeMessageStructure, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, Message, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, StandardMessageStructure, isMessage } from "./message.cjs";
13
13
  import { RemoveMessage, RemoveMessageFields } from "./modifier.cjs";
14
14
  import { FilterMessagesFields, MessageChunkUnion, MessageTypeOrClass, MessageUnion, TrimMessagesFields, defaultTextSplitter, filterMessages, mergeMessageRuns, trimMessages } from "./transformers.cjs";
15
- export { $Expand, $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeDiscriminatedUnion, $MergeMessageStructure, $MergeObjects, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, AIMessage, AIMessageChunk, AIMessageChunkFields, AIMessageFields, BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, ChatMessage, ChatMessageChunk, ChatMessageFields, Constructor, ContentBlock, DEFAULT_MERGE_IGNORE_KEYS, Data, DirectToolOutput, FilterMessagesFields, FunctionCall, FunctionMessage, FunctionMessageChunk, FunctionMessageFields, HumanMessage, HumanMessageChunk, HumanMessageFields, ImageDetail, InputTokenDetails, InvalidToolCall, KNOWN_BLOCK_TYPES, MergeDictsOptions, Message, MessageChunkUnion, MessageContent, MessageContentComplex, MessageContentImageUrl, MessageContentText, MessageFieldWithRole, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, MessageTypeOrClass, MessageUnion, ModalitiesTokenDetails, OpenAIToolCall, OutputTokenDetails, ProviderFormatTypes, RemoveMessage, RemoveMessageFields, ResponseMetadata, StandardContentBlockConverter, StandardMessageStructure, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, SystemMessage, SystemMessageChunk, SystemMessageFields, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, TrimMessagesFields, UsageMetadata, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, parseBase64DataUrl, parseMimeType, trimMessages };
15
+ export { $Expand, $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeDiscriminatedUnion, $MergeMessageStructure, $MergeObjects, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, AIMessage, AIMessageChunk, AIMessageChunkFields, AIMessageFields, BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, ChatMessage, ChatMessageChunk, ChatMessageFields, Constructor, ContentBlock, DEFAULT_MERGE_IGNORE_KEYS, Data, DirectToolOutput, FilterMessagesFields, FunctionCall, FunctionMessage, FunctionMessageChunk, FunctionMessageFields, HumanMessage, HumanMessageChunk, HumanMessageFields, ImageDetail, InputTokenDetails, InvalidToolCall, KNOWN_BLOCK_TYPES, MergeDictsOptions, Message, MessageChunkUnion, MessageContent, MessageContentComplex, MessageContentImageUrl, MessageContentText, MessageFieldWithRole, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, MessageTypeOrClass, MessageUnion, ModalitiesTokenDetails, OpenAIToolCall, OutputTokenDetails, PartialContentBlock, ProviderFormatTypes, RemoveMessage, RemoveMessageFields, ResponseMetadata, StandardContentBlockConverter, StandardMessageStructure, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, SystemMessage, SystemMessageChunk, SystemMessageFields, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, TrimMessagesFields, UsageMetadata, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, parseBase64DataUrl, parseMimeType, trimMessages };
@@ -1,5 +1,5 @@
1
1
  import { Data, ImageDetail, MessageContentComplex, MessageContentImageUrl, MessageContentText, ProviderFormatTypes, StandardContentBlockConverter, convertToOpenAIImageBlock, convertToProviderContentBlock, isBase64ContentBlock, isDataContentBlock, isIDContentBlock, isPlainTextContentBlock, isURLContentBlock, parseBase64DataUrl, parseMimeType } from "./content/data.js";
2
- import { ContentBlock, KNOWN_BLOCK_TYPES } from "./content/index.js";
2
+ import { ContentBlock, KNOWN_BLOCK_TYPES, PartialContentBlock } from "./content/index.js";
3
3
  import { InputTokenDetails, ModalitiesTokenDetails, OutputTokenDetails, ResponseMetadata, UsageMetadata, mergeResponseMetadata, mergeUsageMetadata } from "./metadata.js";
4
4
  import { BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, DEFAULT_MERGE_IGNORE_KEYS, FunctionCall, MergeDictsOptions, MessageContent, MessageFieldWithRole, OpenAIToolCall, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, isBaseMessage, isBaseMessageChunk, isOpenAIToolCallArray, mergeContent } from "./base.js";
5
5
  import { DirectToolOutput, InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, defaultToolCallParser, isDirectToolOutput, isToolMessage, isToolMessageChunk } from "./tool.js";
@@ -12,4 +12,4 @@ import { $Expand, $MergeDiscriminatedUnion, $MergeObjects, Constructor, coerceMe
12
12
  import { $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeMessageStructure, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, Message, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, StandardMessageStructure, isMessage } from "./message.js";
13
13
  import { RemoveMessage, RemoveMessageFields } from "./modifier.js";
14
14
  import { FilterMessagesFields, MessageChunkUnion, MessageTypeOrClass, MessageUnion, TrimMessagesFields, defaultTextSplitter, filterMessages, mergeMessageRuns, trimMessages } from "./transformers.js";
15
- export { $Expand, $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeDiscriminatedUnion, $MergeMessageStructure, $MergeObjects, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, AIMessage, AIMessageChunk, AIMessageChunkFields, AIMessageFields, BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, ChatMessage, ChatMessageChunk, ChatMessageFields, Constructor, ContentBlock, DEFAULT_MERGE_IGNORE_KEYS, Data, DirectToolOutput, FilterMessagesFields, FunctionCall, FunctionMessage, FunctionMessageChunk, FunctionMessageFields, HumanMessage, HumanMessageChunk, HumanMessageFields, ImageDetail, InputTokenDetails, InvalidToolCall, KNOWN_BLOCK_TYPES, MergeDictsOptions, Message, MessageChunkUnion, MessageContent, MessageContentComplex, MessageContentImageUrl, MessageContentText, MessageFieldWithRole, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, MessageTypeOrClass, MessageUnion, ModalitiesTokenDetails, OpenAIToolCall, OutputTokenDetails, ProviderFormatTypes, RemoveMessage, RemoveMessageFields, ResponseMetadata, StandardContentBlockConverter, StandardMessageStructure, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, SystemMessage, SystemMessageChunk, SystemMessageFields, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, TrimMessagesFields, UsageMetadata, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, parseBase64DataUrl, parseMimeType, trimMessages };
15
+ export { $Expand, $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $InferToolCalls, $InferToolOutputs, $MergeContentDefinition, $MergeDiscriminatedUnion, $MergeMessageStructure, $MergeObjects, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, AIMessage, AIMessageChunk, AIMessageChunkFields, AIMessageFields, BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, ChatMessage, ChatMessageChunk, ChatMessageFields, Constructor, ContentBlock, DEFAULT_MERGE_IGNORE_KEYS, Data, DirectToolOutput, FilterMessagesFields, FunctionCall, FunctionMessage, FunctionMessageChunk, FunctionMessageFields, HumanMessage, HumanMessageChunk, HumanMessageFields, ImageDetail, InputTokenDetails, InvalidToolCall, KNOWN_BLOCK_TYPES, MergeDictsOptions, Message, MessageChunkUnion, MessageContent, MessageContentComplex, MessageContentImageUrl, MessageContentText, MessageFieldWithRole, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, MessageTypeOrClass, MessageUnion, ModalitiesTokenDetails, OpenAIToolCall, OutputTokenDetails, PartialContentBlock, ProviderFormatTypes, RemoveMessage, RemoveMessageFields, ResponseMetadata, StandardContentBlockConverter, StandardMessageStructure, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, SystemMessage, SystemMessageChunk, SystemMessageFields, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, TrimMessagesFields, UsageMetadata, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, coerceMessageLikeToMessage, collapseToolCallChunks, convertToChunk, convertToOpenAIImageBlock, convertToProviderContentBlock, defaultTextSplitter, defaultToolCallParser, filterMessages, getBufferString, iife, isAIMessage, isAIMessageChunk, isBase64ContentBlock, isBaseMessage, isBaseMessageChunk, isChatMessage, isChatMessageChunk, isDataContentBlock, isDirectToolOutput, isFunctionMessage, isFunctionMessageChunk, isHumanMessage, isHumanMessageChunk, isIDContentBlock, isMessage, isOpenAIToolCallArray, isPlainTextContentBlock, isSystemMessage, isSystemMessageChunk, isToolMessage, isToolMessageChunk, isURLContentBlock, mapChatMessagesToStoredMessages, mapStoredMessageToChatMessage, mapStoredMessagesToChatMessages, mergeContent, mergeMessageRuns, mergeResponseMetadata, mergeUsageMetadata, parseBase64DataUrl, parseMimeType, trimMessages };
@@ -1,9 +1,9 @@
1
+ import { Optional } from "../../types/type-utils.cjs";
1
2
  import { ChatGeneration, Generation } from "../../outputs.cjs";
2
3
  import { Operation } from "../../utils/fast-json-patch/src/core.cjs";
3
4
  import { JsonSchema7ObjectType } from "../../utils/zod-to-json-schema/parsers/object.cjs";
4
5
  import { BaseLLMOutputParser } from "../base.cjs";
5
6
  import { BaseCumulativeTransformOutputParser, BaseCumulativeTransformOutputParserInput } from "../transform.cjs";
6
- import { Optional } from "../../types/type-utils.cjs";
7
7
 
8
8
  //#region src/output_parsers/openai_functions/json_output_functions_parsers.d.ts
9
9
  /**
@@ -1,9 +1,9 @@
1
+ import { Optional } from "../../types/type-utils.js";
1
2
  import { ChatGeneration, Generation } from "../../outputs.js";
2
3
  import { Operation } from "../../utils/fast-json-patch/src/core.js";
3
4
  import { JsonSchema7ObjectType } from "../../utils/zod-to-json-schema/parsers/object.js";
4
5
  import { BaseLLMOutputParser } from "../base.js";
5
6
  import { BaseCumulativeTransformOutputParser, BaseCumulativeTransformOutputParserInput } from "../transform.js";
6
- import { Optional } from "../../types/type-utils.js";
7
7
 
8
8
  //#region src/output_parsers/openai_functions/json_output_functions_parsers.d.ts
9
9
  /**
@@ -1,7 +1,7 @@
1
1
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  const require_errors_index = require("../errors/index.cjs");
3
3
  let mustache = require("mustache");
4
- mustache = require_runtime.__toESM(mustache);
4
+ mustache = require_runtime.__toESM(mustache, 1);
5
5
  //#region src/prompts/template.ts
6
6
  function configureMustache() {
7
7
  mustache.default.escape = (text) => text;
@@ -2,7 +2,7 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
2
2
  const require_tracer = require("./tracer.cjs");
3
3
  const require_globals = require("./async_local_storage/globals.cjs");
4
4
  let p_queue = require("p-queue");
5
- p_queue = require_runtime.__toESM(p_queue);
5
+ p_queue = require_runtime.__toESM(p_queue, 1);
6
6
  //#region src/singletons/callbacks.ts
7
7
  let queue;
8
8
  /**
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
3
  const require_tracers_base = require("./base.cjs");
4
4
  let ansi_styles = require("ansi-styles");
5
- ansi_styles = require_runtime.__toESM(ansi_styles);
5
+ ansi_styles = require_runtime.__toESM(ansi_styles, 1);
6
6
  //#region src/tracers/console.ts
7
7
  var console_exports = /* @__PURE__ */ require_runtime.__exportAll({ ConsoleCallbackHandler: () => ConsoleCallbackHandler });
8
8
  function wrap(style, text) {
@@ -1,5 +1,6 @@
1
1
  //#region src/types/type-utils.d.ts
2
2
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
3
+ type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] };
3
4
  //#endregion
4
- export { Optional };
5
+ export { DeepPartial, Optional };
5
6
  //# sourceMappingURL=type-utils.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-utils.d.cts","names":[],"sources":["../../src/types/type-utils.ts"],"mappings":";KAEY,QAAA,oBAA4B,CAAA,IAAK,IAAA,CAAK,CAAA,EAAG,CAAA,IAAK,OAAA,CAAQ,IAAA,CAAK,CAAA,EAAG,CAAA"}
1
+ {"version":3,"file":"type-utils.d.cts","names":[],"sources":["../../src/types/type-utils.ts"],"mappings":";KAEY,QAAA,oBAA4B,CAAA,IAAK,IAAA,CAAK,CAAA,EAAG,CAAA,IAAK,OAAA,CAAQ,IAAA,CAAK,CAAA,EAAG,CAAA;AAAA,KAG9D,WAAA,oBACE,CAAA,IAAK,CAAA,CAAE,CAAA,mBAAoB,WAAA,CAAY,CAAA,CAAE,CAAA,KAAM,CAAA,CAAE,CAAA"}
@@ -1,5 +1,6 @@
1
1
  //#region src/types/type-utils.d.ts
2
2
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
3
+ type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] };
3
4
  //#endregion
4
- export { Optional };
5
+ export { DeepPartial, Optional };
5
6
  //# sourceMappingURL=type-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-utils.d.ts","names":[],"sources":["../../src/types/type-utils.ts"],"mappings":";KAEY,QAAA,oBAA4B,CAAA,IAAK,IAAA,CAAK,CAAA,EAAG,CAAA,IAAK,OAAA,CAAQ,IAAA,CAAK,CAAA,EAAG,CAAA"}
1
+ {"version":3,"file":"type-utils.d.ts","names":[],"sources":["../../src/types/type-utils.ts"],"mappings":";KAEY,QAAA,oBAA4B,CAAA,IAAK,IAAA,CAAK,CAAA,EAAG,CAAA,IAAK,OAAA,CAAQ,IAAA,CAAK,CAAA,EAAG,CAAA;AAAA,KAG9D,WAAA,oBACE,CAAA,IAAK,CAAA,CAAE,CAAA,mBAAoB,WAAA,CAAY,CAAA,CAAE,CAAA,KAAM,CAAA,CAAE,CAAA"}
@@ -3,7 +3,7 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
3
3
  const require_signal = require("./signal.cjs");
4
4
  const require_index = require("./p-retry/index.cjs");
5
5
  let p_queue = require("p-queue");
6
- p_queue = require_runtime.__toESM(p_queue);
6
+ p_queue = require_runtime.__toESM(p_queue, 1);
7
7
  //#region src/utils/async_caller.ts
8
8
  var async_caller_exports = /* @__PURE__ */ require_runtime.__exportAll({ AsyncCaller: () => AsyncCaller });
9
9
  const STATUS_NO_RETRY = [
@@ -58,7 +58,8 @@ var AsyncCaller = class {
58
58
  this.maxConcurrency = params.maxConcurrency ?? Infinity;
59
59
  this.maxRetries = params.maxRetries ?? 6;
60
60
  this.onFailedAttempt = params.onFailedAttempt ?? defaultFailedAttemptHandler;
61
- this.queue = new ("default" in p_queue.default ? p_queue.default.default : p_queue.default)({ concurrency: this.maxConcurrency });
61
+ const PQueue = "default" in p_queue.default ? p_queue.default.default : p_queue.default;
62
+ this.queue = new PQueue({ concurrency: this.maxConcurrency });
62
63
  }
63
64
  async call(callable, ...args) {
64
65
  return this.queue.add(() => require_index.default(() => callable(...args).catch((error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"async_caller.cjs","names":["PQueueMod","pRetry","getAbortSignalError"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\n\nimport { getAbortSignalError } from \"./signal.js\";\nimport pRetry from \"./p-retry/index.js\";\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n/**\n * The default failed attempt handler for the AsyncCaller.\n * @param error - The error to handle.\n * @returns void\n */\nconst defaultFailedAttemptHandler = (error: unknown) => {\n if (typeof error !== \"object\" || error === null) {\n return;\n }\n\n if (\n (\"message\" in error &&\n typeof error.message === \"string\" &&\n (error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\"))) ||\n (\"name\" in error &&\n typeof error.name === \"string\" &&\n error.name === \"AbortError\")\n ) {\n throw error;\n }\n if (\n \"code\" in error &&\n typeof error.code === \"string\" &&\n error.code === \"ECONNABORTED\"\n ) {\n throw error;\n }\n const responseStatus =\n \"response\" in error &&\n typeof error.response === \"object\" &&\n error.response !== null &&\n \"status\" in error.response &&\n typeof error.response.status === \"number\"\n ? error.response.status\n : undefined;\n\n // OpenAI SDK errors expose status directly on the error object\n const directStatus =\n \"status\" in error && typeof error.status === \"number\"\n ? error.status\n : undefined;\n\n const status = responseStatus ?? directStatus;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n\n const code =\n \"error\" in error &&\n typeof error.error === \"object\" &&\n error.error !== null &&\n \"code\" in error.error &&\n typeof error.error.code === \"string\"\n ? error.error.code\n : undefined;\n if (code === \"insufficient_quota\") {\n const err = new Error(\n \"message\" in error && typeof error.message === \"string\"\n ? error.message\n : \"Insufficient quota\"\n );\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: (typeof import(\"p-queue\"))[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // oxlint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener, { once: true });\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n return this.call(() =>\n fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n );\n }\n}\n"],"mappings":";;;;;;;;AAKA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;AAOD,MAAM,+BAA+B,UAAmB;AACtD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC;AAGF,KACG,aAAa,SACZ,OAAO,MAAM,YAAY,aACxB,MAAM,QAAQ,WAAW,SAAS,IACjC,MAAM,QAAQ,WAAW,aAAa,KACzC,UAAU,SACT,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,aAEjB,OAAM;AAER,KACE,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,eAEf,OAAM;CAER,MAAM,iBACJ,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,MAAM,aAAa,QACnB,YAAY,MAAM,YAClB,OAAO,MAAM,SAAS,WAAW,WAC7B,MAAM,SAAS,SACf,KAAA;CAG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BAAoB,QAAQ,OAAO,CAAC;;AAE7C,YAAQ,QAAQ,iBAAiB,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC;KACnE,CACH,CAAC,CAAC,cAAc;AACf,QAAI,QAAQ,UAAU,SACpB,SAAQ,OAAO,oBAAoB,SAAS,SAAS;KAEvD;;AAEJ,SAAO,KAAK,KAAW,UAAU,GAAG,KAAK;;CAG3C,MAAM,GAAG,MAA0D;AACjE,SAAO,KAAK,WACV,MAAM,GAAG,KAAK,CAAC,MAAM,QAAS,IAAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE"}
1
+ {"version":3,"file":"async_caller.cjs","names":["PQueueMod","pRetry","getAbortSignalError"],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\n\nimport { getAbortSignalError } from \"./signal.js\";\nimport pRetry from \"./p-retry/index.js\";\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n/**\n * The default failed attempt handler for the AsyncCaller.\n * @param error - The error to handle.\n * @returns void\n */\nconst defaultFailedAttemptHandler = (error: unknown) => {\n if (typeof error !== \"object\" || error === null) {\n return;\n }\n\n if (\n (\"message\" in error &&\n typeof error.message === \"string\" &&\n (error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\"))) ||\n (\"name\" in error &&\n typeof error.name === \"string\" &&\n error.name === \"AbortError\")\n ) {\n throw error;\n }\n if (\n \"code\" in error &&\n typeof error.code === \"string\" &&\n error.code === \"ECONNABORTED\"\n ) {\n throw error;\n }\n const responseStatus =\n \"response\" in error &&\n typeof error.response === \"object\" &&\n error.response !== null &&\n \"status\" in error.response &&\n typeof error.response.status === \"number\"\n ? error.response.status\n : undefined;\n\n // OpenAI SDK errors expose status directly on the error object\n const directStatus =\n \"status\" in error && typeof error.status === \"number\"\n ? error.status\n : undefined;\n\n const status = responseStatus ?? directStatus;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n\n const code =\n \"error\" in error &&\n typeof error.error === \"object\" &&\n error.error !== null &&\n \"code\" in error.error &&\n typeof error.error.code === \"string\"\n ? error.error.code\n : undefined;\n if (code === \"insufficient_quota\") {\n const err = new Error(\n \"message\" in error && typeof error.message === \"string\"\n ? error.message\n : \"Insufficient quota\"\n );\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: (typeof import(\"p-queue\"))[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // oxlint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener, { once: true });\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n return this.call(() =>\n fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n );\n }\n}\n"],"mappings":";;;;;;;;AAKA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;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;AACjC,SAAO,KAAK,MAAM,UAEdC,cAAAA,cAEI,SAAS,GAAG,KAAK,CAAC,OAAO,UAAU;AAEjC,OAAI,iBAAiB,MACnB,OAAM;OAEN,OAAM,IAAI,MAAM,MAAM;IAExB,EACJ;GACE,kBAAkB,EAAE,YAAY,KAAK,kBAAkB,MAAM;GAC7D,SAAS,KAAK;GACd,WAAW;GAGZ,CACF,EACH,EAAE,gBAAgB,MAAM,CACzB;;CAIH,gBACE,SACA,UACA,GAAG,MAC8B;AAGjC,MAAI,QAAQ,QAAQ;GAClB,IAAI;AACJ,UAAO,QAAQ,KAAK,CAClB,KAAK,KAAW,UAAU,GAAG,KAAK,EAClC,IAAI,SAAgB,GAAG,WAAW;AAChC,qBAAiB;AACf,YAAOC,eAAAA,oBAAoB,QAAQ,OAAO,CAAC;;AAE7C,YAAQ,QAAQ,iBAAiB,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC;KACnE,CACH,CAAC,CAAC,cAAc;AACf,QAAI,QAAQ,UAAU,SACpB,SAAQ,OAAO,oBAAoB,SAAS,SAAS;KAEvD;;AAEJ,SAAO,KAAK,KAAW,UAAU,GAAG,KAAK;;CAG3C,MAAM,GAAG,MAA0D;AACjE,SAAO,KAAK,WACV,MAAM,GAAG,KAAK,CAAC,MAAM,QAAS,IAAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE"}
@@ -56,7 +56,8 @@ var AsyncCaller = class {
56
56
  this.maxConcurrency = params.maxConcurrency ?? Infinity;
57
57
  this.maxRetries = params.maxRetries ?? 6;
58
58
  this.onFailedAttempt = params.onFailedAttempt ?? defaultFailedAttemptHandler;
59
- this.queue = new ("default" in PQueueMod ? PQueueMod.default : PQueueMod)({ concurrency: this.maxConcurrency });
59
+ const PQueue = "default" in PQueueMod ? PQueueMod.default : PQueueMod;
60
+ this.queue = new PQueue({ concurrency: this.maxConcurrency });
60
61
  }
61
62
  async call(callable, ...args) {
62
63
  return this.queue.add(() => pRetry(() => callable(...args).catch((error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"async_caller.js","names":[],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\n\nimport { getAbortSignalError } from \"./signal.js\";\nimport pRetry from \"./p-retry/index.js\";\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n/**\n * The default failed attempt handler for the AsyncCaller.\n * @param error - The error to handle.\n * @returns void\n */\nconst defaultFailedAttemptHandler = (error: unknown) => {\n if (typeof error !== \"object\" || error === null) {\n return;\n }\n\n if (\n (\"message\" in error &&\n typeof error.message === \"string\" &&\n (error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\"))) ||\n (\"name\" in error &&\n typeof error.name === \"string\" &&\n error.name === \"AbortError\")\n ) {\n throw error;\n }\n if (\n \"code\" in error &&\n typeof error.code === \"string\" &&\n error.code === \"ECONNABORTED\"\n ) {\n throw error;\n }\n const responseStatus =\n \"response\" in error &&\n typeof error.response === \"object\" &&\n error.response !== null &&\n \"status\" in error.response &&\n typeof error.response.status === \"number\"\n ? error.response.status\n : undefined;\n\n // OpenAI SDK errors expose status directly on the error object\n const directStatus =\n \"status\" in error && typeof error.status === \"number\"\n ? error.status\n : undefined;\n\n const status = responseStatus ?? directStatus;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n\n const code =\n \"error\" in error &&\n typeof error.error === \"object\" &&\n error.error !== null &&\n \"code\" in error.error &&\n typeof error.error.code === \"string\"\n ? error.error.code\n : undefined;\n if (code === \"insufficient_quota\") {\n const err = new Error(\n \"message\" in error && typeof error.message === \"string\"\n ? error.message\n : \"Insufficient quota\"\n );\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: (typeof import(\"p-queue\"))[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // oxlint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener, { once: true });\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n return this.call(() =>\n fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n );\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;AAOD,MAAM,+BAA+B,UAAmB;AACtD,KAAI,OAAO,UAAU,YAAY,UAAU,KACzC;AAGF,KACG,aAAa,SACZ,OAAO,MAAM,YAAY,aACxB,MAAM,QAAQ,WAAW,SAAS,IACjC,MAAM,QAAQ,WAAW,aAAa,KACzC,UAAU,SACT,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,aAEjB,OAAM;AAER,KACE,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,eAEf,OAAM;CAER,MAAM,iBACJ,cAAc,SACd,OAAO,MAAM,aAAa,YAC1B,MAAM,aAAa,QACnB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G,WAAW;AAChC,qBAAiB;AACf,YAAO,oBAAoB,QAAQ,OAAO,CAAC;;AAE7C,YAAQ,QAAQ,iBAAiB,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC;KACnE,CACH,CAAC,CAAC,cAAc;AACf,QAAI,QAAQ,UAAU,SACpB,SAAQ,OAAO,oBAAoB,SAAS,SAAS;KAEvD;;AAEJ,SAAO,KAAK,KAAW,UAAU,GAAG,KAAK;;CAG3C,MAAM,GAAG,MAA0D;AACjE,SAAO,KAAK,WACV,MAAM,GAAG,KAAK,CAAC,MAAM,QAAS,IAAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE"}
1
+ {"version":3,"file":"async_caller.js","names":[],"sources":["../../src/utils/async_caller.ts"],"sourcesContent":["import PQueueMod from \"p-queue\";\n\nimport { getAbortSignalError } from \"./signal.js\";\nimport pRetry from \"./p-retry/index.js\";\n\nconst STATUS_NO_RETRY = [\n 400, // Bad Request\n 401, // Unauthorized\n 402, // Payment Required\n 403, // Forbidden\n 404, // Not Found\n 405, // Method Not Allowed\n 406, // Not Acceptable\n 407, // Proxy Authentication Required\n 409, // Conflict\n];\n\n/**\n * The default failed attempt handler for the AsyncCaller.\n * @param error - The error to handle.\n * @returns void\n */\nconst defaultFailedAttemptHandler = (error: unknown) => {\n if (typeof error !== \"object\" || error === null) {\n return;\n }\n\n if (\n (\"message\" in error &&\n typeof error.message === \"string\" &&\n (error.message.startsWith(\"Cancel\") ||\n error.message.startsWith(\"AbortError\"))) ||\n (\"name\" in error &&\n typeof error.name === \"string\" &&\n error.name === \"AbortError\")\n ) {\n throw error;\n }\n if (\n \"code\" in error &&\n typeof error.code === \"string\" &&\n error.code === \"ECONNABORTED\"\n ) {\n throw error;\n }\n const responseStatus =\n \"response\" in error &&\n typeof error.response === \"object\" &&\n error.response !== null &&\n \"status\" in error.response &&\n typeof error.response.status === \"number\"\n ? error.response.status\n : undefined;\n\n // OpenAI SDK errors expose status directly on the error object\n const directStatus =\n \"status\" in error && typeof error.status === \"number\"\n ? error.status\n : undefined;\n\n const status = responseStatus ?? directStatus;\n if (status && STATUS_NO_RETRY.includes(+status)) {\n throw error;\n }\n\n const code =\n \"error\" in error &&\n typeof error.error === \"object\" &&\n error.error !== null &&\n \"code\" in error.error &&\n typeof error.error.code === \"string\"\n ? error.error.code\n : undefined;\n if (code === \"insufficient_quota\") {\n const err = new Error(\n \"message\" in error && typeof error.message === \"string\"\n ? error.message\n : \"Insufficient quota\"\n );\n err.name = \"InsufficientQuotaError\";\n throw err;\n }\n};\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type FailedAttemptHandler = (error: any) => any;\n\nexport interface AsyncCallerParams {\n /**\n * The maximum number of concurrent calls that can be made.\n * Defaults to `Infinity`, which means no limit.\n */\n maxConcurrency?: number;\n /**\n * The maximum number of retries that can be made for a single call,\n * with an exponential backoff between each attempt. Defaults to 6.\n */\n maxRetries?: number;\n /**\n * Custom handler to handle failed attempts. Takes the originally thrown\n * error object as input, and should itself throw an error if the input\n * error is not retryable.\n */\n onFailedAttempt?: FailedAttemptHandler;\n}\n\nexport interface AsyncCallerCallOptions {\n signal?: AbortSignal;\n}\n\n/**\n * A class that can be used to make async calls with concurrency and retry logic.\n *\n * This is useful for making calls to any kind of \"expensive\" external resource,\n * be it because it's rate-limited, subject to network issues, etc.\n *\n * Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n * to `Infinity`. This means that by default, all calls will be made in parallel.\n *\n * Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n * means that by default, each call will be retried up to 6 times, with an\n * exponential backoff between each attempt.\n */\nexport class AsyncCaller {\n protected maxConcurrency: AsyncCallerParams[\"maxConcurrency\"];\n\n protected maxRetries: AsyncCallerParams[\"maxRetries\"];\n\n protected onFailedAttempt: AsyncCallerParams[\"onFailedAttempt\"];\n\n private queue: (typeof import(\"p-queue\"))[\"default\"][\"prototype\"];\n\n constructor(params: AsyncCallerParams) {\n this.maxConcurrency = params.maxConcurrency ?? Infinity;\n this.maxRetries = params.maxRetries ?? 6;\n this.onFailedAttempt =\n params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\n const PQueue = (\n \"default\" in PQueueMod ? PQueueMod.default : PQueueMod\n ) as typeof PQueueMod;\n this.queue = new PQueue({ concurrency: this.maxConcurrency });\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n async call<A extends any[], T extends (...args: A) => Promise<any>>(\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n return this.queue.add(\n () =>\n pRetry(\n () =>\n callable(...args).catch((error) => {\n // oxlint-disable-next-line no-instanceof/no-instanceof\n if (error instanceof Error) {\n throw error;\n } else {\n throw new Error(error);\n }\n }),\n {\n onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n retries: this.maxRetries,\n randomize: true,\n // If needed we can change some of the defaults here,\n // but they're quite sensible.\n }\n ),\n { throwOnTimeout: true }\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>(\n options: AsyncCallerCallOptions,\n callable: T,\n ...args: Parameters<T>\n ): Promise<Awaited<ReturnType<T>>> {\n // Note this doesn't cancel the underlying request,\n // when available prefer to use the signal option of the underlying call\n if (options.signal) {\n let listener: (() => void) | undefined;\n return Promise.race([\n this.call<A, T>(callable, ...args),\n new Promise<never>((_, reject) => {\n listener = () => {\n reject(getAbortSignalError(options.signal));\n };\n options.signal?.addEventListener(\"abort\", listener, { once: true });\n }),\n ]).finally(() => {\n if (options.signal && listener) {\n options.signal.removeEventListener(\"abort\", listener);\n }\n });\n }\n return this.call<A, T>(callable, ...args);\n }\n\n fetch(...args: Parameters<typeof fetch>): ReturnType<typeof fetch> {\n return this.call(() =>\n fetch(...args).then((res) => (res.ok ? res : Promise.reject(res)))\n );\n }\n}\n"],"mappings":";;;;;;AAKA,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;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AAM,UAEd,aAEI,SAAS,GAAG,KAAK,CAAC,OAAO,UAAU;AAEjC,OAAI,iBAAiB,MACnB,OAAM;OAEN,OAAM,IAAI,MAAM,MAAM;IAExB,EACJ;GACE,kBAAkB,EAAE,YAAY,KAAK,kBAAkB,MAAM;GAC7D,SAAS,KAAK;GACd,WAAW;GAGZ,CACF,EACH,EAAE,gBAAgB,MAAM,CACzB;;CAIH,gBACE,SACA,UACA,GAAG,MAC8B;AAGjC,MAAI,QAAQ,QAAQ;GAClB,IAAI;AACJ,UAAO,QAAQ,KAAK,CAClB,KAAK,KAAW,UAAU,GAAG,KAAK,EAClC,IAAI,SAAgB,GAAG,WAAW;AAChC,qBAAiB;AACf,YAAO,oBAAoB,QAAQ,OAAO,CAAC;;AAE7C,YAAQ,QAAQ,iBAAiB,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC;KACnE,CACH,CAAC,CAAC,cAAc;AACf,QAAI,QAAQ,UAAU,SACpB,SAAQ,OAAO,oBAAoB,SAAS,SAAS;KAEvD;;AAEJ,SAAO,KAAK,KAAW,UAAU,GAAG,KAAK;;CAG3C,MAAM,GAAG,MAA0D;AACjE,SAAO,KAAK,WACV,MAAM,GAAG,KAAK,CAAC,MAAM,QAAS,IAAI,KAAK,MAAM,QAAQ,OAAO,IAAI,CAAE,CACnE"}
@@ -38,13 +38,6 @@ async function getBytes(stream, onChunk) {
38
38
  ].join("\n"));
39
39
  }
40
40
  }
41
- var ControlChars = /* @__PURE__ */ function(ControlChars) {
42
- ControlChars[ControlChars["NewLine"] = 10] = "NewLine";
43
- ControlChars[ControlChars["CarriageReturn"] = 13] = "CarriageReturn";
44
- ControlChars[ControlChars["Space"] = 32] = "Space";
45
- ControlChars[ControlChars["Colon"] = 58] = "Colon";
46
- return ControlChars;
47
- }(ControlChars || {});
48
41
  /**
49
42
  * Parses arbitary byte chunks into EventSource line buffers.
50
43
  * Each line should be of the format "field: value" and ends with \r, \n, or \r\n.
@@ -70,16 +63,16 @@ function getLines(onLine) {
70
63
  let lineStart = 0;
71
64
  while (position < bufLength) {
72
65
  if (discardTrailingNewline) {
73
- if (buffer[position] === ControlChars.NewLine) lineStart = ++position;
66
+ if (buffer[position] === 10) lineStart = ++position;
74
67
  discardTrailingNewline = false;
75
68
  }
76
69
  let lineEnd = -1;
77
70
  for (; position < bufLength && lineEnd === -1; ++position) switch (buffer[position]) {
78
- case ControlChars.Colon:
71
+ case 58:
79
72
  if (fieldLength === -1) fieldLength = position - lineStart;
80
73
  break;
81
- case ControlChars.CarriageReturn: discardTrailingNewline = true;
82
- case ControlChars.NewLine:
74
+ case 13: discardTrailingNewline = true;
75
+ case 10:
83
76
  lineEnd = position;
84
77
  break;
85
78
  }
@@ -118,7 +111,7 @@ function getMessages(onMessage, onId, onRetry) {
118
111
  message = newMessage();
119
112
  } else if (fieldLength > 0) {
120
113
  const field = decoder.decode(line.subarray(0, fieldLength));
121
- const valueOffset = fieldLength + (line[fieldLength + 1] === ControlChars.Space ? 2 : 1);
114
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 ? 2 : 1);
122
115
  const value = decoder.decode(line.subarray(valueOffset));
123
116
  switch (field) {
124
117
  case "data":
@@ -1 +1 @@
1
- {"version":3,"file":"event_source_parse.cjs","names":["IterableReadableStream"],"sources":["../../src/utils/event_source_parse.ts"],"sourcesContent":["/* oxlint-disable prefer-template */\n/* oxlint-disable default-case */\n// Adapted from https://github.com/gfortaine/fetch-event-source/blob/main/src/parse.ts\n// due to a packaging issue in the original.\n// MIT License\nimport { IterableReadableStream } from \"./stream.js\";\n\nexport const EventStreamContentType = \"text/event-stream\";\n\n/**\n * Represents a message sent in an event stream\n * https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format\n */\nexport interface EventSourceMessage {\n /** The event ID to set the EventSource object's last event ID value. */\n id: string;\n /** A string identifying the type of event described. */\n event: string;\n /** The event data */\n data: string;\n /** The reconnection interval (in milliseconds) to wait before retrying the connection */\n retry?: number;\n}\n\n/**\n * Converts a ReadableStream into a callback pattern.\n * @param stream The input ReadableStream.\n * @param onChunk A function that will be called on each new byte chunk in the stream.\n * @returns {Promise<void>} A promise that will be resolved when the stream closes.\n */\nexport async function getBytes(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n stream: ReadableStream<Uint8Array> | AsyncIterable<any>,\n onChunk: (arr: Uint8Array, flush?: boolean) => void\n) {\n // TODO: Use Async iteration for both cases?\n // oxlint-disable-next-line no-instanceof/no-instanceof\n if (stream instanceof ReadableStream) {\n const reader = stream.getReader();\n // CHANGED: Introduced a \"flush\" mechanism to process potential pending messages when the stream ends.\n // This change is essential to ensure that we capture every last piece of information from streams,\n // such as those from Azure OpenAI, which may not terminate with a blank line. Without this\n // mechanism, we risk ignoring a possibly significant last message.\n // See https://github.com/langchain-ai/langchainjs/issues/1299 for details.\n while (true) {\n const result = await reader.read();\n if (result.done) {\n onChunk(new Uint8Array(), true);\n break;\n }\n onChunk(result.value);\n }\n } else {\n try {\n // Handle Node.js Readable streams with async iteration\n for await (const chunk of stream) {\n onChunk(new Uint8Array(chunk));\n }\n onChunk(new Uint8Array(), true);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n throw new Error(\n [\n \"Parsing event source stream failed.\",\n \"Ensure your implementation of fetch returns a web or Node readable stream.\",\n `Error: ${e.message}`,\n ].join(\"\\n\")\n );\n }\n }\n}\n\nconst enum ControlChars {\n NewLine = 10,\n CarriageReturn = 13,\n Space = 32,\n Colon = 58,\n}\n\n/**\n * Parses arbitary byte chunks into EventSource line buffers.\n * Each line should be of the format \"field: value\" and ends with \\r, \\n, or \\r\\n.\n * @param onLine A function that will be called on each new EventSource line.\n * @returns A function that should be called for each incoming byte chunk.\n */\nexport function getLines(\n onLine: (line: Uint8Array, fieldLength: number, flush?: boolean) => void\n) {\n let buffer: Uint8Array | undefined;\n let position: number; // current read position\n let fieldLength: number; // length of the `field` portion of the line\n let discardTrailingNewline = false;\n\n // return a function that can process each incoming byte chunk:\n return function onChunk(arr: Uint8Array, flush?: boolean) {\n if (flush) {\n onLine(arr, 0, true);\n return;\n }\n\n if (buffer === undefined) {\n buffer = arr;\n position = 0;\n fieldLength = -1;\n } else {\n // we're still parsing the old line. Append the new bytes into buffer:\n buffer = concat(buffer, arr);\n }\n\n const bufLength = buffer.length;\n let lineStart = 0; // index where the current line starts\n while (position < bufLength) {\n if (discardTrailingNewline) {\n if (buffer[position] === ControlChars.NewLine) {\n lineStart = ++position; // skip to next char\n }\n\n discardTrailingNewline = false;\n }\n\n // start looking forward till the end of line:\n let lineEnd = -1; // index of the \\r or \\n char\n for (; position < bufLength && lineEnd === -1; ++position) {\n switch (buffer[position]) {\n case ControlChars.Colon:\n if (fieldLength === -1) {\n // first colon in line\n fieldLength = position - lineStart;\n }\n break;\n // @ts-expect-error \\r case below should fallthrough to \\n:\n case ControlChars.CarriageReturn:\n discardTrailingNewline = true;\n // oxlint-disable-next-line no-fallthrough\n case ControlChars.NewLine:\n lineEnd = position;\n break;\n }\n }\n\n if (lineEnd === -1) {\n // We reached the end of the buffer but the line hasn't ended.\n // Wait for the next arr and then continue parsing:\n break;\n }\n\n // we've reached the line end, send it out:\n onLine(buffer.subarray(lineStart, lineEnd), fieldLength);\n lineStart = position; // we're now on the next line\n fieldLength = -1;\n }\n\n if (lineStart === bufLength) {\n buffer = undefined; // we've finished reading it\n } else if (lineStart !== 0) {\n // Create a new view into buffer beginning at lineStart so we don't\n // need to copy over the previous lines when we get the new arr:\n buffer = buffer.subarray(lineStart);\n position -= lineStart;\n }\n };\n}\n\n/**\n * Parses line buffers into EventSourceMessages.\n * @param onId A function that will be called on each `id` field.\n * @param onRetry A function that will be called on each `retry` field.\n * @param onMessage A function that will be called on each message.\n * @returns A function that should be called for each incoming line buffer.\n */\nexport function getMessages(\n onMessage?: (msg: EventSourceMessage) => void,\n onId?: (id: string) => void,\n onRetry?: (retry: number) => void\n) {\n let message = newMessage();\n const decoder = new TextDecoder();\n\n // return a function that can process each incoming line buffer:\n return function onLine(\n line: Uint8Array,\n fieldLength: number,\n flush?: boolean\n ) {\n if (flush) {\n if (!isEmpty(message)) {\n onMessage?.(message);\n message = newMessage();\n }\n return;\n }\n\n if (line.length === 0) {\n // empty line denotes end of message. Trigger the callback and start a new message:\n onMessage?.(message);\n message = newMessage();\n } else if (fieldLength > 0) {\n // exclude comments and lines with no values\n // line is of format \"<field>:<value>\" or \"<field>: <value>\"\n // https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n const field = decoder.decode(line.subarray(0, fieldLength));\n const valueOffset =\n fieldLength + (line[fieldLength + 1] === ControlChars.Space ? 2 : 1);\n const value = decoder.decode(line.subarray(valueOffset));\n\n switch (field) {\n case \"data\":\n // if this message already has data, append the new value to the old.\n // otherwise, just set to the new value:\n message.data = message.data ? message.data + \"\\n\" + value : value; // otherwise,\n break;\n case \"event\":\n message.event = value;\n break;\n case \"id\":\n onId?.((message.id = value));\n break;\n case \"retry\": {\n const retry = parseInt(value, 10);\n if (!Number.isNaN(retry)) {\n // per spec, ignore non-integers\n onRetry?.((message.retry = retry));\n }\n break;\n }\n }\n }\n };\n}\n\nfunction concat(a: Uint8Array, b: Uint8Array) {\n const res = new Uint8Array(a.length + b.length);\n res.set(a);\n res.set(b, a.length);\n return res;\n}\n\nfunction newMessage(): EventSourceMessage {\n // data, event, and id must be initialized to empty strings:\n // https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n // retry should be initialized to undefined so we return a consistent shape\n // to the js engine all the time: https://mathiasbynens.be/notes/shapes-ics#takeaways\n return {\n data: \"\",\n event: \"\",\n id: \"\",\n retry: undefined,\n };\n}\n\nexport function convertEventStreamToIterableReadableDataStream(\n stream: ReadableStream,\n onMetadataEvent?: (e: unknown) => unknown\n) {\n const dataStream = new ReadableStream({\n async start(controller) {\n const enqueueLine = getMessages((msg) => {\n if (msg.event === \"error\") {\n throw new Error(msg.data ?? \"Unspecified event streaming error.\");\n } else if (msg.event === \"metadata\") {\n onMetadataEvent?.(msg);\n } else {\n if (msg.data) controller.enqueue(msg.data);\n }\n });\n const onLine = (\n line: Uint8Array,\n fieldLength: number,\n flush?: boolean\n ) => {\n enqueueLine(line, fieldLength, flush);\n if (flush) controller.close();\n };\n await getBytes(stream, getLines(onLine));\n },\n });\n return IterableReadableStream.fromReadableStream(dataStream);\n}\n\nfunction isEmpty(message: EventSourceMessage): boolean {\n return (\n message.data === \"\" &&\n message.event === \"\" &&\n message.id === \"\" &&\n message.retry === undefined\n );\n}\n"],"mappings":";;;;;;;;;;;AAOA,MAAa,yBAAyB;;;;;;;AAuBtC,eAAsB,SAEpB,QACA,SACA;AAGA,KAAI,kBAAkB,gBAAgB;EACpC,MAAM,SAAS,OAAO,WAAW;AAMjC,SAAO,MAAM;GACX,MAAM,SAAS,MAAM,OAAO,MAAM;AAClC,OAAI,OAAO,MAAM;AACf,YAAQ,IAAI,YAAY,EAAE,KAAK;AAC/B;;AAEF,WAAQ,OAAO,MAAM;;OAGvB,KAAI;AAEF,aAAW,MAAM,SAAS,OACxB,SAAQ,IAAI,WAAW,MAAM,CAAC;AAEhC,UAAQ,IAAI,YAAY,EAAE,KAAK;UAExB,GAAQ;AACf,QAAM,IAAI,MACR;GACE;GACA;GACA,UAAU,EAAE;GACb,CAAC,KAAK,KAAK,CACb;;;AAKP,IAAW,eAAX,yBAAA,cAAA;AACE,cAAA,aAAA,aAAA,MAAA;AACA,cAAA,aAAA,oBAAA,MAAA;AACA,cAAA,aAAA,WAAA,MAAA;AACA,cAAA,aAAA,WAAA,MAAA;;EAJS,gBAAA,EAAA,CAKV;;;;;;;AAQD,SAAgB,SACd,QACA;CACA,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,yBAAyB;AAG7B,QAAO,SAAS,QAAQ,KAAiB,OAAiB;AACxD,MAAI,OAAO;AACT,UAAO,KAAK,GAAG,KAAK;AACpB;;AAGF,MAAI,WAAW,KAAA,GAAW;AACxB,YAAS;AACT,cAAW;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,aAAQ,QAAQ;AAChB;IACF,KAAK;AACH,YAAQ,QAAQ,KAAK,MAAO;AAC5B;IACF,KAAK,SAAS;KACZ,MAAM,QAAQ,SAAS,OAAO,GAAG;AACjC,SAAI,CAAC,OAAO,MAAM,MAAM,CAEtB,WAAW,QAAQ,QAAQ,MAAO;AAEpC;;;;;;AAOV,SAAS,OAAO,GAAe,GAAe;CAC5C,MAAM,MAAM,IAAI,WAAW,EAAE,SAAS,EAAE,OAAO;AAC/C,KAAI,IAAI,EAAE;AACV,KAAI,IAAI,GAAG,EAAE,OAAO;AACpB,QAAO;;AAGT,SAAS,aAAiC;AAKxC,QAAO;EACL,MAAM;EACN,OAAO;EACP,IAAI;EACJ,OAAO,KAAA;EACR;;AAGH,SAAgB,+CACd,QACA,iBACA;CACA,MAAM,aAAa,IAAI,eAAe,EACpC,MAAM,MAAM,YAAY;EACtB,MAAM,cAAc,aAAa,QAAQ;AACvC,OAAI,IAAI,UAAU,QAChB,OAAM,IAAI,MAAM,IAAI,QAAQ,qCAAqC;YACxD,IAAI,UAAU,WACvB,mBAAkB,IAAI;YAElB,IAAI,KAAM,YAAW,QAAQ,IAAI,KAAK;IAE5C;EACF,MAAM,UACJ,MACA,aACA,UACG;AACH,eAAY,MAAM,aAAa,MAAM;AACrC,OAAI,MAAO,YAAW,OAAO;;AAE/B,QAAM,SAAS,QAAQ,SAAS,OAAO,CAAC;IAE3C,CAAC;AACF,QAAOA,qBAAAA,uBAAuB,mBAAmB,WAAW;;AAG9D,SAAS,QAAQ,SAAsC;AACrD,QACE,QAAQ,SAAS,MACjB,QAAQ,UAAU,MAClB,QAAQ,OAAO,MACf,QAAQ,UAAU,KAAA"}
1
+ {"version":3,"file":"event_source_parse.cjs","names":["IterableReadableStream"],"sources":["../../src/utils/event_source_parse.ts"],"sourcesContent":["/* oxlint-disable prefer-template */\n/* oxlint-disable default-case */\n// Adapted from https://github.com/gfortaine/fetch-event-source/blob/main/src/parse.ts\n// due to a packaging issue in the original.\n// MIT License\nimport { IterableReadableStream } from \"./stream.js\";\n\nexport const EventStreamContentType = \"text/event-stream\";\n\n/**\n * Represents a message sent in an event stream\n * https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format\n */\nexport interface EventSourceMessage {\n /** The event ID to set the EventSource object's last event ID value. */\n id: string;\n /** A string identifying the type of event described. */\n event: string;\n /** The event data */\n data: string;\n /** The reconnection interval (in milliseconds) to wait before retrying the connection */\n retry?: number;\n}\n\n/**\n * Converts a ReadableStream into a callback pattern.\n * @param stream The input ReadableStream.\n * @param onChunk A function that will be called on each new byte chunk in the stream.\n * @returns {Promise<void>} A promise that will be resolved when the stream closes.\n */\nexport async function getBytes(\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n stream: ReadableStream<Uint8Array> | AsyncIterable<any>,\n onChunk: (arr: Uint8Array, flush?: boolean) => void\n) {\n // TODO: Use Async iteration for both cases?\n // oxlint-disable-next-line no-instanceof/no-instanceof\n if (stream instanceof ReadableStream) {\n const reader = stream.getReader();\n // CHANGED: Introduced a \"flush\" mechanism to process potential pending messages when the stream ends.\n // This change is essential to ensure that we capture every last piece of information from streams,\n // such as those from Azure OpenAI, which may not terminate with a blank line. Without this\n // mechanism, we risk ignoring a possibly significant last message.\n // See https://github.com/langchain-ai/langchainjs/issues/1299 for details.\n while (true) {\n const result = await reader.read();\n if (result.done) {\n onChunk(new Uint8Array(), true);\n break;\n }\n onChunk(result.value);\n }\n } else {\n try {\n // Handle Node.js Readable streams with async iteration\n for await (const chunk of stream) {\n onChunk(new Uint8Array(chunk));\n }\n onChunk(new Uint8Array(), true);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n throw new Error(\n [\n \"Parsing event source stream failed.\",\n \"Ensure your implementation of fetch returns a web or Node readable stream.\",\n `Error: ${e.message}`,\n ].join(\"\\n\")\n );\n }\n }\n}\n\nconst enum ControlChars {\n NewLine = 10,\n CarriageReturn = 13,\n Space = 32,\n Colon = 58,\n}\n\n/**\n * Parses arbitary byte chunks into EventSource line buffers.\n * Each line should be of the format \"field: value\" and ends with \\r, \\n, or \\r\\n.\n * @param onLine A function that will be called on each new EventSource line.\n * @returns A function that should be called for each incoming byte chunk.\n */\nexport function getLines(\n onLine: (line: Uint8Array, fieldLength: number, flush?: boolean) => void\n) {\n let buffer: Uint8Array | undefined;\n let position: number; // current read position\n let fieldLength: number; // length of the `field` portion of the line\n let discardTrailingNewline = false;\n\n // return a function that can process each incoming byte chunk:\n return function onChunk(arr: Uint8Array, flush?: boolean) {\n if (flush) {\n onLine(arr, 0, true);\n return;\n }\n\n if (buffer === undefined) {\n buffer = arr;\n position = 0;\n fieldLength = -1;\n } else {\n // we're still parsing the old line. Append the new bytes into buffer:\n buffer = concat(buffer, arr);\n }\n\n const bufLength = buffer.length;\n let lineStart = 0; // index where the current line starts\n while (position < bufLength) {\n if (discardTrailingNewline) {\n if (buffer[position] === ControlChars.NewLine) {\n lineStart = ++position; // skip to next char\n }\n\n discardTrailingNewline = false;\n }\n\n // start looking forward till the end of line:\n let lineEnd = -1; // index of the \\r or \\n char\n for (; position < bufLength && lineEnd === -1; ++position) {\n switch (buffer[position]) {\n case ControlChars.Colon:\n if (fieldLength === -1) {\n // first colon in line\n fieldLength = position - lineStart;\n }\n break;\n // @ts-expect-error \\r case below should fallthrough to \\n:\n case ControlChars.CarriageReturn:\n discardTrailingNewline = true;\n // oxlint-disable-next-line no-fallthrough\n case ControlChars.NewLine:\n lineEnd = position;\n break;\n }\n }\n\n if (lineEnd === -1) {\n // We reached the end of the buffer but the line hasn't ended.\n // Wait for the next arr and then continue parsing:\n break;\n }\n\n // we've reached the line end, send it out:\n onLine(buffer.subarray(lineStart, lineEnd), fieldLength);\n lineStart = position; // we're now on the next line\n fieldLength = -1;\n }\n\n if (lineStart === bufLength) {\n buffer = undefined; // we've finished reading it\n } else if (lineStart !== 0) {\n // Create a new view into buffer beginning at lineStart so we don't\n // need to copy over the previous lines when we get the new arr:\n buffer = buffer.subarray(lineStart);\n position -= lineStart;\n }\n };\n}\n\n/**\n * Parses line buffers into EventSourceMessages.\n * @param onId A function that will be called on each `id` field.\n * @param onRetry A function that will be called on each `retry` field.\n * @param onMessage A function that will be called on each message.\n * @returns A function that should be called for each incoming line buffer.\n */\nexport function getMessages(\n onMessage?: (msg: EventSourceMessage) => void,\n onId?: (id: string) => void,\n onRetry?: (retry: number) => void\n) {\n let message = newMessage();\n const decoder = new TextDecoder();\n\n // return a function that can process each incoming line buffer:\n return function onLine(\n line: Uint8Array,\n fieldLength: number,\n flush?: boolean\n ) {\n if (flush) {\n if (!isEmpty(message)) {\n onMessage?.(message);\n message = newMessage();\n }\n return;\n }\n\n if (line.length === 0) {\n // empty line denotes end of message. Trigger the callback and start a new message:\n onMessage?.(message);\n message = newMessage();\n } else if (fieldLength > 0) {\n // exclude comments and lines with no values\n // line is of format \"<field>:<value>\" or \"<field>: <value>\"\n // https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n const field = decoder.decode(line.subarray(0, fieldLength));\n const valueOffset =\n fieldLength + (line[fieldLength + 1] === ControlChars.Space ? 2 : 1);\n const value = decoder.decode(line.subarray(valueOffset));\n\n switch (field) {\n case \"data\":\n // if this message already has data, append the new value to the old.\n // otherwise, just set to the new value:\n message.data = message.data ? message.data + \"\\n\" + value : value; // otherwise,\n break;\n case \"event\":\n message.event = value;\n break;\n case \"id\":\n onId?.((message.id = value));\n break;\n case \"retry\": {\n const retry = parseInt(value, 10);\n if (!Number.isNaN(retry)) {\n // per spec, ignore non-integers\n onRetry?.((message.retry = retry));\n }\n break;\n }\n }\n }\n };\n}\n\nfunction concat(a: Uint8Array, b: Uint8Array) {\n const res = new Uint8Array(a.length + b.length);\n res.set(a);\n res.set(b, a.length);\n return res;\n}\n\nfunction newMessage(): EventSourceMessage {\n // data, event, and id must be initialized to empty strings:\n // https://html.spec.whatwg.org/multipage/server-sent-events.html#event-stream-interpretation\n // retry should be initialized to undefined so we return a consistent shape\n // to the js engine all the time: https://mathiasbynens.be/notes/shapes-ics#takeaways\n return {\n data: \"\",\n event: \"\",\n id: \"\",\n retry: undefined,\n };\n}\n\nexport function convertEventStreamToIterableReadableDataStream(\n stream: ReadableStream,\n onMetadataEvent?: (e: unknown) => unknown\n) {\n const dataStream = new ReadableStream({\n async start(controller) {\n const enqueueLine = getMessages((msg) => {\n if (msg.event === \"error\") {\n throw new Error(msg.data ?? \"Unspecified event streaming error.\");\n } else if (msg.event === \"metadata\") {\n onMetadataEvent?.(msg);\n } else {\n if (msg.data) controller.enqueue(msg.data);\n }\n });\n const onLine = (\n line: Uint8Array,\n fieldLength: number,\n flush?: boolean\n ) => {\n enqueueLine(line, fieldLength, flush);\n if (flush) controller.close();\n };\n await getBytes(stream, getLines(onLine));\n },\n });\n return IterableReadableStream.fromReadableStream(dataStream);\n}\n\nfunction isEmpty(message: EventSourceMessage): boolean {\n return (\n message.data === \"\" &&\n message.event === \"\" &&\n message.id === \"\" &&\n message.retry === undefined\n );\n}\n"],"mappings":";;;;;;;;;;;AAOA,MAAa,yBAAyB;;;;;;;AAuBtC,eAAsB,SAEpB,QACA,SACA;AAGA,KAAI,kBAAkB,gBAAgB;EACpC,MAAM,SAAS,OAAO,WAAW;AAMjC,SAAO,MAAM;GACX,MAAM,SAAS,MAAM,OAAO,MAAM;AAClC,OAAI,OAAO,MAAM;AACf,YAAQ,IAAI,YAAY,EAAE,KAAK;AAC/B;;AAEF,WAAQ,OAAO,MAAM;;OAGvB,KAAI;AAEF,aAAW,MAAM,SAAS,OACxB,SAAQ,IAAI,WAAW,MAAM,CAAC;AAEhC,UAAQ,IAAI,YAAY,EAAE,KAAK;UAExB,GAAQ;AACf,QAAM,IAAI,MACR;GACE;GACA;GACA,UAAU,EAAE;GACb,CAAC,KAAK,KAAK,CACb;;;;;;;;;AAkBP,SAAgB,SACd,QACA;CACA,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI,yBAAyB;AAG7B,QAAO,SAAS,QA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ControlChars) {
41
- ControlChars[ControlChars["NewLine"] = 10] = "NewLine";
42
- ControlChars[ControlChars["CarriageReturn"] = 13] = "CarriageReturn";
43
- ControlChars[ControlChars["Space"] = 32] = "Space";
44
- ControlChars[ControlChars["Colon"] = 58] = "Colon";
45
- return ControlChars;
46
- }(ControlChars || {});
47
40
  /**
48
41
  * Parses arbitary byte chunks into EventSource line buffers.
49
42
  * Each line should be of the format "field: value" and ends with \r, \n, or \r\n.
@@ -69,16 +62,16 @@ function getLines(onLine) {
69
62
  let lineStart = 0;
70
63
  while (position < bufLength) {
71
64
  if (discardTrailingNewline) {
72
- if (buffer[position] === ControlChars.NewLine) lineStart = ++position;
65
+ if (buffer[position] === 10) lineStart = ++position;
73
66
  discardTrailingNewline = false;
74
67
  }
75
68
  let lineEnd = -1;
76
69
  for (; position < bufLength && lineEnd === -1; ++position) switch (buffer[position]) {
77
- case ControlChars.Colon:
70
+ case 58:
78
71
  if (fieldLength === -1) fieldLength = position - lineStart;
79
72
  break;
80
- case ControlChars.CarriageReturn: discardTrailingNewline = true;
81
- case ControlChars.NewLine:
73
+ case 13: discardTrailingNewline = true;
74
+ case 10:
82
75
  lineEnd = position;
83
76
  break;
84
77
  }
@@ -117,7 +110,7 @@ function getMessages(onMessage, onId, onRetry) {
117
110
  message = newMessage();
118
111
  } else if (fieldLength > 0) {
119
112
  const field = decoder.decode(line.subarray(0, fieldLength));
120
- const valueOffset = fieldLength + (line[fieldLength + 1] === ControlChars.Space ? 2 : 1);
113
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 ? 2 : 1);
121
114
  const value = decoder.decode(line.subarray(valueOffset));
122
115
  switch (field) {
123
116
  case "data":