@langchain/core 1.1.4 → 1.1.5-dev-1765432861398

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 (706) hide show
  1. package/README.md +1 -1
  2. package/dist/agents.d.cts +0 -2
  3. package/dist/agents.d.cts.map +1 -0
  4. package/dist/agents.d.ts +0 -2
  5. package/dist/agents.d.ts.map +1 -0
  6. package/dist/caches/index.d.cts.map +1 -0
  7. package/dist/caches/index.d.ts.map +1 -0
  8. package/dist/callbacks/base.cjs +1 -1
  9. package/dist/callbacks/base.cjs.map +1 -1
  10. package/dist/callbacks/base.d.cts +22 -60
  11. package/dist/callbacks/base.d.cts.map +1 -0
  12. package/dist/callbacks/base.d.ts +22 -60
  13. package/dist/callbacks/base.d.ts.map +1 -0
  14. package/dist/callbacks/base.js +1 -1
  15. package/dist/callbacks/base.js.map +1 -1
  16. package/dist/callbacks/dispatch/index.d.cts +1 -3
  17. package/dist/callbacks/dispatch/index.d.cts.map +1 -0
  18. package/dist/callbacks/dispatch/index.d.ts +1 -3
  19. package/dist/callbacks/dispatch/index.d.ts.map +1 -0
  20. package/dist/callbacks/dispatch/web.d.cts +1 -3
  21. package/dist/callbacks/dispatch/web.d.cts.map +1 -0
  22. package/dist/callbacks/dispatch/web.d.ts +1 -3
  23. package/dist/callbacks/dispatch/web.d.ts.map +1 -0
  24. package/dist/callbacks/manager.cjs +6 -6
  25. package/dist/callbacks/manager.cjs.map +1 -1
  26. package/dist/callbacks/manager.d.cts +2 -12
  27. package/dist/callbacks/manager.d.cts.map +1 -0
  28. package/dist/callbacks/manager.d.ts +2 -12
  29. package/dist/callbacks/manager.d.ts.map +1 -0
  30. package/dist/callbacks/manager.js +7 -7
  31. package/dist/callbacks/manager.js.map +1 -1
  32. package/dist/chat_history.d.cts +0 -1
  33. package/dist/chat_history.d.cts.map +1 -0
  34. package/dist/chat_history.d.ts +0 -1
  35. package/dist/chat_history.d.ts.map +1 -0
  36. package/dist/context.d.cts.map +1 -0
  37. package/dist/context.d.ts.map +1 -0
  38. package/dist/document_loaders/base.d.cts.map +1 -0
  39. package/dist/document_loaders/base.d.ts.map +1 -0
  40. package/dist/document_loaders/langsmith.d.cts +0 -3
  41. package/dist/document_loaders/langsmith.d.cts.map +1 -0
  42. package/dist/document_loaders/langsmith.d.ts +0 -3
  43. package/dist/document_loaders/langsmith.d.ts.map +1 -0
  44. package/dist/documents/document.d.cts +3 -12
  45. package/dist/documents/document.d.cts.map +1 -0
  46. package/dist/documents/document.d.ts +3 -12
  47. package/dist/documents/document.d.ts.map +1 -0
  48. package/dist/documents/transformers.d.cts.map +1 -0
  49. package/dist/documents/transformers.d.ts.map +1 -0
  50. package/dist/embeddings.d.cts.map +1 -0
  51. package/dist/embeddings.d.ts.map +1 -0
  52. package/dist/example_selectors/base.d.cts.map +1 -0
  53. package/dist/example_selectors/base.d.ts.map +1 -0
  54. package/dist/example_selectors/conditional.d.cts.map +1 -0
  55. package/dist/example_selectors/conditional.d.ts.map +1 -0
  56. package/dist/example_selectors/length_based.d.cts +1 -1
  57. package/dist/example_selectors/length_based.d.cts.map +1 -0
  58. package/dist/example_selectors/length_based.d.ts +1 -1
  59. package/dist/example_selectors/length_based.d.ts.map +1 -0
  60. package/dist/example_selectors/semantic_similarity.d.cts.map +1 -0
  61. package/dist/example_selectors/semantic_similarity.d.ts.map +1 -0
  62. package/dist/indexing/base.d.cts +0 -1
  63. package/dist/indexing/base.d.cts.map +1 -0
  64. package/dist/indexing/base.d.ts +0 -1
  65. package/dist/indexing/base.d.ts.map +1 -0
  66. package/dist/indexing/record_manager.d.cts +0 -1
  67. package/dist/indexing/record_manager.d.cts.map +1 -0
  68. package/dist/indexing/record_manager.d.ts +0 -1
  69. package/dist/indexing/record_manager.d.ts.map +1 -0
  70. package/dist/language_models/base.d.cts +8 -38
  71. package/dist/language_models/base.d.cts.map +1 -0
  72. package/dist/language_models/base.d.ts +8 -38
  73. package/dist/language_models/base.d.ts.map +1 -0
  74. package/dist/language_models/chat_models.d.cts +6 -33
  75. package/dist/language_models/chat_models.d.cts.map +1 -0
  76. package/dist/language_models/chat_models.d.ts +6 -33
  77. package/dist/language_models/chat_models.d.ts.map +1 -0
  78. package/dist/language_models/llms.d.cts +0 -6
  79. package/dist/language_models/llms.d.cts.map +1 -0
  80. package/dist/language_models/llms.d.ts +0 -6
  81. package/dist/language_models/llms.d.ts.map +1 -0
  82. package/dist/language_models/profile.d.cts.map +1 -0
  83. package/dist/language_models/profile.d.ts.map +1 -0
  84. package/dist/load/import_type.d.cts +0 -1
  85. package/dist/load/import_type.d.cts.map +1 -0
  86. package/dist/load/import_type.d.ts +0 -1
  87. package/dist/load/import_type.d.ts.map +1 -0
  88. package/dist/load/index.d.cts.map +1 -0
  89. package/dist/load/index.d.ts.map +1 -0
  90. package/dist/load/map_keys.d.cts +0 -1
  91. package/dist/load/map_keys.d.cts.map +1 -0
  92. package/dist/load/map_keys.d.ts +0 -1
  93. package/dist/load/map_keys.d.ts.map +1 -0
  94. package/dist/load/serializable.d.cts +0 -1
  95. package/dist/load/serializable.d.cts.map +1 -0
  96. package/dist/load/serializable.d.ts +0 -1
  97. package/dist/load/serializable.d.ts.map +1 -0
  98. package/dist/memory.d.cts +0 -3
  99. package/dist/memory.d.cts.map +1 -0
  100. package/dist/memory.d.ts +0 -3
  101. package/dist/memory.d.ts.map +1 -0
  102. package/dist/messages/ai.d.cts.map +1 -0
  103. package/dist/messages/ai.d.ts.map +1 -0
  104. package/dist/messages/base.d.cts +1 -13
  105. package/dist/messages/base.d.cts.map +1 -0
  106. package/dist/messages/base.d.ts +1 -13
  107. package/dist/messages/base.d.ts.map +1 -0
  108. package/dist/messages/chat.d.cts.map +1 -0
  109. package/dist/messages/chat.d.ts.map +1 -0
  110. package/dist/messages/content/base.d.cts.map +1 -0
  111. package/dist/messages/content/base.d.ts.map +1 -0
  112. package/dist/messages/content/data.d.cts +2 -7
  113. package/dist/messages/content/data.d.cts.map +1 -0
  114. package/dist/messages/content/data.d.ts +2 -7
  115. package/dist/messages/content/data.d.ts.map +1 -0
  116. package/dist/messages/content/index.d.cts +1 -4
  117. package/dist/messages/content/index.d.cts.map +1 -0
  118. package/dist/messages/content/index.d.ts +1 -4
  119. package/dist/messages/content/index.d.ts.map +1 -0
  120. package/dist/messages/content/multimodal.d.cts +0 -1
  121. package/dist/messages/content/multimodal.d.cts.map +1 -0
  122. package/dist/messages/content/multimodal.d.ts +0 -1
  123. package/dist/messages/content/multimodal.d.ts.map +1 -0
  124. package/dist/messages/content/tools.d.cts +0 -1
  125. package/dist/messages/content/tools.d.cts.map +1 -0
  126. package/dist/messages/content/tools.d.ts +0 -1
  127. package/dist/messages/content/tools.d.ts.map +1 -0
  128. package/dist/messages/format.d.cts.map +1 -0
  129. package/dist/messages/format.d.ts.map +1 -0
  130. package/dist/messages/function.d.cts.map +1 -0
  131. package/dist/messages/function.d.ts.map +1 -0
  132. package/dist/messages/human.d.cts.map +1 -0
  133. package/dist/messages/human.d.ts.map +1 -0
  134. package/dist/messages/message.d.cts.map +1 -0
  135. package/dist/messages/message.d.ts.map +1 -0
  136. package/dist/messages/metadata.d.cts.map +1 -0
  137. package/dist/messages/metadata.d.ts.map +1 -0
  138. package/dist/messages/modifier.d.cts.map +1 -0
  139. package/dist/messages/modifier.d.ts.map +1 -0
  140. package/dist/messages/system.d.cts.map +1 -0
  141. package/dist/messages/system.d.ts.map +1 -0
  142. package/dist/messages/tool.d.cts +2 -9
  143. package/dist/messages/tool.d.cts.map +1 -0
  144. package/dist/messages/tool.d.ts +2 -9
  145. package/dist/messages/tool.d.ts.map +1 -0
  146. package/dist/messages/transformers.d.cts +0 -3
  147. package/dist/messages/transformers.d.cts.map +1 -0
  148. package/dist/messages/transformers.d.ts +0 -3
  149. package/dist/messages/transformers.d.ts.map +1 -0
  150. package/dist/messages/utils.d.cts +2 -5
  151. package/dist/messages/utils.d.cts.map +1 -0
  152. package/dist/messages/utils.d.ts +2 -5
  153. package/dist/messages/utils.d.ts.map +1 -0
  154. package/dist/output_parsers/base.d.cts.map +1 -0
  155. package/dist/output_parsers/base.d.ts.map +1 -0
  156. package/dist/output_parsers/bytes.d.cts.map +1 -0
  157. package/dist/output_parsers/bytes.d.ts.map +1 -0
  158. package/dist/output_parsers/json.d.cts +1 -5
  159. package/dist/output_parsers/json.d.cts.map +1 -0
  160. package/dist/output_parsers/json.d.ts +1 -5
  161. package/dist/output_parsers/json.d.ts.map +1 -0
  162. package/dist/output_parsers/list.d.cts.map +1 -0
  163. package/dist/output_parsers/list.d.ts.map +1 -0
  164. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +2 -6
  165. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts.map +1 -0
  166. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +2 -6
  167. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts.map +1 -0
  168. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +10 -34
  169. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +1 -0
  170. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +10 -34
  171. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -0
  172. package/dist/output_parsers/string.d.cts.map +1 -0
  173. package/dist/output_parsers/string.d.ts.map +1 -0
  174. package/dist/output_parsers/structured.d.cts.map +1 -0
  175. package/dist/output_parsers/structured.d.ts.map +1 -0
  176. package/dist/output_parsers/transform.d.cts +0 -1
  177. package/dist/output_parsers/transform.d.cts.map +1 -0
  178. package/dist/output_parsers/transform.d.ts +0 -1
  179. package/dist/output_parsers/transform.d.ts.map +1 -0
  180. package/dist/output_parsers/xml.d.cts.map +1 -0
  181. package/dist/output_parsers/xml.d.ts.map +1 -0
  182. package/dist/outputs.d.cts +0 -6
  183. package/dist/outputs.d.cts.map +1 -0
  184. package/dist/outputs.d.ts +0 -6
  185. package/dist/outputs.d.ts.map +1 -0
  186. package/dist/prompt_values.d.cts.map +1 -0
  187. package/dist/prompt_values.d.ts.map +1 -0
  188. package/dist/prompts/base.d.cts +2 -10
  189. package/dist/prompts/base.d.cts.map +1 -0
  190. package/dist/prompts/base.d.ts +2 -10
  191. package/dist/prompts/base.d.ts.map +1 -0
  192. package/dist/prompts/chat.d.cts +13 -51
  193. package/dist/prompts/chat.d.cts.map +1 -0
  194. package/dist/prompts/chat.d.ts +13 -51
  195. package/dist/prompts/chat.d.ts.map +1 -0
  196. package/dist/prompts/dict.d.cts.map +1 -0
  197. package/dist/prompts/dict.d.ts.map +1 -0
  198. package/dist/prompts/few_shot.d.cts +1 -5
  199. package/dist/prompts/few_shot.d.cts.map +1 -0
  200. package/dist/prompts/few_shot.d.ts +1 -5
  201. package/dist/prompts/few_shot.d.ts.map +1 -0
  202. package/dist/prompts/image.d.cts +2 -10
  203. package/dist/prompts/image.d.cts.map +1 -0
  204. package/dist/prompts/image.d.ts +2 -10
  205. package/dist/prompts/image.d.ts.map +1 -0
  206. package/dist/prompts/pipeline.d.cts.map +1 -0
  207. package/dist/prompts/pipeline.d.ts.map +1 -0
  208. package/dist/prompts/prompt.d.cts +4 -15
  209. package/dist/prompts/prompt.d.cts.map +1 -0
  210. package/dist/prompts/prompt.d.ts +4 -16
  211. package/dist/prompts/prompt.d.ts.map +1 -0
  212. package/dist/prompts/serde.d.cts +0 -1
  213. package/dist/prompts/serde.d.cts.map +1 -0
  214. package/dist/prompts/serde.d.ts +0 -1
  215. package/dist/prompts/serde.d.ts.map +1 -0
  216. package/dist/prompts/string.d.cts +1 -5
  217. package/dist/prompts/string.d.cts.map +1 -0
  218. package/dist/prompts/string.d.ts +1 -5
  219. package/dist/prompts/string.d.ts.map +1 -0
  220. package/dist/prompts/structured.d.cts +3 -16
  221. package/dist/prompts/structured.d.cts.map +1 -0
  222. package/dist/prompts/structured.d.ts +3 -16
  223. package/dist/prompts/structured.d.ts.map +1 -0
  224. package/dist/prompts/template.d.cts.map +1 -0
  225. package/dist/prompts/template.d.ts.map +1 -0
  226. package/dist/retrievers/document_compressors/index.d.cts +0 -1
  227. package/dist/retrievers/document_compressors/index.d.cts.map +1 -0
  228. package/dist/retrievers/document_compressors/index.d.ts +0 -1
  229. package/dist/retrievers/document_compressors/index.d.ts.map +1 -0
  230. package/dist/retrievers/index.d.cts +2 -6
  231. package/dist/retrievers/index.d.cts.map +1 -0
  232. package/dist/retrievers/index.d.ts +2 -6
  233. package/dist/retrievers/index.d.ts.map +1 -0
  234. package/dist/runnables/base.d.cts +12 -64
  235. package/dist/runnables/base.d.cts.map +1 -0
  236. package/dist/runnables/base.d.ts +12 -64
  237. package/dist/runnables/base.d.ts.map +1 -0
  238. package/dist/runnables/branch.d.cts +0 -2
  239. package/dist/runnables/branch.d.cts.map +1 -0
  240. package/dist/runnables/branch.d.ts +0 -2
  241. package/dist/runnables/branch.d.ts.map +1 -0
  242. package/dist/runnables/config.cjs +15 -1
  243. package/dist/runnables/config.cjs.map +1 -1
  244. package/dist/runnables/config.d.cts +0 -1
  245. package/dist/runnables/config.d.cts.map +1 -0
  246. package/dist/runnables/config.d.ts +0 -1
  247. package/dist/runnables/config.d.ts.map +1 -0
  248. package/dist/runnables/config.js +15 -1
  249. package/dist/runnables/config.js.map +1 -1
  250. package/dist/runnables/graph.d.cts +1 -5
  251. package/dist/runnables/graph.d.cts.map +1 -0
  252. package/dist/runnables/graph.d.ts +1 -5
  253. package/dist/runnables/graph.d.ts.map +1 -0
  254. package/dist/runnables/history.d.cts +4 -12
  255. package/dist/runnables/history.d.cts.map +1 -0
  256. package/dist/runnables/history.d.ts +4 -12
  257. package/dist/runnables/history.d.ts.map +1 -0
  258. package/dist/runnables/passthrough.d.cts +0 -2
  259. package/dist/runnables/passthrough.d.cts.map +1 -0
  260. package/dist/runnables/passthrough.d.ts +0 -2
  261. package/dist/runnables/passthrough.d.ts.map +1 -0
  262. package/dist/runnables/router.d.cts +0 -1
  263. package/dist/runnables/router.d.cts.map +1 -0
  264. package/dist/runnables/router.d.ts +0 -1
  265. package/dist/runnables/router.d.ts.map +1 -0
  266. package/dist/runnables/types.d.cts +2 -9
  267. package/dist/runnables/types.d.cts.map +1 -0
  268. package/dist/runnables/types.d.ts +2 -9
  269. package/dist/runnables/types.d.ts.map +1 -0
  270. package/dist/singletons/async_local_storage/context.d.cts +0 -2
  271. package/dist/singletons/async_local_storage/context.d.cts.map +1 -0
  272. package/dist/singletons/async_local_storage/context.d.ts +0 -2
  273. package/dist/singletons/async_local_storage/context.d.ts.map +1 -0
  274. package/dist/singletons/async_local_storage/globals.d.cts +0 -1
  275. package/dist/singletons/async_local_storage/globals.d.cts.map +1 -0
  276. package/dist/singletons/async_local_storage/globals.d.ts +0 -1
  277. package/dist/singletons/async_local_storage/globals.d.ts.map +1 -0
  278. package/dist/singletons/async_local_storage/index.d.cts.map +1 -0
  279. package/dist/singletons/async_local_storage/index.d.ts.map +1 -0
  280. package/dist/singletons/callbacks.d.cts.map +1 -0
  281. package/dist/singletons/callbacks.d.ts.map +1 -0
  282. package/dist/stores.d.cts +0 -1
  283. package/dist/stores.d.cts.map +1 -0
  284. package/dist/stores.d.ts +0 -1
  285. package/dist/stores.d.ts.map +1 -0
  286. package/dist/structured_query/base.d.cts.map +1 -0
  287. package/dist/structured_query/base.d.ts.map +1 -0
  288. package/dist/structured_query/functional.d.cts.map +1 -0
  289. package/dist/structured_query/functional.d.ts.map +1 -0
  290. package/dist/structured_query/ir.d.cts.map +1 -0
  291. package/dist/structured_query/ir.d.ts.map +1 -0
  292. package/dist/structured_query/utils.d.cts +1 -4
  293. package/dist/structured_query/utils.d.cts.map +1 -0
  294. package/dist/structured_query/utils.d.ts +1 -4
  295. package/dist/structured_query/utils.d.ts.map +1 -0
  296. package/dist/tools/index.d.cts +1 -6
  297. package/dist/tools/index.d.cts.map +1 -0
  298. package/dist/tools/index.d.ts +1 -6
  299. package/dist/tools/index.d.ts.map +1 -0
  300. package/dist/tools/types.d.cts +3 -13
  301. package/dist/tools/types.d.cts.map +1 -0
  302. package/dist/tools/types.d.ts +3 -13
  303. package/dist/tools/types.d.ts.map +1 -0
  304. package/dist/tools/utils.d.cts.map +1 -0
  305. package/dist/tools/utils.d.ts.map +1 -0
  306. package/dist/tracers/base.d.cts +1 -20
  307. package/dist/tracers/base.d.cts.map +1 -0
  308. package/dist/tracers/base.d.ts +1 -20
  309. package/dist/tracers/base.d.ts.map +1 -0
  310. package/dist/tracers/console.d.cts +0 -2
  311. package/dist/tracers/console.d.cts.map +1 -0
  312. package/dist/tracers/console.d.ts +0 -2
  313. package/dist/tracers/console.d.ts.map +1 -0
  314. package/dist/tracers/event_stream.d.cts +0 -4
  315. package/dist/tracers/event_stream.d.cts.map +1 -0
  316. package/dist/tracers/event_stream.d.ts +0 -4
  317. package/dist/tracers/event_stream.d.ts.map +1 -0
  318. package/dist/tracers/log_stream.d.cts +0 -6
  319. package/dist/tracers/log_stream.d.cts.map +1 -0
  320. package/dist/tracers/log_stream.d.ts +0 -6
  321. package/dist/tracers/log_stream.d.ts.map +1 -0
  322. package/dist/tracers/run_collector.d.cts.map +1 -0
  323. package/dist/tracers/run_collector.d.ts.map +1 -0
  324. package/dist/tracers/tracer_langchain.d.cts.map +1 -0
  325. package/dist/tracers/tracer_langchain.d.ts.map +1 -0
  326. package/dist/types/_internal.d.cts +0 -3
  327. package/dist/types/_internal.d.cts.map +1 -0
  328. package/dist/types/_internal.d.ts +0 -3
  329. package/dist/types/_internal.d.ts.map +1 -0
  330. package/dist/types/type-utils.d.cts +0 -2
  331. package/dist/types/type-utils.d.cts.map +1 -0
  332. package/dist/types/type-utils.d.ts +0 -2
  333. package/dist/types/type-utils.d.ts.map +1 -0
  334. package/dist/utils/async_caller.d.cts +0 -3
  335. package/dist/utils/async_caller.d.cts.map +1 -0
  336. package/dist/utils/async_caller.d.ts +0 -3
  337. package/dist/utils/async_caller.d.ts.map +1 -0
  338. package/dist/utils/chunk_array.d.cts.map +1 -0
  339. package/dist/utils/chunk_array.d.ts.map +1 -0
  340. package/dist/utils/env.d.cts +0 -4
  341. package/dist/utils/env.d.cts.map +1 -0
  342. package/dist/utils/env.d.ts +0 -4
  343. package/dist/utils/env.d.ts.map +1 -0
  344. package/dist/utils/event_source_parse.d.cts +1 -4
  345. package/dist/utils/event_source_parse.d.cts.map +1 -0
  346. package/dist/utils/event_source_parse.d.ts +1 -4
  347. package/dist/utils/event_source_parse.d.ts.map +1 -0
  348. package/dist/utils/fast-json-patch/src/core.d.cts.map +1 -0
  349. package/dist/utils/fast-json-patch/src/core.d.ts.map +1 -0
  350. package/dist/utils/fast-json-patch/src/duplex.d.cts.map +1 -0
  351. package/dist/utils/fast-json-patch/src/duplex.d.ts.map +1 -0
  352. package/dist/utils/format.d.cts.map +1 -0
  353. package/dist/utils/format.d.ts.map +1 -0
  354. package/dist/utils/function_calling.d.cts +1 -3
  355. package/dist/utils/function_calling.d.cts.map +1 -0
  356. package/dist/utils/function_calling.d.ts +1 -3
  357. package/dist/utils/function_calling.d.ts.map +1 -0
  358. package/dist/utils/hash.d.cts.map +1 -0
  359. package/dist/utils/hash.d.ts.map +1 -0
  360. package/dist/utils/js-sha256/hash.d.cts.map +1 -0
  361. package/dist/utils/js-sha256/hash.d.ts.map +1 -0
  362. package/dist/utils/json.d.cts +0 -1
  363. package/dist/utils/json.d.cts.map +1 -0
  364. package/dist/utils/json.d.ts +0 -1
  365. package/dist/utils/json.d.ts.map +1 -0
  366. package/dist/utils/json_schema.d.cts.map +1 -0
  367. package/dist/utils/json_schema.d.ts.map +1 -0
  368. package/dist/utils/math.d.cts.map +1 -0
  369. package/dist/utils/math.d.ts.map +1 -0
  370. package/dist/utils/ml-distance/similarities.d.cts.map +1 -0
  371. package/dist/utils/ml-distance/similarities.d.ts.map +1 -0
  372. package/dist/utils/signal.d.cts.map +1 -0
  373. package/dist/utils/signal.d.ts.map +1 -0
  374. package/dist/utils/stream.d.cts +1 -13
  375. package/dist/utils/stream.d.cts.map +1 -0
  376. package/dist/utils/stream.d.ts +1 -13
  377. package/dist/utils/stream.d.ts.map +1 -0
  378. package/dist/utils/testing/chat_models.cjs +11 -5
  379. package/dist/utils/testing/chat_models.cjs.map +1 -1
  380. package/dist/utils/testing/chat_models.d.cts +11 -12
  381. package/dist/utils/testing/chat_models.d.cts.map +1 -0
  382. package/dist/utils/testing/chat_models.d.ts +11 -12
  383. package/dist/utils/testing/chat_models.d.ts.map +1 -0
  384. package/dist/utils/testing/chat_models.js +11 -5
  385. package/dist/utils/testing/chat_models.js.map +1 -1
  386. package/dist/utils/testing/embeddings.d.cts.map +1 -0
  387. package/dist/utils/testing/embeddings.d.ts.map +1 -0
  388. package/dist/utils/testing/llms.d.cts.map +1 -0
  389. package/dist/utils/testing/llms.d.ts.map +1 -0
  390. package/dist/utils/testing/message_history.d.cts.map +1 -0
  391. package/dist/utils/testing/message_history.d.ts.map +1 -0
  392. package/dist/utils/testing/output_parsers.d.cts.map +1 -0
  393. package/dist/utils/testing/output_parsers.d.ts.map +1 -0
  394. package/dist/utils/testing/retrievers.d.cts +1 -3
  395. package/dist/utils/testing/retrievers.d.cts.map +1 -0
  396. package/dist/utils/testing/retrievers.d.ts +1 -3
  397. package/dist/utils/testing/retrievers.d.ts.map +1 -0
  398. package/dist/utils/testing/runnables.d.cts.map +1 -0
  399. package/dist/utils/testing/runnables.d.ts.map +1 -0
  400. package/dist/utils/testing/tools.d.cts.map +1 -0
  401. package/dist/utils/testing/tools.d.ts.map +1 -0
  402. package/dist/utils/testing/tracers.d.cts.map +1 -0
  403. package/dist/utils/testing/tracers.d.ts.map +1 -0
  404. package/dist/utils/testing/vectorstores.d.cts +0 -1
  405. package/dist/utils/testing/vectorstores.d.cts.map +1 -0
  406. package/dist/utils/testing/vectorstores.d.ts +0 -1
  407. package/dist/utils/testing/vectorstores.d.ts.map +1 -0
  408. package/dist/utils/tiktoken.d.cts.map +1 -0
  409. package/dist/utils/tiktoken.d.ts.map +1 -0
  410. package/dist/utils/types/index.d.cts +0 -2
  411. package/dist/utils/types/index.d.cts.map +1 -0
  412. package/dist/utils/types/index.d.ts +0 -2
  413. package/dist/utils/types/index.d.ts.map +1 -0
  414. package/dist/utils/types/zod.d.cts +0 -3
  415. package/dist/utils/types/zod.d.cts.map +1 -0
  416. package/dist/utils/types/zod.d.ts +0 -3
  417. package/dist/utils/types/zod.d.ts.map +1 -0
  418. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -0
  419. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -0
  420. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -0
  421. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -0
  422. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -0
  423. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -0
  424. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -0
  425. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -0
  426. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -0
  427. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -0
  428. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -0
  429. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -0
  430. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -0
  431. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -0
  432. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -0
  433. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -0
  434. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -0
  435. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -0
  436. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -0
  437. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -0
  438. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -0
  439. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -0
  440. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -0
  441. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -0
  442. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -0
  443. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -0
  444. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -0
  445. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -0
  446. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -0
  447. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -0
  448. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -0
  449. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -0
  450. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -0
  451. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -0
  452. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -0
  453. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -0
  454. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -0
  455. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -0
  456. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -0
  457. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -0
  458. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -0
  459. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -0
  460. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -0
  461. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -0
  462. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -0
  463. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -0
  464. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -0
  465. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -0
  466. package/dist/vectorstores.d.cts +5 -17
  467. package/dist/vectorstores.d.cts.map +1 -0
  468. package/dist/vectorstores.d.ts +5 -17
  469. package/dist/vectorstores.d.ts.map +1 -0
  470. package/package.json +6 -5
  471. package/agents.cjs +0 -1
  472. package/agents.d.cts +0 -1
  473. package/agents.d.ts +0 -1
  474. package/agents.js +0 -1
  475. package/caches.cjs +0 -1
  476. package/caches.d.cts +0 -1
  477. package/caches.d.ts +0 -1
  478. package/caches.js +0 -1
  479. package/callbacks/base.cjs +0 -1
  480. package/callbacks/base.d.cts +0 -1
  481. package/callbacks/base.d.ts +0 -1
  482. package/callbacks/base.js +0 -1
  483. package/callbacks/dispatch/web.cjs +0 -1
  484. package/callbacks/dispatch/web.d.cts +0 -1
  485. package/callbacks/dispatch/web.d.ts +0 -1
  486. package/callbacks/dispatch/web.js +0 -1
  487. package/callbacks/dispatch.cjs +0 -1
  488. package/callbacks/dispatch.d.cts +0 -1
  489. package/callbacks/dispatch.d.ts +0 -1
  490. package/callbacks/dispatch.js +0 -1
  491. package/callbacks/manager.cjs +0 -1
  492. package/callbacks/manager.d.cts +0 -1
  493. package/callbacks/manager.d.ts +0 -1
  494. package/callbacks/manager.js +0 -1
  495. package/callbacks/promises.cjs +0 -1
  496. package/callbacks/promises.d.cts +0 -1
  497. package/callbacks/promises.d.ts +0 -1
  498. package/callbacks/promises.js +0 -1
  499. package/chat_history.cjs +0 -1
  500. package/chat_history.d.cts +0 -1
  501. package/chat_history.d.ts +0 -1
  502. package/chat_history.js +0 -1
  503. package/context.cjs +0 -1
  504. package/context.d.cts +0 -1
  505. package/context.d.ts +0 -1
  506. package/context.js +0 -1
  507. package/document_loaders/base.cjs +0 -1
  508. package/document_loaders/base.d.cts +0 -1
  509. package/document_loaders/base.d.ts +0 -1
  510. package/document_loaders/base.js +0 -1
  511. package/document_loaders/langsmith.cjs +0 -1
  512. package/document_loaders/langsmith.d.cts +0 -1
  513. package/document_loaders/langsmith.d.ts +0 -1
  514. package/document_loaders/langsmith.js +0 -1
  515. package/documents.cjs +0 -1
  516. package/documents.d.cts +0 -1
  517. package/documents.d.ts +0 -1
  518. package/documents.js +0 -1
  519. package/embeddings.cjs +0 -1
  520. package/embeddings.d.cts +0 -1
  521. package/embeddings.d.ts +0 -1
  522. package/embeddings.js +0 -1
  523. package/example_selectors.cjs +0 -1
  524. package/example_selectors.d.cts +0 -1
  525. package/example_selectors.d.ts +0 -1
  526. package/example_selectors.js +0 -1
  527. package/indexing.cjs +0 -1
  528. package/indexing.d.cts +0 -1
  529. package/indexing.d.ts +0 -1
  530. package/indexing.js +0 -1
  531. package/language_models/base.cjs +0 -1
  532. package/language_models/base.d.cts +0 -1
  533. package/language_models/base.d.ts +0 -1
  534. package/language_models/base.js +0 -1
  535. package/language_models/chat_models.cjs +0 -1
  536. package/language_models/chat_models.d.cts +0 -1
  537. package/language_models/chat_models.d.ts +0 -1
  538. package/language_models/chat_models.js +0 -1
  539. package/language_models/llms.cjs +0 -1
  540. package/language_models/llms.d.cts +0 -1
  541. package/language_models/llms.d.ts +0 -1
  542. package/language_models/llms.js +0 -1
  543. package/language_models/profile.cjs +0 -1
  544. package/language_models/profile.d.cts +0 -1
  545. package/language_models/profile.d.ts +0 -1
  546. package/language_models/profile.js +0 -1
  547. package/load/serializable.cjs +0 -1
  548. package/load/serializable.d.cts +0 -1
  549. package/load/serializable.d.ts +0 -1
  550. package/load/serializable.js +0 -1
  551. package/load.cjs +0 -1
  552. package/load.d.cts +0 -1
  553. package/load.d.ts +0 -1
  554. package/load.js +0 -1
  555. package/memory.cjs +0 -1
  556. package/memory.d.cts +0 -1
  557. package/memory.d.ts +0 -1
  558. package/memory.js +0 -1
  559. package/messages/tool.cjs +0 -1
  560. package/messages/tool.d.cts +0 -1
  561. package/messages/tool.d.ts +0 -1
  562. package/messages/tool.js +0 -1
  563. package/messages.cjs +0 -1
  564. package/messages.d.cts +0 -1
  565. package/messages.d.ts +0 -1
  566. package/messages.js +0 -1
  567. package/output_parsers/openai_functions.cjs +0 -1
  568. package/output_parsers/openai_functions.d.cts +0 -1
  569. package/output_parsers/openai_functions.d.ts +0 -1
  570. package/output_parsers/openai_functions.js +0 -1
  571. package/output_parsers/openai_tools.cjs +0 -1
  572. package/output_parsers/openai_tools.d.cts +0 -1
  573. package/output_parsers/openai_tools.d.ts +0 -1
  574. package/output_parsers/openai_tools.js +0 -1
  575. package/output_parsers.cjs +0 -1
  576. package/output_parsers.d.cts +0 -1
  577. package/output_parsers.d.ts +0 -1
  578. package/output_parsers.js +0 -1
  579. package/outputs.cjs +0 -1
  580. package/outputs.d.cts +0 -1
  581. package/outputs.d.ts +0 -1
  582. package/outputs.js +0 -1
  583. package/prompt_values.cjs +0 -1
  584. package/prompt_values.d.cts +0 -1
  585. package/prompt_values.d.ts +0 -1
  586. package/prompt_values.js +0 -1
  587. package/prompts.cjs +0 -1
  588. package/prompts.d.cts +0 -1
  589. package/prompts.d.ts +0 -1
  590. package/prompts.js +0 -1
  591. package/retrievers/document_compressors.cjs +0 -1
  592. package/retrievers/document_compressors.d.cts +0 -1
  593. package/retrievers/document_compressors.d.ts +0 -1
  594. package/retrievers/document_compressors.js +0 -1
  595. package/retrievers.cjs +0 -1
  596. package/retrievers.d.cts +0 -1
  597. package/retrievers.d.ts +0 -1
  598. package/retrievers.js +0 -1
  599. package/runnables/graph.cjs +0 -1
  600. package/runnables/graph.d.cts +0 -1
  601. package/runnables/graph.d.ts +0 -1
  602. package/runnables/graph.js +0 -1
  603. package/runnables.cjs +0 -1
  604. package/runnables.d.cts +0 -1
  605. package/runnables.d.ts +0 -1
  606. package/runnables.js +0 -1
  607. package/singletons.cjs +0 -1
  608. package/singletons.d.cts +0 -1
  609. package/singletons.d.ts +0 -1
  610. package/singletons.js +0 -1
  611. package/stores.cjs +0 -1
  612. package/stores.d.cts +0 -1
  613. package/stores.d.ts +0 -1
  614. package/stores.js +0 -1
  615. package/structured_query.cjs +0 -1
  616. package/structured_query.d.cts +0 -1
  617. package/structured_query.d.ts +0 -1
  618. package/structured_query.js +0 -1
  619. package/tools.cjs +0 -1
  620. package/tools.d.cts +0 -1
  621. package/tools.d.ts +0 -1
  622. package/tools.js +0 -1
  623. package/tracers/base.cjs +0 -1
  624. package/tracers/base.d.cts +0 -1
  625. package/tracers/base.d.ts +0 -1
  626. package/tracers/base.js +0 -1
  627. package/tracers/console.cjs +0 -1
  628. package/tracers/console.d.cts +0 -1
  629. package/tracers/console.d.ts +0 -1
  630. package/tracers/console.js +0 -1
  631. package/tracers/log_stream.cjs +0 -1
  632. package/tracers/log_stream.d.cts +0 -1
  633. package/tracers/log_stream.d.ts +0 -1
  634. package/tracers/log_stream.js +0 -1
  635. package/tracers/run_collector.cjs +0 -1
  636. package/tracers/run_collector.d.cts +0 -1
  637. package/tracers/run_collector.d.ts +0 -1
  638. package/tracers/run_collector.js +0 -1
  639. package/tracers/tracer_langchain.cjs +0 -1
  640. package/tracers/tracer_langchain.d.cts +0 -1
  641. package/tracers/tracer_langchain.d.ts +0 -1
  642. package/tracers/tracer_langchain.js +0 -1
  643. package/types/stream.cjs +0 -1
  644. package/types/stream.d.cts +0 -1
  645. package/types/stream.d.ts +0 -1
  646. package/types/stream.js +0 -1
  647. package/utils/async_caller.cjs +0 -1
  648. package/utils/async_caller.d.cts +0 -1
  649. package/utils/async_caller.d.ts +0 -1
  650. package/utils/async_caller.js +0 -1
  651. package/utils/chunk_array.cjs +0 -1
  652. package/utils/chunk_array.d.cts +0 -1
  653. package/utils/chunk_array.d.ts +0 -1
  654. package/utils/chunk_array.js +0 -1
  655. package/utils/env.cjs +0 -1
  656. package/utils/env.d.cts +0 -1
  657. package/utils/env.d.ts +0 -1
  658. package/utils/env.js +0 -1
  659. package/utils/event_source_parse.cjs +0 -1
  660. package/utils/event_source_parse.d.cts +0 -1
  661. package/utils/event_source_parse.d.ts +0 -1
  662. package/utils/event_source_parse.js +0 -1
  663. package/utils/format.cjs +0 -1
  664. package/utils/format.d.cts +0 -1
  665. package/utils/format.d.ts +0 -1
  666. package/utils/format.js +0 -1
  667. package/utils/function_calling.cjs +0 -1
  668. package/utils/function_calling.d.cts +0 -1
  669. package/utils/function_calling.d.ts +0 -1
  670. package/utils/function_calling.js +0 -1
  671. package/utils/hash.cjs +0 -1
  672. package/utils/hash.d.cts +0 -1
  673. package/utils/hash.d.ts +0 -1
  674. package/utils/hash.js +0 -1
  675. package/utils/json_patch.cjs +0 -1
  676. package/utils/json_patch.d.cts +0 -1
  677. package/utils/json_patch.d.ts +0 -1
  678. package/utils/json_patch.js +0 -1
  679. package/utils/json_schema.cjs +0 -1
  680. package/utils/json_schema.d.cts +0 -1
  681. package/utils/json_schema.d.ts +0 -1
  682. package/utils/json_schema.js +0 -1
  683. package/utils/math.cjs +0 -1
  684. package/utils/math.d.cts +0 -1
  685. package/utils/math.d.ts +0 -1
  686. package/utils/math.js +0 -1
  687. package/utils/stream.cjs +0 -1
  688. package/utils/stream.d.cts +0 -1
  689. package/utils/stream.d.ts +0 -1
  690. package/utils/stream.js +0 -1
  691. package/utils/testing.cjs +0 -1
  692. package/utils/testing.d.cts +0 -1
  693. package/utils/testing.d.ts +0 -1
  694. package/utils/testing.js +0 -1
  695. package/utils/tiktoken.cjs +0 -1
  696. package/utils/tiktoken.d.cts +0 -1
  697. package/utils/tiktoken.d.ts +0 -1
  698. package/utils/tiktoken.js +0 -1
  699. package/utils/types.cjs +0 -1
  700. package/utils/types.d.cts +0 -1
  701. package/utils/types.d.ts +0 -1
  702. package/utils/types.js +0 -1
  703. package/vectorstores.cjs +0 -1
  704. package/vectorstores.d.cts +0 -1
  705. package/vectorstores.d.ts +0 -1
  706. package/vectorstores.js +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.cts","names":["ContentBlock","ResponseMetadata","UsageMetadata","$MergeDiscriminatedUnion","$MergeObjects","MessageType","NonNullable","MessageOutputVersion","MessageToolDefinition","TInput","TOutput","MessageToolSet","$MessageToolCallBlock","TStructure","MessageStructure","K","Tools","ToolCall","Partial","Record","$NormalizeMessageOutputVersion","T","Extract","$MergeOutputVersion","U","TV","UV","Exclude","$MergeContentDefinition","$MergeMessageStructure","StandardMessageStructure","Text","$NormalizedMessageStructure","$InferMessageContentBlocks","TRole","S","C","PropertyKey","$InferMessageContent","Array","$InferMessageProperties","P","Omit","$InferMessageProperty","$InferResponseMetadata","Message","isMessage"],"sources":["../../src/messages/message.d.ts"],"sourcesContent":["import type { ContentBlock } from \"./content/index.js\";\nimport type { ResponseMetadata, UsageMetadata } from \"./metadata.js\";\nimport type { $MergeDiscriminatedUnion, $MergeObjects } from \"./utils.js\";\n/**\n * Represents the possible types of messages in the system.\n * Includes standard message types (\"ai\", \"human\", \"tool\", \"system\")\n * and allows for custom string types that are non-null.\n *\n * @example\n * ```ts\n * // Standard message types\n * const messageType1: MessageType = \"ai\";\n * const messageType2: MessageType = \"human\";\n *\n * // Custom message type\n * const messageType3: MessageType = \"custom_type\";\n * ```\n */\nexport type MessageType = \"ai\" | \"human\" | \"tool\" | \"system\" | (string & NonNullable<unknown>);\n/**\n * Represents the output version format for message content.\n *\n * This type determines how the content field is structured in a message:\n * - \"v0\": Content is represented as a simple string or array of content blocks\n * - provides backward compatibility with simpler content representations\n * - \"v1\": Content follows the structured ContentBlock format with typed discriminated unions\n * - enables full type safety and structured content block handling\n *\n * @example\n * ```ts\n * // v0 format - simple content representation\n * const v0Message: Message<{ outputVersion: \"v0\", content: ... }> = {\n * type: \"human\",\n * content: \"Hello world\" // string | Array<ContentBlock | ContentBlock.Text>\n * };\n *\n * // v1 format - structured content blocks\n * const v1Message: Message<{ outputVersion: \"v1\", content: ... }> = {\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello world\" },\n * { type: \"image\", image_url: \"...\" }\n * ] // Array<ContentBlock | ...> (determined by the structure)\n * };\n * ```\n */\nexport type MessageOutputVersion = \"v0\" | \"v1\";\n/**\n * Represents the input and output types of a tool that can be used in messages.\n *\n * @template TInput - The type of input the tool accepts.\n * @template TOutput - The type of output the tool produces.\n *\n * @example\n * ```ts\n * // Tool that takes a string input and returns a number\n * interface StringToNumberTool extends MessageToolDefinition<string, number> {\n * input: string;\n * output: number;\n * }\n * ```\n */\nexport interface MessageToolDefinition<TInput = unknown, TOutput = unknown> {\n input: TInput;\n output: TOutput;\n}\n/**\n * Represents a structured set of tools by mapping tool names to definitions\n * that can be used in messages.\n *\n * @example\n * ```ts\n * interface MyToolSet extends MessageToolSet {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * translator: MessageToolDefinition<\n * { text: string; targetLanguage: string },\n * string\n * >;\n * }\n * ```\n */\nexport interface MessageToolSet {\n [key: string]: MessageToolDefinition;\n}\n/**\n * Represents a tool call block within a message structure by mapping tool names to their\n * corresponding tool call formats, including the input arguments and an optional identifier.\n *\n * @template TStructure - A message structure type that may contain tool definitions\n *\n * @example\n * ```ts\n * // Given a message structure with a calculator tool:\n * interface MyStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<{ operation: string, numbers: number[] }, number>\n * }\n * }\n *\n * // The tool call block would be:\n * type CalcToolCall = $MessageToolCallBlock<MyStructure>;\n * // Resolves to:\n * // {\n * // type: \"tool_call\";\n * // name: \"calculator\";\n * // args: { operation: string, numbers: number[] };\n * // id?: string;\n * // }\n * ```\n */\nexport type $MessageToolCallBlock<TStructure extends MessageStructure> = TStructure[\"tools\"] extends MessageToolSet ? {\n [K in keyof TStructure[\"tools\"]]: K extends string ? TStructure[\"tools\"][K] extends MessageToolDefinition ? ContentBlock.Tools.ToolCall<K, TStructure[\"tools\"][K][\"input\"]> : never : never;\n}[keyof TStructure[\"tools\"]] : never;\n/**\n * Core interface that defines the structure of messages.\n *\n * @example\n * ```ts\n * // Basic message structure with just content blocks\n * interface SimpleMessageStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * // allows for text + reasoning blocks in ai messages\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * }\n * }\n *\n * // Message structure with tools and properties\n * interface AdvancedMessageStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * };\n * content: {\n * // allows for text + image blocks in human messages\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // only allows for text blocks in ai messages\n * ai: ContentBlock.Text;\n * };\n * properties: {\n * // pins properties to ai messages\n * ai: {\n * response_metadata: {\n * confidence: number;\n * model: string;\n * };\n * };\n * }\n * }\n *\n * // Using with $MergeMessageStructure to combine structures\n * // The resulting type when passed into BaseMessage will have a calculator tool,\n * // allow for text + image blocks in human messages,\n * // and text + reasoning blocks + additional arbitrary properties in ai messages.\n * type CombinedStructure = $MergeMessageStructure<\n * SimpleMessageStructure,\n * AdvancedMessageStructure\n * >;\n *\n * // Using in a Message object\n * const message: Message<CombinedStructure> = {\n * id: \"msg-123\",\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello!\" }\n * { type: \"image\", mimeType: \"image/jpeg\", url: \"https://example.com/image.jpg\" }\n * // this block will throw an error because it's not defined in the structure\n * { type: \"reasoning\", reasoning: \"The answer is 42\" }\n * ]\n * };\n * ```\n */\nexport interface MessageStructure {\n /**\n * Optional output version for the message structure.\n * If not provided, defaults to \"v0\".\n */\n readonly outputVersion?: MessageOutputVersion;\n /**\n * Optional set of tool definitions that can be used in messages.\n * Each tool is defined with input/output types and can be referenced in tool messages.\n */\n readonly tools?: MessageToolSet;\n /**\n * Optional mapping of message types to their allowed content blocks.\n * Each message type can specify what content block types it supports (text, images, etc).\n */\n readonly content?: Partial<{\n [key in MessageType]: ContentBlock;\n }>;\n /**\n * Optional mapping of message types to arbitrary property objects.\n * Allows attaching custom metadata or other information to specific message types.\n */\n readonly properties?: Partial<{\n [key in MessageType]: Record<string, unknown>;\n }>;\n}\n/**\n * Normalizes an arbitrary type to a message output version or undefined.\n * Accepts unknown and narrows to a valid MessageOutputVersion if present.\n */\ntype $NormalizeMessageOutputVersion<T> = Extract<T, MessageOutputVersion> | undefined;\n/**\n * Merges two output version types from message structures.\n *\n * This utility type determines the resulting output version when combining two message structures.\n * The merge logic follows these rules:\n *\n * - If both T and U are undefined, defaults to \"v0\" for backwards compatibility\n * - If T is undefined but U is defined, uses U's version\n * - If U is undefined but T is defined, uses T's version\n * - If both T and U are defined, U takes precedence (later structure wins)\n *\n * @template T - The output version from the first message structure\n * @template U - The output version from the second message structure\n *\n * @example\n * ```ts\n * // Both undefined - defaults to \"v0\"\n * type Result1 = $MergeOutputVersion<undefined, undefined>; // \"v0\"\n *\n * // One defined - uses the defined version\n * type Result2 = $MergeOutputVersion<undefined, \"v1\">; // \"v1\"\n * type Result3 = $MergeOutputVersion<\"v0\", undefined>; // \"v0\"\n *\n * // Both defined - second takes precedence\n * type Result4 = $MergeOutputVersion<\"v0\", \"v1\">; // \"v1\"\n * ```\n */\nexport type $MergeOutputVersion<T, U> = $NormalizeMessageOutputVersion<T> extends infer TV ? $NormalizeMessageOutputVersion<U> extends infer UV ? [TV, UV] extends [undefined, undefined] ? \"v0\" : [TV] extends [undefined] ? Exclude<UV, undefined> : [UV] extends [undefined] ? Exclude<TV, undefined> : UV : never : never;\n/**\n * Merges two content definition objects from message structures.\n *\n * This utility type combines content definitions from two message structures, handling\n * the merging of content block types for each message type. The merge logic follows\n * these rules:\n *\n * - For keys that exist in both T and U: Merges the content blocks using discriminated\n * union merging based on the \"type\" property. This allows combining different content\n * block types (e.g., text + image) for the same message type.\n * - For keys that exist only in T: Uses T's content definition as-is\n * - For keys that exist only in U: Uses U's content definition as-is\n *\n * @template T - The content definition from the first message structure\n * @template U - The content definition from the second message structure\n *\n * @example\n * ```ts\n * // T allows text content for human messages\n * type ContentA = {\n * human: ContentBlock.Text;\n * };\n *\n * // U allows image content for human messages and text for AI messages\n * type ContentB = {\n * human: ContentBlock.Multimodal.Image;\n * ai: ContentBlock.Text;\n * };\n *\n * // Merged result allows both text and images for human messages, text for AI\n * type Merged = $MergeContentDefinition<ContentA, ContentB>;\n * // Result: {\n * // human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // ai: ContentBlock.Text;\n * // }\n * ```\n */\nexport type $MergeContentDefinition<T, U> = {\n [K in keyof T | keyof U as Extract<(K extends keyof T ? T[K] : never) | (K extends keyof U ? U[K] : never), ContentBlock> extends never ? never : K]: K extends keyof T ? K extends keyof U ? $MergeDiscriminatedUnion<Extract<T[K], ContentBlock>, Extract<U[K], ContentBlock>, \"type\"> : Extract<T[K], ContentBlock> : K extends keyof U ? Extract<U[K], ContentBlock> : never;\n};\n/**\n * Merges two message structures A and B into a combined structure.\n * This is a type utility that handles merging of tools, content blocks, and properties\n * from two message structures. The resulting type is usable as its own message structure.\n *\n * @example\n * ```ts\n * // Structure A allows text in human messages and has a confidence property on AI messages\n * interface StructureA extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * };\n * properties: {\n * ai: { confidence: number };\n * }\n * }\n *\n * // Structure B allows images in human messages and has a model property on AI messages\n * interface StructureB extends MessageStructure {\n * content: {\n * human: ContentBlock.Multimodal.Image;\n * };\n * properties: {\n * ai: { model: string };\n * }\n * }\n *\n * // Merged structure allows both text and images in human messages\n * // AI messages have both confidence and model properties\n * type Merged = $MergeMessageStructure<StructureA, StructureB>;\n * ```\n *\n * @template A - First message structure to merge\n * @template B - Second message structure to merge (takes precedence over A)\n */\nexport type $MergeMessageStructure<T extends MessageStructure, U extends MessageStructure> = {\n outputVersion: $MergeOutputVersion<T[\"outputVersion\"], U[\"outputVersion\"]>;\n tools: $MergeObjects<T[\"tools\"], U[\"tools\"]>;\n content: $MergeContentDefinition<T[\"content\"], U[\"content\"]>;\n properties: $MergeObjects<T[\"properties\"], U[\"properties\"]>;\n};\n/**\n * Standard message structured used to define the most basic message structure that's\n * used throughout the library.\n *\n * This is also the message structure that's used when a message structure is not provided.\n */\nexport interface StandardMessageStructure extends MessageStructure {\n content: {\n /** Text content for AI messages */\n ai: ContentBlock.Text;\n /** Text content for human messages */\n human: ContentBlock.Text;\n /** Text content for system messages */\n system: ContentBlock.Text;\n /** Text content for tool messages */\n tool: ContentBlock.Text;\n };\n properties: {\n /** Properties specific to AI messages */\n ai: {\n /** Metadata about the AI model response */\n response_metadata: ResponseMetadata;\n /** Usage statistics for the AI response */\n usage_metadata: UsageMetadata;\n };\n human: {\n /** Metadata about the human message */\n response_metadata: Record<string, unknown>;\n };\n system: {\n /** Metadata about the system message */\n response_metadata: Record<string, unknown>;\n };\n tool: {\n /** Metadata about the tool message */\n response_metadata: Record<string, unknown>;\n };\n };\n}\n/**\n * Takes a message structure type T and normalizes it by merging it with the standard message structure.\n * If T is already a standard message structure, returns T unchanged.\n *\n * This ensures that any custom message structure includes all the standard message structure fields\n * by default while allowing overrides and extensions.\n *\n * @template T - The message structure type to normalize, must extend MessageStructure\n * @returns Either T if it's already a standard structure, or the merged result of T with standard structure\n */\nexport type $NormalizedMessageStructure<T extends MessageStructure> = T extends StandardMessageStructure ? T : $MergeMessageStructure<StandardMessageStructure, T>;\n/**\n * Infers the content blocks for a specific message type in a message structure.\n *\n * This utility type extracts the content block type that corresponds to a given message type\n * from the message structure's content definition.\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content block type for the specified type, or never if its not defined in the structure\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContent = $InferMessageContentBlocks<MyStructure, \"human\">;\n * // HumanContent = ContentBlock.Text\n *\n * type AIContent = $InferMessageContentBlocks<MyStructure, \"ai\">;\n * // AIContent = ContentBlock.Text | ContentBlock.ToolCall\n * ```\n */\nexport type $InferMessageContentBlocks<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"content\"] extends infer C ? C extends Record<PropertyKey, ContentBlock> ? TRole extends keyof C ? [$MessageToolCallBlock<TStructure>] extends [never] ? C[TRole] : $MergeDiscriminatedUnion<NonNullable<C[TRole]>, $MessageToolCallBlock<TStructure>, \"type\"> : never : never : never : never : never;\n/**\n * Infers the content type for a specific message type from a message structure.\n *\n * This utility type determines the appropriate content type based on the message structure's\n * output version and the specified message type. The content type varies depending on the\n * output version (see {@link MessageOutputVersion})\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content type for the specified role based on the output version\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * outputVersion: \"v0\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContentV0 = $InferMessageContent<MyStructure, \"human\">;\n * // HumanContentV0 = string | Array<ContentBlock | ContentBlock.Text>\n *\n * interface MyStructureV1 extends MessageStructure {\n * outputVersion: \"v1\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * };\n * }\n *\n * type HumanContentV1 = $InferMessageContent<MyStructureV1, \"human\">;\n * // HumanContentV1 = ContentBlock.Text\n *\n * type AIContentV1 = $InferMessageContent<MyStructureV1, \"ai\">;\n * // AIContentV1 = ContentBlock.Text | ContentBlock.Reasoning\n * ```\n */\nexport type $InferMessageContent<TStructure extends MessageStructure, TRole extends MessageType> = TStructure[\"outputVersion\"] extends \"v1\" ? Array<$InferMessageContentBlocks<TStructure, TRole>> : string | Array<ContentBlock | ContentBlock.Text>;\n/**\n * Infers the properties for a specific message type from a message structure.\n *\n * This utility type extracts the properties object that corresponds to a given message type\n * from the message structure's properties definition, and excludes the reserved\n * \"content\" and \"type\" properties to avoid conflicts with the core message structure.\n *\n * If the specified type is not defined in the message structure's properties, it returns\n * a generic Record<string, unknown> type to allow for arbitrary properties.\n *\n * @template TStructure - The message structure to infer properties from\n * @template TRole - The message type/role to get properties for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The properties object type for the specified type, excluding \"content\" and \"type\"\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string };\n * usage_metadata: { tokens: number };\n * content: string; // This will be omitted\n * type: string; // This will be omitted\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIProperties = $InferMessageProperties<MyStructure, \"ai\">;\n * // AIProperties = { response_metadata: { model: string }; usage_metadata: { tokens: number } }\n *\n * type HumanProperties = $InferMessageProperties<MyStructure, \"human\">;\n * // HumanProperties = { metadata: Record<string, unknown> }\n *\n * type SystemProperties = $InferMessageProperties<MyStructure, \"system\">;\n * // SystemProperties = Record<string, unknown> (fallback for undefined role)\n * ```\n */\nexport type $InferMessageProperties<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"properties\"] extends infer P | undefined ? P extends Record<PropertyKey, unknown> ? TRole extends keyof P ? Omit<P[TRole], \"content\" | \"type\"> : Record<string, unknown> : Record<string, unknown> : Record<string, unknown> : never : never;\n/**\n * Infers the type of a specific property for a message type from a message structure.\n *\n * This utility type extracts the type of a single property by name from the properties\n * object that corresponds to a given message type. If the specified property key does\n * not exist in the type's properties, it returns `never`.\n *\n * @template TStructure - The message structure to infer the property from\n * @template TRole - The message type/role to get the property for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @template K - The property key to extract the type for\n * @returns The type of the specified property, or `never` if the property doesn't exist\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number };\n * usage_metadata: { input_tokens: number; output_tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type ResponseMetadata = $InferMessageProperty<MyStructure, \"ai\", \"response_metadata\">;\n * // ResponseMetadata = { model: string; temperature: number }\n *\n * type UsageMetadata = $InferMessageProperty<MyStructure, \"ai\", \"usage_metadata\">;\n * // UsageMetadata = { input_tokens: number; output_tokens: number }\n *\n * type NonExistentProperty = $InferMessageProperty<MyStructure, \"ai\", \"nonExistent\">;\n * // NonExistentProperty = Record<string, unknown>\n *\n * type HumanMetadata = $InferMessageProperty<MyStructure, \"human\", \"metadata\">;\n * // HumanMetadata = Record<string, unknown>\n * ```\n */\nexport type $InferMessageProperty<TStructure extends MessageStructure, TRole extends MessageType, K extends string> = K extends keyof $InferMessageProperties<TStructure, TRole> ? $InferMessageProperties<TStructure, TRole>[K] : never;\n/**\n * Infers the response metadata type for a specific message type from a message structure.\n *\n * This utility type extracts the `response_metadata` property type for a given message type.\n *\n * @template TStructure - The message structure to infer the response metadata from\n * @template TRole - The message type/role to get the response metadata for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The type of the response_metadata property, or `Record<string, unknown>` as fallback\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number; tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIResponseMetadata = $InferResponseMetadata<MyStructure, \"ai\">;\n * // AIResponseMetadata = { model: string; temperature: number; tokens: number }\n *\n * type HumanResponseMetadata = $InferResponseMetadata<MyStructure, \"human\">;\n * // HumanResponseMetadata = Record<string, unknown> (fallback since not defined)\n * ```\n */\nexport type $InferResponseMetadata<TStructure extends MessageStructure, TRole extends MessageType> = $InferMessageProperty<TStructure, TRole, \"response_metadata\"> extends infer P ? [P] extends [never] ? Record<string, unknown> : P : never;\n/**\n * Represents a message object that organizes context for an LLM.\n *\n * @example\n * ```ts\n * // Basic message with text content\n * const message: Message = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"human\",\n * content: [{ type: \"text\", text: \"Hello!\" }]\n * };\n *\n * // Basic ai message interface extension\n * interface MyMessage extends Message<StandardMessageStructure, \"ai\"> {\n * // Additional AI-specific properties can be added here\n * }\n *`\n * // Custom message structure\n * interface CustomStructure extends MessageStructure {\n * content: {\n * ai: ContentBlock.Text | ContentBlock.ToolCall<\"search\", { query: string }>;\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * };\n * }\n *\n * // Create a message with custom structure\n * const message: Message<CustomStructure> = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"ai\",\n * content: [\n * { type: \"text\", text: \"Hello!\" },\n * {\n * type: \"tool_call\",\n * name: \"search\",\n * args: { query: \"What is the capital of France?\" }\n * }\n * ]\n * };\n * ```\n */\nexport interface Message<TStructure extends MessageStructure = StandardMessageStructure, TRole extends MessageType = MessageType> {\n /** The message type/role */\n readonly type: TRole;\n /** Unique identifier for this message */\n id?: string;\n /** Optional name/identifier for the entity that created this message */\n name?: string;\n /** Array of content blocks that make up the message content */\n content: $InferMessageContent<TStructure, TRole>;\n /** Metadata about the message */\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n}\n/**\n * Type guard to check if a value is a valid Message object.\n *\n * @param message - The value to check\n * @returns true if the value is a valid Message object, false otherwise\n */\nexport declare function isMessage(message: unknown): message is Message;\nexport {};\n//# sourceMappingURL=message.d.ts.map"],"mappings":";;;;;;;;AAkBA;AA4BA;AAgBA;AAsBA;AA6BA;;;;;;;;;AAC4Ie,KAhGhIV,WAAAA,GAgGgIU,IAAAA,GAAAA,OAAAA,GAAAA,MAAAA,GAAAA,QAAAA,GAAAA,CAAAA,MAAAA,GAhGnET,WAgGmES,CAAAA,OAAAA,CAAAA,CAAAA;;;;;AAC1H;AA8DlB;;;;;;;;;AAsBiC;AAGhC;;;;AAK+C;AA4BhD;;;;;;;AAAoMU,KA7LxLlB,oBAAAA,GA6LwLkB,IAAAA,GAAAA,IAAAA;;;;;;;AAAyG;AAsC7S;;;;;;;;AAC6FD,UApN5EhB,qBAoN4EgB,CAAAA,SAAAA,OAAAA,EAAAA,UAAAA,OAAAA,CAAAA,CAAAA;EAAIA,KAAAA,EAnNtFf,MAmNsFe;EAAET,MAAAA,EAlNvFL,OAkNuFK;;;;;;;;;;;;;;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putVersion","MessageToolDefinition","TInput","TOutput","MessageToolSet","$MessageToolCallBlock","TStructure","MessageStructure","K","Tools","ToolCall","Partial","Record","$NormalizeMessageOutputVersion","T","Extract","$MergeOutputVersion","U","TV","UV","Exclude","$MergeContentDefinition","$MergeMessageStructure","StandardMessageStructure","Text","$NormalizedMessageStructure","$InferMessageContentBlocks","TRole","S","C","PropertyKey","$InferMessageContent","Array","$InferMessageProperties","P","Omit","$InferMessageProperty","$InferResponseMetadata","Message","isMessage"],"sources":["../../src/messages/message.d.ts"],"sourcesContent":["import type { ContentBlock } from \"./content/index.js\";\nimport type { ResponseMetadata, UsageMetadata } from \"./metadata.js\";\nimport type { $MergeDiscriminatedUnion, $MergeObjects } from \"./utils.js\";\n/**\n * Represents the possible types of messages in the system.\n * Includes standard message types (\"ai\", \"human\", \"tool\", \"system\")\n * and allows for custom string types that are non-null.\n *\n * @example\n * ```ts\n * // Standard message types\n * const messageType1: MessageType = \"ai\";\n * const messageType2: MessageType = \"human\";\n *\n * // Custom message type\n * const messageType3: MessageType = \"custom_type\";\n * ```\n */\nexport type MessageType = \"ai\" | \"human\" | \"tool\" | \"system\" | (string & NonNullable<unknown>);\n/**\n * Represents the output version format for message content.\n *\n * This type determines how the content field is structured in a message:\n * - \"v0\": Content is represented as a simple string or array of content blocks\n * - provides backward compatibility with simpler content representations\n * - \"v1\": Content follows the structured ContentBlock format with typed discriminated unions\n * - enables full type safety and structured content block handling\n *\n * @example\n * ```ts\n * // v0 format - simple content representation\n * const v0Message: Message<{ outputVersion: \"v0\", content: ... }> = {\n * type: \"human\",\n * content: \"Hello world\" // string | Array<ContentBlock | ContentBlock.Text>\n * };\n *\n * // v1 format - structured content blocks\n * const v1Message: Message<{ outputVersion: \"v1\", content: ... }> = {\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello world\" },\n * { type: \"image\", image_url: \"...\" }\n * ] // Array<ContentBlock | ...> (determined by the structure)\n * };\n * ```\n */\nexport type MessageOutputVersion = \"v0\" | \"v1\";\n/**\n * Represents the input and output types of a tool that can be used in messages.\n *\n * @template TInput - The type of input the tool accepts.\n * @template TOutput - The type of output the tool produces.\n *\n * @example\n * ```ts\n * // Tool that takes a string input and returns a number\n * interface StringToNumberTool extends MessageToolDefinition<string, number> {\n * input: string;\n * output: number;\n * }\n * ```\n */\nexport interface MessageToolDefinition<TInput = unknown, TOutput = unknown> {\n input: TInput;\n output: TOutput;\n}\n/**\n * Represents a structured set of tools by mapping tool names to definitions\n * that can be used in messages.\n *\n * @example\n * ```ts\n * interface MyToolSet extends MessageToolSet {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * translator: MessageToolDefinition<\n * { text: string; targetLanguage: string },\n * string\n * >;\n * }\n * ```\n */\nexport interface MessageToolSet {\n [key: string]: MessageToolDefinition;\n}\n/**\n * Represents a tool call block within a message structure by mapping tool names to their\n * corresponding tool call formats, including the input arguments and an optional identifier.\n *\n * @template TStructure - A message structure type that may contain tool definitions\n *\n * @example\n * ```ts\n * // Given a message structure with a calculator tool:\n * interface MyStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<{ operation: string, numbers: number[] }, number>\n * }\n * }\n *\n * // The tool call block would be:\n * type CalcToolCall = $MessageToolCallBlock<MyStructure>;\n * // Resolves to:\n * // {\n * // type: \"tool_call\";\n * // name: \"calculator\";\n * // args: { operation: string, numbers: number[] };\n * // id?: string;\n * // }\n * ```\n */\nexport type $MessageToolCallBlock<TStructure extends MessageStructure> = TStructure[\"tools\"] extends MessageToolSet ? {\n [K in keyof TStructure[\"tools\"]]: K extends string ? TStructure[\"tools\"][K] extends MessageToolDefinition ? ContentBlock.Tools.ToolCall<K, TStructure[\"tools\"][K][\"input\"]> : never : never;\n}[keyof TStructure[\"tools\"]] : never;\n/**\n * Core interface that defines the structure of messages.\n *\n * @example\n * ```ts\n * // Basic message structure with just content blocks\n * interface SimpleMessageStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * // allows for text + reasoning blocks in ai messages\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * }\n * }\n *\n * // Message structure with tools and properties\n * interface AdvancedMessageStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * };\n * content: {\n * // allows for text + image blocks in human messages\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // only allows for text blocks in ai messages\n * ai: ContentBlock.Text;\n * };\n * properties: {\n * // pins properties to ai messages\n * ai: {\n * response_metadata: {\n * confidence: number;\n * model: string;\n * };\n * };\n * }\n * }\n *\n * // Using with $MergeMessageStructure to combine structures\n * // The resulting type when passed into BaseMessage will have a calculator tool,\n * // allow for text + image blocks in human messages,\n * // and text + reasoning blocks + additional arbitrary properties in ai messages.\n * type CombinedStructure = $MergeMessageStructure<\n * SimpleMessageStructure,\n * AdvancedMessageStructure\n * >;\n *\n * // Using in a Message object\n * const message: Message<CombinedStructure> = {\n * id: \"msg-123\",\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello!\" }\n * { type: \"image\", mimeType: \"image/jpeg\", url: \"https://example.com/image.jpg\" }\n * // this block will throw an error because it's not defined in the structure\n * { type: \"reasoning\", reasoning: \"The answer is 42\" }\n * ]\n * };\n * ```\n */\nexport interface MessageStructure {\n /**\n * Optional output version for the message structure.\n * If not provided, defaults to \"v0\".\n */\n readonly outputVersion?: MessageOutputVersion;\n /**\n * Optional set of tool definitions that can be used in messages.\n * Each tool is defined with input/output types and can be referenced in tool messages.\n */\n readonly tools?: MessageToolSet;\n /**\n * Optional mapping of message types to their allowed content blocks.\n * Each message type can specify what content block types it supports (text, images, etc).\n */\n readonly content?: Partial<{\n [key in MessageType]: ContentBlock;\n }>;\n /**\n * Optional mapping of message types to arbitrary property objects.\n * Allows attaching custom metadata or other information to specific message types.\n */\n readonly properties?: Partial<{\n [key in MessageType]: Record<string, unknown>;\n }>;\n}\n/**\n * Normalizes an arbitrary type to a message output version or undefined.\n * Accepts unknown and narrows to a valid MessageOutputVersion if present.\n */\ntype $NormalizeMessageOutputVersion<T> = Extract<T, MessageOutputVersion> | undefined;\n/**\n * Merges two output version types from message structures.\n *\n * This utility type determines the resulting output version when combining two message structures.\n * The merge logic follows these rules:\n *\n * - If both T and U are undefined, defaults to \"v0\" for backwards compatibility\n * - If T is undefined but U is defined, uses U's version\n * - If U is undefined but T is defined, uses T's version\n * - If both T and U are defined, U takes precedence (later structure wins)\n *\n * @template T - The output version from the first message structure\n * @template U - The output version from the second message structure\n *\n * @example\n * ```ts\n * // Both undefined - defaults to \"v0\"\n * type Result1 = $MergeOutputVersion<undefined, undefined>; // \"v0\"\n *\n * // One defined - uses the defined version\n * type Result2 = $MergeOutputVersion<undefined, \"v1\">; // \"v1\"\n * type Result3 = $MergeOutputVersion<\"v0\", undefined>; // \"v0\"\n *\n * // Both defined - second takes precedence\n * type Result4 = $MergeOutputVersion<\"v0\", \"v1\">; // \"v1\"\n * ```\n */\nexport type $MergeOutputVersion<T, U> = $NormalizeMessageOutputVersion<T> extends infer TV ? $NormalizeMessageOutputVersion<U> extends infer UV ? [TV, UV] extends [undefined, undefined] ? \"v0\" : [TV] extends [undefined] ? Exclude<UV, undefined> : [UV] extends [undefined] ? Exclude<TV, undefined> : UV : never : never;\n/**\n * Merges two content definition objects from message structures.\n *\n * This utility type combines content definitions from two message structures, handling\n * the merging of content block types for each message type. The merge logic follows\n * these rules:\n *\n * - For keys that exist in both T and U: Merges the content blocks using discriminated\n * union merging based on the \"type\" property. This allows combining different content\n * block types (e.g., text + image) for the same message type.\n * - For keys that exist only in T: Uses T's content definition as-is\n * - For keys that exist only in U: Uses U's content definition as-is\n *\n * @template T - The content definition from the first message structure\n * @template U - The content definition from the second message structure\n *\n * @example\n * ```ts\n * // T allows text content for human messages\n * type ContentA = {\n * human: ContentBlock.Text;\n * };\n *\n * // U allows image content for human messages and text for AI messages\n * type ContentB = {\n * human: ContentBlock.Multimodal.Image;\n * ai: ContentBlock.Text;\n * };\n *\n * // Merged result allows both text and images for human messages, text for AI\n * type Merged = $MergeContentDefinition<ContentA, ContentB>;\n * // Result: {\n * // human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // ai: ContentBlock.Text;\n * // }\n * ```\n */\nexport type $MergeContentDefinition<T, U> = {\n [K in keyof T | keyof U as Extract<(K extends keyof T ? T[K] : never) | (K extends keyof U ? U[K] : never), ContentBlock> extends never ? never : K]: K extends keyof T ? K extends keyof U ? $MergeDiscriminatedUnion<Extract<T[K], ContentBlock>, Extract<U[K], ContentBlock>, \"type\"> : Extract<T[K], ContentBlock> : K extends keyof U ? Extract<U[K], ContentBlock> : never;\n};\n/**\n * Merges two message structures A and B into a combined structure.\n * This is a type utility that handles merging of tools, content blocks, and properties\n * from two message structures. The resulting type is usable as its own message structure.\n *\n * @example\n * ```ts\n * // Structure A allows text in human messages and has a confidence property on AI messages\n * interface StructureA extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * };\n * properties: {\n * ai: { confidence: number };\n * }\n * }\n *\n * // Structure B allows images in human messages and has a model property on AI messages\n * interface StructureB extends MessageStructure {\n * content: {\n * human: ContentBlock.Multimodal.Image;\n * };\n * properties: {\n * ai: { model: string };\n * }\n * }\n *\n * // Merged structure allows both text and images in human messages\n * // AI messages have both confidence and model properties\n * type Merged = $MergeMessageStructure<StructureA, StructureB>;\n * ```\n *\n * @template A - First message structure to merge\n * @template B - Second message structure to merge (takes precedence over A)\n */\nexport type $MergeMessageStructure<T extends MessageStructure, U extends MessageStructure> = {\n outputVersion: $MergeOutputVersion<T[\"outputVersion\"], U[\"outputVersion\"]>;\n tools: $MergeObjects<T[\"tools\"], U[\"tools\"]>;\n content: $MergeContentDefinition<T[\"content\"], U[\"content\"]>;\n properties: $MergeObjects<T[\"properties\"], U[\"properties\"]>;\n};\n/**\n * Standard message structured used to define the most basic message structure that's\n * used throughout the library.\n *\n * This is also the message structure that's used when a message structure is not provided.\n */\nexport interface StandardMessageStructure extends MessageStructure {\n content: {\n /** Text content for AI messages */\n ai: ContentBlock.Text;\n /** Text content for human messages */\n human: ContentBlock.Text;\n /** Text content for system messages */\n system: ContentBlock.Text;\n /** Text content for tool messages */\n tool: ContentBlock.Text;\n };\n properties: {\n /** Properties specific to AI messages */\n ai: {\n /** Metadata about the AI model response */\n response_metadata: ResponseMetadata;\n /** Usage statistics for the AI response */\n usage_metadata: UsageMetadata;\n };\n human: {\n /** Metadata about the human message */\n response_metadata: Record<string, unknown>;\n };\n system: {\n /** Metadata about the system message */\n response_metadata: Record<string, unknown>;\n };\n tool: {\n /** Metadata about the tool message */\n response_metadata: Record<string, unknown>;\n };\n };\n}\n/**\n * Takes a message structure type T and normalizes it by merging it with the standard message structure.\n * If T is already a standard message structure, returns T unchanged.\n *\n * This ensures that any custom message structure includes all the standard message structure fields\n * by default while allowing overrides and extensions.\n *\n * @template T - The message structure type to normalize, must extend MessageStructure\n * @returns Either T if it's already a standard structure, or the merged result of T with standard structure\n */\nexport type $NormalizedMessageStructure<T extends MessageStructure> = T extends StandardMessageStructure ? T : $MergeMessageStructure<StandardMessageStructure, T>;\n/**\n * Infers the content blocks for a specific message type in a message structure.\n *\n * This utility type extracts the content block type that corresponds to a given message type\n * from the message structure's content definition.\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content block type for the specified type, or never if its not defined in the structure\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContent = $InferMessageContentBlocks<MyStructure, \"human\">;\n * // HumanContent = ContentBlock.Text\n *\n * type AIContent = $InferMessageContentBlocks<MyStructure, \"ai\">;\n * // AIContent = ContentBlock.Text | ContentBlock.ToolCall\n * ```\n */\nexport type $InferMessageContentBlocks<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"content\"] extends infer C ? C extends Record<PropertyKey, ContentBlock> ? TRole extends keyof C ? [$MessageToolCallBlock<TStructure>] extends [never] ? C[TRole] : $MergeDiscriminatedUnion<NonNullable<C[TRole]>, $MessageToolCallBlock<TStructure>, \"type\"> : never : never : never : never : never;\n/**\n * Infers the content type for a specific message type from a message structure.\n *\n * This utility type determines the appropriate content type based on the message structure's\n * output version and the specified message type. The content type varies depending on the\n * output version (see {@link MessageOutputVersion})\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content type for the specified role based on the output version\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * outputVersion: \"v0\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContentV0 = $InferMessageContent<MyStructure, \"human\">;\n * // HumanContentV0 = string | Array<ContentBlock | ContentBlock.Text>\n *\n * interface MyStructureV1 extends MessageStructure {\n * outputVersion: \"v1\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * };\n * }\n *\n * type HumanContentV1 = $InferMessageContent<MyStructureV1, \"human\">;\n * // HumanContentV1 = ContentBlock.Text\n *\n * type AIContentV1 = $InferMessageContent<MyStructureV1, \"ai\">;\n * // AIContentV1 = ContentBlock.Text | ContentBlock.Reasoning\n * ```\n */\nexport type $InferMessageContent<TStructure extends MessageStructure, TRole extends MessageType> = TStructure[\"outputVersion\"] extends \"v1\" ? Array<$InferMessageContentBlocks<TStructure, TRole>> : string | Array<ContentBlock | ContentBlock.Text>;\n/**\n * Infers the properties for a specific message type from a message structure.\n *\n * This utility type extracts the properties object that corresponds to a given message type\n * from the message structure's properties definition, and excludes the reserved\n * \"content\" and \"type\" properties to avoid conflicts with the core message structure.\n *\n * If the specified type is not defined in the message structure's properties, it returns\n * a generic Record<string, unknown> type to allow for arbitrary properties.\n *\n * @template TStructure - The message structure to infer properties from\n * @template TRole - The message type/role to get properties for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The properties object type for the specified type, excluding \"content\" and \"type\"\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string };\n * usage_metadata: { tokens: number };\n * content: string; // This will be omitted\n * type: string; // This will be omitted\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIProperties = $InferMessageProperties<MyStructure, \"ai\">;\n * // AIProperties = { response_metadata: { model: string }; usage_metadata: { tokens: number } }\n *\n * type HumanProperties = $InferMessageProperties<MyStructure, \"human\">;\n * // HumanProperties = { metadata: Record<string, unknown> }\n *\n * type SystemProperties = $InferMessageProperties<MyStructure, \"system\">;\n * // SystemProperties = Record<string, unknown> (fallback for undefined role)\n * ```\n */\nexport type $InferMessageProperties<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"properties\"] extends infer P | undefined ? P extends Record<PropertyKey, unknown> ? TRole extends keyof P ? Omit<P[TRole], \"content\" | \"type\"> : Record<string, unknown> : Record<string, unknown> : Record<string, unknown> : never : never;\n/**\n * Infers the type of a specific property for a message type from a message structure.\n *\n * This utility type extracts the type of a single property by name from the properties\n * object that corresponds to a given message type. If the specified property key does\n * not exist in the type's properties, it returns `never`.\n *\n * @template TStructure - The message structure to infer the property from\n * @template TRole - The message type/role to get the property for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @template K - The property key to extract the type for\n * @returns The type of the specified property, or `never` if the property doesn't exist\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number };\n * usage_metadata: { input_tokens: number; output_tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type ResponseMetadata = $InferMessageProperty<MyStructure, \"ai\", \"response_metadata\">;\n * // ResponseMetadata = { model: string; temperature: number }\n *\n * type UsageMetadata = $InferMessageProperty<MyStructure, \"ai\", \"usage_metadata\">;\n * // UsageMetadata = { input_tokens: number; output_tokens: number }\n *\n * type NonExistentProperty = $InferMessageProperty<MyStructure, \"ai\", \"nonExistent\">;\n * // NonExistentProperty = Record<string, unknown>\n *\n * type HumanMetadata = $InferMessageProperty<MyStructure, \"human\", \"metadata\">;\n * // HumanMetadata = Record<string, unknown>\n * ```\n */\nexport type $InferMessageProperty<TStructure extends MessageStructure, TRole extends MessageType, K extends string> = K extends keyof $InferMessageProperties<TStructure, TRole> ? $InferMessageProperties<TStructure, TRole>[K] : never;\n/**\n * Infers the response metadata type for a specific message type from a message structure.\n *\n * This utility type extracts the `response_metadata` property type for a given message type.\n *\n * @template TStructure - The message structure to infer the response metadata from\n * @template TRole - The message type/role to get the response metadata for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The type of the response_metadata property, or `Record<string, unknown>` as fallback\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number; tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIResponseMetadata = $InferResponseMetadata<MyStructure, \"ai\">;\n * // AIResponseMetadata = { model: string; temperature: number; tokens: number }\n *\n * type HumanResponseMetadata = $InferResponseMetadata<MyStructure, \"human\">;\n * // HumanResponseMetadata = Record<string, unknown> (fallback since not defined)\n * ```\n */\nexport type $InferResponseMetadata<TStructure extends MessageStructure, TRole extends MessageType> = $InferMessageProperty<TStructure, TRole, \"response_metadata\"> extends infer P ? [P] extends [never] ? Record<string, unknown> : P : never;\n/**\n * Represents a message object that organizes context for an LLM.\n *\n * @example\n * ```ts\n * // Basic message with text content\n * const message: Message = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"human\",\n * content: [{ type: \"text\", text: \"Hello!\" }]\n * };\n *\n * // Basic ai message interface extension\n * interface MyMessage extends Message<StandardMessageStructure, \"ai\"> {\n * // Additional AI-specific properties can be added here\n * }\n *`\n * // Custom message structure\n * interface CustomStructure extends MessageStructure {\n * content: {\n * ai: ContentBlock.Text | ContentBlock.ToolCall<\"search\", { query: string }>;\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * };\n * }\n *\n * // Create a message with custom structure\n * const message: Message<CustomStructure> = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"ai\",\n * content: [\n * { type: \"text\", text: \"Hello!\" },\n * {\n * type: \"tool_call\",\n * name: \"search\",\n * args: { query: \"What is the capital of France?\" }\n * }\n * ]\n * };\n * ```\n */\nexport interface Message<TStructure extends MessageStructure = StandardMessageStructure, TRole extends MessageType = MessageType> {\n /** The message type/role */\n readonly type: TRole;\n /** Unique identifier for this message */\n id?: string;\n /** Optional name/identifier for the entity that created this message */\n name?: string;\n /** Array of content blocks that make up the message content */\n content: $InferMessageContent<TStructure, TRole>;\n /** Metadata about the message */\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n}\n/**\n * Type guard to check if a value is a valid Message object.\n *\n * @param message - The value to check\n * @returns true if the value is a valid Message object, false otherwise\n */\nexport declare function isMessage(message: unknown): message is Message;\nexport {};\n//# sourceMappingURL=message.d.ts.map"],"mappings":";;;;;;;;AAkBA;AA4BA;AAgBA;AAsBA;AA6BA;;;;;;;;;AAC4Ie,KAhGhIV,WAAAA,GAgGgIU,IAAAA,GAAAA,OAAAA,GAAAA,MAAAA,GAAAA,QAAAA,GAAAA,CAAAA,MAAAA,GAhGnET,WAgGmES,CAAAA,OAAAA,CAAAA,CAAAA;;;;;AAC1H;AA8DlB;;;;;;;;;AAsBiC;AAGhC;;;;AAK+C;AA4BhD;;;;;;;AAAoMU,KA7LxLlB,oBAAAA,GA6LwLkB,IAAAA,GAAAA,IAAAA;;;;;;;AAAyG;AAsC7S;;;;;;;;AAC6FD,UApN5EhB,qBAoN4EgB,CAAAA,SAAAA,OAAAA,EAAAA,UAAAA,OAAAA,CAAAA,CAAAA;EAAIA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":["MessageOutputVersion","ResponseMetadata","mergeResponseMetadata","ModalitiesTokenDetails","InputTokenDetails","OutputTokenDetails","UsageMetadata","mergeUsageMetadata"],"sources":["../../src/messages/metadata.d.ts"],"sourcesContent":["import type { MessageOutputVersion } from \"./message.js\";\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n output_version?: MessageOutputVersion;\n [key: string]: unknown;\n};\nexport declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n /**\n * Audio tokens.\n */\n audio?: number;\n /**\n * Video tokens.\n */\n video?: number;\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\nexport declare function mergeUsageMetadata(a?: UsageMetadata, b?: UsageMetadata): UsageMetadata;\n//# sourceMappingURL=metadata.d.ts.map"],"mappings":";;;KACYC,gBAAAA;;EAAAA,UAAAA,CAAAA,EAAAA,MAAgB;EAMJC,cAAAA,CAAAA,EAHHF,oBAGwB;EAAKC,CAAAA,GAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;CAAsBA;AAAmBA,iBAAnEC,qBAAAA,CAAmED,CAAAA,CAAAA,EAAzCA,gBAAyCA,EAAAA,CAAAA,CAAAA,EAAnBA,gBAAmBA,CAAAA,EAAAA,gBAAAA;AAAgB,KAC/FE,sBAAAA,GAD+F;EAC/FA;AA6BZ;AAoBA;AAYA;EA0BwBI,IAAAA,CAAAA,EAAAA,MAAAA;EAAuBD;;;EAAgD,KAAA,CAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;KA1DnFF,iBAAAA,GAAoBD;;;;;;;;;;;;;;;;;;;;KAoBpBE,kBAAAA,GAAqBF;;;;;;;;;;;;KAYrBG,aAAAA;;;;;;;;;;;;;;;;;;wBAkBcF;;;;;;yBAMCC;;iBAEHE,kBAAAA,KAAuBD,mBAAmBA,gBAAgBA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metadata.d.ts","names":["MessageOutputVersion","ResponseMetadata","mergeResponseMetadata","ModalitiesTokenDetails","InputTokenDetails","OutputTokenDetails","UsageMetadata","mergeUsageMetadata"],"sources":["../../src/messages/metadata.d.ts"],"sourcesContent":["import type { MessageOutputVersion } from \"./message.js\";\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n output_version?: MessageOutputVersion;\n [key: string]: unknown;\n};\nexport declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n /**\n * Audio tokens.\n */\n audio?: number;\n /**\n * Video tokens.\n */\n video?: number;\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\nexport declare function mergeUsageMetadata(a?: UsageMetadata, b?: UsageMetadata): UsageMetadata;\n//# sourceMappingURL=metadata.d.ts.map"],"mappings":";;;KACYC,gBAAAA;;EAAAA,UAAAA,CAAAA,EAAAA,MAAgB;EAMJC,cAAAA,CAAAA,EAHHF,oBAGwB;EAAKC,CAAAA,GAAAA,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;CAAsBA;AAAmBA,iBAAnEC,qBAAAA,CAAmED,CAAAA,CAAAA,EAAzCA,gBAAyCA,EAAAA,CAAAA,CAAAA,EAAnBA,gBAAmBA,CAAAA,EAAAA,gBAAAA;AAAgB,KAC/FE,sBAAAA,GAD+F;EAC/FA;AA6BZ;AAoBA;AAYA;EA0BwBI,IAAAA,CAAAA,EAAAA,MAAAA;EAAuBD;;;EAAgD,KAAA,CAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;KA1DnFF,iBAAAA,GAAoBD;;;;;;;;;;;;;;;;;;;;KAoBpBE,kBAAAA,GAAqBF;;;;;;;;;;;;KAYrBG,aAAAA;;;;;;;;;;;;;;;;;;wBAkBcF;;;;;;yBAMCC;;iBAEHE,kBAAAA,KAAuBD,mBAAmBA,gBAAgBA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modifier.d.cts","names":["BaseMessage","BaseMessageFields","MessageStructure","RemoveMessageFields","TStructure","Omit","RemoveMessage","Record"],"sources":["../../src/messages/modifier.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageFields } from \"./base.js\";\nimport { MessageStructure } from \"./message.js\";\nexport interface RemoveMessageFields<TStructure extends MessageStructure = MessageStructure> extends Omit<BaseMessageFields<TStructure, \"remove\">, \"content\"> {\n /**\n * The ID of the message to remove.\n */\n id: string;\n}\n/**\n * Message responsible for deleting other messages.\n */\nexport declare class RemoveMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"remove\"> {\n readonly type: \"remove\";\n /**\n * The ID of the message to remove.\n */\n id: string;\n constructor(fields: RemoveMessageFields<TStructure>);\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is RemoveMessage;\n}\n//# sourceMappingURL=modifier.d.ts.map"],"mappings":";;;;UAEiBG,uCAAuCD,mBAAmBA,0BAA0BG,KAAKJ,kBAAkBG;;AAA5H;;EAA2EF,EAAAA,EAAAA,MAAAA;;;;AAA8B;AASpFI,cAAAA,aAAaF,CAAAA,mBAAoBF,gBAApB,GAAuCA,gBAAvC,CAAA,SAAiEF,WAAjE,CAA6EI,UAA7E,EAAA,QAAA,CAAA,CAAA;EAAoBF,SAAAA,IAAAA,EAAAA,QAAAA;EAAmBA;;;EAMjDC,EAAAA,EAAAA,MAAAA;EACII,WAAAA,CAAAA,MAAAA,EADJJ,mBACII,CADgBH,UAChBG,CAAAA;EACgBD,IAAAA,gBAAAA,CAAAA,CAAAA,EADhBC,MACgBD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EARuDN,OAAAA,UAAAA,CAAAA,GAAAA,EAAAA,OAAAA,CAAAA,EAAAA,GAAAA,IAQvDM,aARuDN;AAAW"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modifier.d.ts","names":["BaseMessage","BaseMessageFields","MessageStructure","RemoveMessageFields","TStructure","Omit","RemoveMessage","Record"],"sources":["../../src/messages/modifier.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageFields } from \"./base.js\";\nimport { MessageStructure } from \"./message.js\";\nexport interface RemoveMessageFields<TStructure extends MessageStructure = MessageStructure> extends Omit<BaseMessageFields<TStructure, \"remove\">, \"content\"> {\n /**\n * The ID of the message to remove.\n */\n id: string;\n}\n/**\n * Message responsible for deleting other messages.\n */\nexport declare class RemoveMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"remove\"> {\n readonly type: \"remove\";\n /**\n * The ID of the message to remove.\n */\n id: string;\n constructor(fields: RemoveMessageFields<TStructure>);\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is RemoveMessage;\n}\n//# sourceMappingURL=modifier.d.ts.map"],"mappings":";;;;UAEiBG,uCAAuCD,mBAAmBA,0BAA0BG,KAAKJ,kBAAkBG;;AAA5H;;EAA2EF,EAAAA,EAAAA,MAAAA;;;;AAA8B;AASpFI,cAAAA,aAAaF,CAAAA,mBAAoBF,gBAApB,GAAuCA,gBAAvC,CAAA,SAAiEF,WAAjE,CAA6EI,UAA7E,EAAA,QAAA,CAAA,CAAA;EAAoBF,SAAAA,IAAAA,EAAAA,QAAAA;EAAmBA;;;EAMjDC,EAAAA,EAAAA,MAAAA;EACII,WAAAA,CAAAA,MAAAA,EADJJ,mBACII,CADgBH,UAChBG,CAAAA;EACgBD,IAAAA,gBAAAA,CAAAA,CAAAA,EADhBC,MACgBD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EARuDN,OAAAA,UAAAA,CAAAA,GAAAA,EAAAA,OAAAA,CAAAA,EAAAA,GAAAA,IAQvDM,aARuDN;AAAW"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.d.cts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","SystemMessageFields","TStructure","SystemMessage","SystemMessageChunk","isSystemMessage","isSystemMessageChunk"],"sources":["../../src/messages/system.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface SystemMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"system\"> {\n}\n/**\n * Represents a system message in a conversation.\n */\nexport declare class SystemMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"system\"> {\n static lc_name(): string;\n readonly type: \"system\";\n constructor(fields: $InferMessageContent<TStructure, \"system\"> | SystemMessageFields<TStructure>);\n /**\n * Concatenates a string or another system message with the current system message.\n * @param chunk - The chunk to concatenate with the system message.\n * @returns A new system message with the concatenated content.\n */\n concat(chunk: string | SystemMessage): SystemMessage<TStructure>;\n static isInstance(obj: unknown): obj is SystemMessage;\n}\n/**\n * Represents a chunk of a system message, which can be concatenated with\n * other system message chunks.\n */\nexport declare class SystemMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"system\"> {\n static lc_name(): string;\n readonly type: \"system\";\n constructor(fields: $InferMessageContent<TStructure, \"system\"> | SystemMessageFields<TStructure>);\n concat(chunk: SystemMessageChunk<TStructure>): this;\n static isInstance(obj: unknown): obj is SystemMessageChunk;\n}\n/**\n * @deprecated Use {@link SystemMessage.isInstance} instead\n */\nexport declare function isSystemMessage<TStructure extends MessageStructure>(x: BaseMessage): x is SystemMessage<TStructure>;\n/**\n * @deprecated Use {@link SystemMessageChunk.isInstance} instead\n */\nexport declare function isSystemMessageChunk<TStructure extends MessageStructure>(x: BaseMessageChunk): x is SystemMessageChunk<TStructure>;\n//# sourceMappingURL=system.d.ts.map"],"mappings":";;;;UAEiBK,uCAAuCD,mBAAmBA,0BAA0BF,kBAAkBI;AAAvH;;;AAAuHA,cAKlGC,aALkGD,CAAAA,mBAKjEF,gBALiEE,GAK9CF,gBAL8CE,CAAAA,SAKpBN,WALoBM,CAKRA,UALQA,EAAAA,QAAAA,CAAAA,CAAAA;EAAlBJ,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAiB,SAAA,IAAA,EAAA,QAAA;EAKjGK,WAAAA,CAAAA,MAAa,EAGVJ,oBAHU,CAGWG,UAHX,EAAA,QAAA,CAAA,GAGmCD,mBAHnC,CAGuDC,UAHvD,CAAA;EAAoBF;;;;;EAGmCE,MAAAA,CAAAA,KAAAA,EAAAA,MAAAA,GAM9DC,aAN8DD,CAAAA,EAM9CC,aAN8CD,CAMhCA,UANgCA,CAAAA;EAApBD,OAAAA,UAAAA,CAAAA,GAAAA,EAAAA,OAAAA,CAAAA,EAAAA,GAAAA,IAOzBE,aAPyBF;;;;;;AAHyC,cAgBzFG,kBAhByF,CAAA,mBAgBnDJ,gBAhBmD,GAgBhCA,gBAhBgC,CAAA,SAgBNH,gBAhBM,CAgBWK,UAhBX,EAAA,QAAA,CAAA,CAAA;EAgBzFE,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAkB;EAAoBJ,SAAAA,IAAAA,EAAAA,QAAAA;EAAmBA,WAAAA,CAAAA,MAAAA,EAGtDD,oBAHsDC,CAGjCE,UAHiCF,EAAAA,QAAAA,CAAAA,GAGTC,mBAHSD,CAGWE,UAHXF,CAAAA;EAA2CE,MAAAA,CAAAA,KAAAA,EAIvGE,kBAJuGF,CAIpFA,UAJoFA,CAAAA,CAAAA,EAAAA,IAAAA;EAG5EA,OAAAA,UAAAA,CAAAA,GAAAA,EAAAA,OAAAA,CAAAA,EAAAA,GAAAA,IAEDE,kBAFCF;;;;;AAC3BE,iBAMMC,eANND,CAAAA,mBAMyCJ,gBANzCI,CAAAA,CAAAA,CAAAA,EAM8DR,WAN9DQ,CAAAA,EAAAA,CAAAA,IAMiFD,aANjFC,CAM+FF,UAN/FE,CAAAA;;;AAJsG;AAUhGC,iBAIAC,oBAJe,CAAA,mBAIyBN,gBAJzB,CAAA,CAAA,CAAA,EAI8CH,gBAJ9C,CAAA,EAAA,CAAA,IAIsEO,kBAJtE,CAIyFF,UAJzF,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system.d.ts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","SystemMessageFields","TStructure","SystemMessage","SystemMessageChunk","isSystemMessage","isSystemMessageChunk"],"sources":["../../src/messages/system.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface SystemMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"system\"> {\n}\n/**\n * Represents a system message in a conversation.\n */\nexport declare class SystemMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"system\"> {\n static lc_name(): string;\n readonly type: \"system\";\n constructor(fields: $InferMessageContent<TStructure, \"system\"> | SystemMessageFields<TStructure>);\n /**\n * Concatenates a string or another system message with the current system message.\n * @param chunk - The chunk to concatenate with the system message.\n * @returns A new system message with the concatenated content.\n */\n concat(chunk: string | SystemMessage): SystemMessage<TStructure>;\n static isInstance(obj: unknown): obj is SystemMessage;\n}\n/**\n * Represents a chunk of a system message, which can be concatenated with\n * other system message chunks.\n */\nexport declare class SystemMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"system\"> {\n static lc_name(): string;\n readonly type: \"system\";\n constructor(fields: $InferMessageContent<TStructure, \"system\"> | SystemMessageFields<TStructure>);\n concat(chunk: SystemMessageChunk<TStructure>): this;\n static isInstance(obj: unknown): obj is SystemMessageChunk;\n}\n/**\n * @deprecated Use {@link SystemMessage.isInstance} instead\n */\nexport declare function isSystemMessage<TStructure extends MessageStructure>(x: BaseMessage): x is SystemMessage<TStructure>;\n/**\n * @deprecated Use {@link SystemMessageChunk.isInstance} instead\n */\nexport declare function isSystemMessageChunk<TStructure extends MessageStructure>(x: BaseMessageChunk): x is SystemMessageChunk<TStructure>;\n//# sourceMappingURL=system.d.ts.map"],"mappings":";;;;UAEiBK,uCAAuCD,mBAAmBA,0BAA0BF,kBAAkBI;AAAvH;;;AAAuHA,cAKlGC,aALkGD,CAAAA,mBAKjEF,gBALiEE,GAK9CF,gBAL8CE,CAAAA,SAKpBN,WALoBM,CAKRA,UALQA,EAAAA,QAAAA,CAAAA,CAAAA;EAAlBJ,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAiB,SAAA,IAAA,EAAA,QAAA;EAKjGK,WAAAA,CAAAA,MAAa,EAGVJ,oBAHU,CAGWG,UAHX,EAAA,QAAA,CAAA,GAGmCD,mBAHnC,CAGuDC,UAHvD,CAAA;EAAoBF;;;;;EAGmCE,MAAAA,CAAAA,KAAAA,EAAAA,MAAAA,GAM9DC,aAN8DD,CAAAA,EAM9CC,aAN8CD,CAMhCA,UANgCA,CAAAA;EAApBD,OAAAA,UAAAA,CAAAA,GAAAA,EAAAA,OAAAA,CAAAA,EAAAA,GAAAA,IAOzBE,aAPyBF;;;;;;AAHyC,cAgBzFG,kBAhByF,CAAA,mBAgBnDJ,gBAhBmD,GAgBhCA,gBAhBgC,CAAA,SAgBNH,gBAhBM,CAgBWK,UAhBX,EAAA,QAAA,CAAA,CAAA;EAgBzFE,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAkB;EAAoBJ,SAAAA,IAAAA,EAAAA,QAAAA;EAAmBA,WAAAA,CAAAA,MAAAA,EAGtDD,oBAHsDC,CAGjCE,UAHiCF,EAAAA,QAAAA,CAAAA,GAGTC,mBAHSD,CAGWE,UAHXF,CAAAA;EAA2CE,MAAAA,CAAAA,KAAAA,EAIvGE,kBAJuGF,CAIpFA,UAJoFA,CAAAA,CAAAA,EAAAA,IAAAA;EAG5EA,OAAAA,UAAAA,CAAAA,GAAAA,EAAAA,OAAAA,CAAAA,EAAAA,GAAAA,IAEDE,kBAFCF;;;;;AAC3BE,iBAMMC,eANND,CAAAA,mBAMyCJ,gBANzCI,CAAAA,CAAAA,CAAAA,EAM8DR,WAN9DQ,CAAAA,EAAAA,CAAAA,IAMiFD,aANjFC,CAM+FF,UAN/FE,CAAAA;;;AAJsG;AAUhGC,iBAIAC,oBAJe,CAAA,mBAIyBN,gBAJzB,CAAA,CAAA,CAAA,EAI8CH,gBAJ9C,CAAA,EAAA,CAAA,IAIsEO,kBAJtE,CAIyFF,UAJzF,CAAA"}
@@ -10,7 +10,6 @@ interface ToolMessageFields<TStructure extends MessageStructure = MessageStructu
10
10
  * a subset of the full tool output is being passed as message content but the full
11
11
  * output is needed in other parts of the code.
12
12
  */
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
13
  artifact?: any;
15
14
  tool_call_id: string;
16
15
  status?: "success" | "error";
@@ -49,7 +48,6 @@ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure
49
48
  * a subset of the full tool output is being passed as message content but the full
50
49
  * output is needed in other parts of the code.
51
50
  */
52
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
51
  artifact?: any;
54
52
  constructor(fields: $InferMessageContent<TStructure, "tool"> | ToolMessageFields, tool_call_id: string, name?: string);
55
53
  constructor(fields: ToolMessageFields<TStructure>);
@@ -75,16 +73,13 @@ declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStru
75
73
  * a subset of the full tool output is being passed as message content but the full
76
74
  * output is needed in other parts of the code.
77
75
  */
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
76
  artifact?: any;
80
77
  constructor(fields: ToolMessageFields<TStructure>);
81
78
  static lc_name(): string;
82
79
  concat(chunk: ToolMessageChunk<TStructure>): this;
83
80
  get _printableFields(): Record<string, unknown>;
84
81
  }
85
- interface ToolCall<TName extends string = string,
86
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- TArgs extends Record<string, any> = Record<string, any>> {
82
+ interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {
88
83
  readonly type?: "tool_call";
89
84
  /**
90
85
  * If provided, an identifier associated with the tool call
@@ -187,9 +182,7 @@ interface InvalidToolCall<TName extends string = string> {
187
182
  */
188
183
  index?: string | number;
189
184
  }
190
- declare function defaultToolCallParser(
191
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
192
- rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];
185
+ declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];
193
186
  /**
194
187
  * @deprecated Use {@link ToolMessage.isInstance} instead
195
188
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.cts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","Record","DirectToolOutput","isDirectToolOutput","ToolMessage","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n metadata?: Record<string, unknown>;\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n metadata?: Record<string, unknown>;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {\n readonly type?: \"tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n}\n/**\n * A chunk of a tool call (e.g., as part of a stream).\n * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\n * all string attributes are concatenated. Chunks are only merged if their\n * values of `index` are equal and not None.\n *\n * @example\n * ```ts\n * const leftChunks = [\n * {\n * name: \"foo\",\n * args: '{\"a\":',\n * index: 0\n * }\n * ];\n *\n * const leftAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: leftChunks\n * });\n *\n * const rightChunks = [\n * {\n * name: undefined,\n * args: '1}',\n * index: 0\n * }\n * ];\n *\n * const rightAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: rightChunks\n * });\n *\n * const result = leftAIMessageChunk.concat(rightAIMessageChunk);\n * // result.tool_call_chunks is equal to:\n * // [\n * // {\n * // name: \"foo\",\n * // args: '{\"a\":1}'\n * // index: 0\n * // }\n * // ]\n * ```\n */\nexport interface ToolCallChunk<TName extends string = string> {\n readonly type?: \"tool_call_chunk\";\n /**\n * If provided, a substring of an identifier for the tool call\n */\n id?: string;\n /**\n * If provided, a substring of the name of the tool to be called\n */\n name?: TName;\n /**\n * If provided, a JSON substring of the arguments to the tool call\n */\n args?: string;\n /**\n * If provided, the index of the tool call in a sequence\n */\n index?: number;\n}\nexport interface InvalidToolCall<TName extends string = string> {\n readonly type?: \"invalid_tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n}\nexport declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n//# sourceMappingURL=tool.d.ts.map"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH,QAAA,CAAA,EAAA,GAAA;EAoBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAAA,EAhBNH,MAgBiB,CAAA,MAAAD,EAAAA,OAAAA,CAAAA;;;;;;;;;AAqBUA,UA5BzBE,gBAAAA,CA4ByBF;EAAlBD,SAAAA,qBAAAA,EAAAA,IAAAA;;AAEIE,iBA3BJE,kBAAAA,CA2BIF,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BiCC,gBA2BjCD;;;AAvBgI;AA6BvII,cA7BAD,WA6BgBJ,CAAAA,mBA7BeF,gBA6Bf,GA7BkCA,gBA6BlC,CAAA,SA7B4DJ,WA6B5D,CA7BwEM,UA6BxE,EAAA,MAAA,CAAA,YA7BuGE,gBA6BvG,CAAA;EAAoBJ,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAmBA,IAAAA,UAAAA,CAAAA,CAAAA,EA3BtDG,MA2BsDH,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAA2CE,qBAAAA,EAAAA,IAAAA;EAgB7EA,SAAAA,IAAAA,EAAAA,MAAAA;EAAlBD;;;;EAhB8EJ,MAAAA,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAgB,YAAA,EAAA,MAAA;EAqBrGW,QAAAA,CAAAA,EAvCFL,MAuCU,CAAAM,MAAAA,EAAAC,OAAAA,CAAAA;EAA8CP;;;;AAaxD;AA+Cf;AAmBA;EAwBwBU,QAAAA,CAAAA,EAAAA,GAAAA;EAAoCV,WAAAA,CAAAA,MAAAA,EArIpCJ,oBAqIoCI,CArIfD,UAqIeC,EAAAA,MAAAA,CAAAA,GArIOF,iBAqIPE,EAAAA,YAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA;EAAyBK,WAAAA,CAAAA,MAAAA,EApI7DP,iBAoI6DO,CApI3CN,UAoI2CM,CAAAA;EAAYI,OAAAA,UAAAA,CAAAA,OAAAA,EAAAA,OAAAA,CAAAA,EAAAA,OAAAA,IAnI7CN,WAmI6CM;EAAe,IAAA,gBAAA,CAAA,CAAA,EAlIpFT,MAkIoF,CAAA,MAAA,EAAA,OAAA,CAAA;AAIhH;AAIA;;;;cApIqBI,oCAAoCP,mBAAmBA,0BAA0BH,iBAAiBK;;;;;;;;;;;;;;;;sBAgB/FD,kBAAkBC;;gBAExBK,iBAAiBL;0BACPC;;UAEXK,sDAAsDL,sBAAsBA;;;;;;;;;QASnFM;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA,eAAoCV,yBAAyBK,YAAYI;;;;iBAIzEE,aAAAA,mBAAgCR;;;;iBAIhCS,kBAAAA,IAAsBlB,wBAAwBU"}
@@ -10,7 +10,6 @@ interface ToolMessageFields<TStructure extends MessageStructure = MessageStructu
10
10
  * a subset of the full tool output is being passed as message content but the full
11
11
  * output is needed in other parts of the code.
12
12
  */
13
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
13
  artifact?: any;
15
14
  tool_call_id: string;
16
15
  status?: "success" | "error";
@@ -49,7 +48,6 @@ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure
49
48
  * a subset of the full tool output is being passed as message content but the full
50
49
  * output is needed in other parts of the code.
51
50
  */
52
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
51
  artifact?: any;
54
52
  constructor(fields: $InferMessageContent<TStructure, "tool"> | ToolMessageFields, tool_call_id: string, name?: string);
55
53
  constructor(fields: ToolMessageFields<TStructure>);
@@ -75,16 +73,13 @@ declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStru
75
73
  * a subset of the full tool output is being passed as message content but the full
76
74
  * output is needed in other parts of the code.
77
75
  */
78
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
76
  artifact?: any;
80
77
  constructor(fields: ToolMessageFields<TStructure>);
81
78
  static lc_name(): string;
82
79
  concat(chunk: ToolMessageChunk<TStructure>): this;
83
80
  get _printableFields(): Record<string, unknown>;
84
81
  }
85
- interface ToolCall<TName extends string = string,
86
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- TArgs extends Record<string, any> = Record<string, any>> {
82
+ interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {
88
83
  readonly type?: "tool_call";
89
84
  /**
90
85
  * If provided, an identifier associated with the tool call
@@ -187,9 +182,7 @@ interface InvalidToolCall<TName extends string = string> {
187
182
  */
188
183
  index?: string | number;
189
184
  }
190
- declare function defaultToolCallParser(
191
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
192
- rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];
185
+ declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];
193
186
  /**
194
187
  * @deprecated Use {@link ToolMessage.isInstance} instead
195
188
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","Record","DirectToolOutput","isDirectToolOutput","ToolMessage","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n metadata?: Record<string, unknown>;\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n metadata?: Record<string, unknown>;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {\n readonly type?: \"tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n}\n/**\n * A chunk of a tool call (e.g., as part of a stream).\n * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\n * all string attributes are concatenated. Chunks are only merged if their\n * values of `index` are equal and not None.\n *\n * @example\n * ```ts\n * const leftChunks = [\n * {\n * name: \"foo\",\n * args: '{\"a\":',\n * index: 0\n * }\n * ];\n *\n * const leftAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: leftChunks\n * });\n *\n * const rightChunks = [\n * {\n * name: undefined,\n * args: '1}',\n * index: 0\n * }\n * ];\n *\n * const rightAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: rightChunks\n * });\n *\n * const result = leftAIMessageChunk.concat(rightAIMessageChunk);\n * // result.tool_call_chunks is equal to:\n * // [\n * // {\n * // name: \"foo\",\n * // args: '{\"a\":1}'\n * // index: 0\n * // }\n * // ]\n * ```\n */\nexport interface ToolCallChunk<TName extends string = string> {\n readonly type?: \"tool_call_chunk\";\n /**\n * If provided, a substring of an identifier for the tool call\n */\n id?: string;\n /**\n * If provided, a substring of the name of the tool to be called\n */\n name?: TName;\n /**\n * If provided, a JSON substring of the arguments to the tool call\n */\n args?: string;\n /**\n * If provided, the index of the tool call in a sequence\n */\n index?: number;\n}\nexport interface InvalidToolCall<TName extends string = string> {\n readonly type?: \"invalid_tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n}\nexport declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n//# sourceMappingURL=tool.d.ts.map"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH,QAAA,CAAA,EAAA,GAAA;EAoBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAAA,EAhBNH,MAgBiB,CAAA,MAAAD,EAAAA,OAAAA,CAAAA;;;;;;;;;AAqBUA,UA5BzBE,gBAAAA,CA4ByBF;EAAlBD,SAAAA,qBAAAA,EAAAA,IAAAA;;AAEIE,iBA3BJE,kBAAAA,CA2BIF,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BiCC,gBA2BjCD;;;AAvBgI;AA6BvII,cA7BAD,WA6BgBJ,CAAAA,mBA7BeF,g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;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA,eAAoCV,yBAAyBK,YAAYI;;;;iBAIzEE,aAAAA,mBAAgCR;;;;iBAIhCS,kBAAAA,IAAsBlB,wBAAwBU"}
@@ -14,7 +14,6 @@ import { RemoveMessage } from "./modifier.cjs";
14
14
  //#region src/messages/transformers.d.ts
15
15
  type MessageUnion = typeof HumanMessage | typeof AIMessage | typeof SystemMessage | typeof ChatMessage | typeof FunctionMessage | typeof ToolMessage | typeof RemoveMessage;
16
16
  type MessageChunkUnion = typeof HumanMessageChunk | typeof AIMessageChunk | typeof SystemMessageChunk | typeof FunctionMessageChunk | typeof ToolMessageChunk | typeof ChatMessageChunk | typeof RemoveMessage;
17
- // RemoveMessage does not have a chunk class.
18
17
  type MessageTypeOrClass = MessageType | MessageUnion | MessageChunkUnion;
19
18
  interface FilterMessagesFields {
20
19
  /**
@@ -145,8 +144,6 @@ declare function filterMessages(messages: BaseMessage[], options?: FilterMessage
145
144
  */
146
145
  declare function mergeMessageRuns(): Runnable<BaseMessage[], BaseMessage[]>;
147
146
  declare function mergeMessageRuns(messages: BaseMessage[]): BaseMessage[];
148
- // Since we can not import from `@langchain/textsplitters` we need
149
- // to reconstruct the interface here.
150
147
  interface _TextSplitterInterface extends BaseDocumentTransformer {
151
148
  splitText(text: string): Promise<string[]>;
152
149
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformers.d.cts","names":["BaseDocumentTransformer","BaseLanguageModel","Runnable","AIMessage","AIMessageChunk","BaseMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","MessageType","RemoveMessage","SystemMessage","SystemMessageChunk","ToolMessage","ToolMessageChunk","MessageUnion","MessageChunkUnion","MessageTypeOrClass","FilterMessagesFields","filterMessages","mergeMessageRuns","_TextSplitterInterface","Promise","TrimMessagesFields","trimMessages","defaultTextSplitter"],"sources":["../../src/messages/transformers.d.ts"],"sourcesContent":["import { BaseDocumentTransformer } from \"../documents/transformers.js\";\nimport { BaseLanguageModel } from \"../language_models/base.js\";\nimport { Runnable } from \"../runnables/base.js\";\nimport { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { MessageType } from \"./message.js\";\nimport { RemoveMessage } from \"./modifier.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { ToolMessage, ToolMessageChunk } from \"./tool.js\";\nexport type MessageUnion = typeof HumanMessage | typeof AIMessage | typeof SystemMessage | typeof ChatMessage | typeof FunctionMessage | typeof ToolMessage | typeof RemoveMessage;\nexport type MessageChunkUnion = typeof HumanMessageChunk | typeof AIMessageChunk | typeof SystemMessageChunk | typeof FunctionMessageChunk | typeof ToolMessageChunk | typeof ChatMessageChunk | typeof RemoveMessage;\nexport type MessageTypeOrClass = MessageType | MessageUnion | MessageChunkUnion;\nexport interface FilterMessagesFields {\n /**\n * @param {string[] | undefined} includeNames Message names to include.\n */\n includeNames?: string[];\n /**\n * @param {string[] | undefined} excludeNames Messages names to exclude.\n */\n excludeNames?: string[];\n /**\n * @param {(MessageType | BaseMessage)[] | undefined} includeTypes Message types to include. Can be specified as string names (e.g.\n * \"system\", \"human\", \"ai\", ...) or as BaseMessage classes (e.g.\n * SystemMessage, HumanMessage, AIMessage, ...).\n */\n includeTypes?: MessageTypeOrClass[];\n /**\n * @param {(MessageType | BaseMessage)[] | undefined} excludeTypes Message types to exclude. Can be specified as string names (e.g.\n * \"system\", \"human\", \"ai\", ...) or as BaseMessage classes (e.g.\n * SystemMessage, HumanMessage, AIMessage, ...).\n */\n excludeTypes?: MessageTypeOrClass[];\n /**\n * @param {string[] | undefined} includeIds Message IDs to include.\n */\n includeIds?: string[];\n /**\n * @param {string[] | undefined} excludeIds Message IDs to exclude.\n */\n excludeIds?: string[];\n}\n/**\n * Filter messages based on name, type or id.\n *\n * @param {BaseMessage[] | FilterMessagesFields} messagesOrOptions - Either an array of BaseMessage objects to filter or the filtering options. If an array is provided, the `options` parameter should also be supplied. If filtering options are provided, a RunnableLambda is returned.\n * @param {FilterMessagesFields} [options] - Optional filtering options. Should only be provided if `messagesOrOptions` is an array of BaseMessage objects.\n * @returns A list of Messages that meets at least one of the include conditions and none\n * of the exclude conditions, or a RunnableLambda which does the same. If no include conditions are specified then\n * anything that is not explicitly excluded will be included.\n * @throws {Error} If two incompatible arguments are provided.\n *\n * @example\n * ```typescript\n * import { filterMessages, AIMessage, HumanMessage, SystemMessage } from \"@langchain/core/messages\";\n *\n * const messages = [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({ content: \"what's your name\", id: \"foo\", name: \"example_user\" }),\n * new AIMessage({ content: \"steve-o\", id: \"bar\", name: \"example_assistant\" }),\n * new HumanMessage({ content: \"what's your favorite color\", id: \"baz\" }),\n * new AIMessage({ content: \"silicon blue\" , id: \"blah\" }),\n * ];\n *\n * filterMessages(messages, {\n * includeNames: [\"example_user\", \"example_assistant\"],\n * includeTypes: [\"system\"],\n * excludeIds: [\"bar\"],\n * });\n * ```\n *\n * The above example would return:\n * ```typescript\n * [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({ content: \"what's your name\", id: \"foo\", name: \"example_user\" }),\n * ]\n * ```\n */\nexport declare function filterMessages(options?: FilterMessagesFields): Runnable<BaseMessage[], BaseMessage[]>;\nexport declare function filterMessages(messages: BaseMessage[], options?: FilterMessagesFields): BaseMessage[];\n/**\n * Merge consecutive Messages of the same type.\n *\n * **NOTE**: ToolMessages are not merged, as each has a distinct tool call id that\n * can't be merged.\n *\n * @param {BaseMessage[] | undefined} messages Sequence of Message-like objects to merge. Optional. If not provided, a RunnableLambda is returned.\n * @returns List of BaseMessages with consecutive runs of message types merged into single\n * messages, or a RunnableLambda which returns a list of BaseMessages If two messages being merged both have string contents, the merged\n * content is a concatenation of the two strings with a new-line separator. If at\n * least one of the messages has a list of content blocks, the merged content is a\n * list of content blocks.\n *\n * @example\n * ```typescript\n * import { mergeMessageRuns, AIMessage, HumanMessage, SystemMessage, ToolCall } from \"@langchain/core/messages\";\n *\n * const messages = [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({ content: \"what's your favorite color\", id: \"foo\" }),\n * new HumanMessage({ content: \"wait your favorite food\", id: \"bar\" }),\n * new AIMessage({\n * content: \"my favorite colo\",\n * tool_calls: [{ name: \"blah_tool\", args: { x: 2 }, id: \"123\" }],\n * id: \"baz\",\n * }),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"my favorite dish is lasagna\" }],\n * tool_calls: [{ name: \"blah_tool\", args: { x: -10 }, id: \"456\" }],\n * id: \"blur\",\n * }),\n * ];\n *\n * mergeMessageRuns(messages);\n * ```\n *\n * The above example would return:\n * ```typescript\n * [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({\n * content: \"what's your favorite colorwait your favorite food\",\n * id: \"foo\",\n * }),\n * new AIMessage({\n * content: [\n * { type: \"text\", text: \"my favorite colo\" },\n * { type: \"text\", text: \"my favorite dish is lasagna\" },\n * ],\n * tool_calls: [\n * { name: \"blah_tool\", args: { x: 2 }, id: \"123\" },\n * { name: \"blah_tool\", args: { x: -10 }, id: \"456\" },\n * ],\n * id: \"baz\",\n * }),\n * ]\n * ```\n */\nexport declare function mergeMessageRuns(): Runnable<BaseMessage[], BaseMessage[]>;\nexport declare function mergeMessageRuns(messages: BaseMessage[]): BaseMessage[];\ninterface _TextSplitterInterface extends BaseDocumentTransformer {\n splitText(text: string): Promise<string[]>;\n}\nexport interface TrimMessagesFields {\n /**\n * @param {number} maxTokens Max token count of trimmed messages.\n */\n maxTokens: number;\n /**\n * @param {((messages: BaseMessage[]) => number) | ((messages: BaseMessage[]) => Promise<number>) | BaseLanguageModel} tokenCounter\n * Function or LLM for counting tokens in an array of `BaseMessage`s.\n * If a `BaseLanguageModel` is passed in then `BaseLanguageModel.getNumTokens()` will be used.\n */\n tokenCounter: ((messages: BaseMessage[]) => number) | ((messages: BaseMessage[]) => Promise<number>) | BaseLanguageModel;\n /**\n * @param {\"first\" | \"last\"} [strategy=\"last\"] Strategy for trimming.\n * - \"first\": Keep the first <= n_count tokens of the messages.\n * - \"last\": Keep the last <= n_count tokens of the messages.\n * @default \"last\"\n */\n strategy?: \"first\" | \"last\";\n /**\n * @param {boolean} [allowPartial=false] Whether to split a message if only part of the message can be included.\n * If `strategy: \"last\"` then the last partial contents of a message are included.\n * If `strategy: \"first\"` then the first partial contents of a message are included.\n * @default false\n */\n allowPartial?: boolean;\n /**\n * @param {MessageTypeOrClass | MessageTypeOrClass[]} [endOn] The message type to end on.\n * If specified then every message after the last occurrence of this type is ignored.\n * If `strategy === \"last\"` then this is done before we attempt to get the last `maxTokens`.\n * If `strategy === \"first\"` then this is done after we get the first `maxTokens`.\n * Can be specified as string names (e.g. \"system\", \"human\", \"ai\", ...) or as `BaseMessage` classes\n * (e.g. `SystemMessage`, `HumanMessage`, `AIMessage`, ...). Can be a single type or an array of types.\n */\n endOn?: MessageTypeOrClass | MessageTypeOrClass[];\n /**\n * @param {MessageTypeOrClass | MessageTypeOrClass[]} [startOn] The message type to start on.\n * Should only be specified if `strategy: \"last\"`. If specified then every message before the first occurrence\n * of this type is ignored. This is done after we trim the initial messages to the last `maxTokens`.\n * Does not apply to a `SystemMessage` at index 0 if `includeSystem: true`.\n * Can be specified as string names (e.g. \"system\", \"human\", \"ai\", ...) or as `BaseMessage` classes\n * (e.g. `SystemMessage`, `HumanMessage`, `AIMessage`, ...). Can be a single type or an array of types.\n */\n startOn?: MessageTypeOrClass | MessageTypeOrClass[];\n /**\n * @param {boolean} [includeSystem=false] Whether to keep the `SystemMessage` if there is one at index 0.\n * Should only be specified if `strategy: \"last\"`.\n * @default false\n */\n includeSystem?: boolean;\n /**\n * @param {((text: string) => string[]) | BaseDocumentTransformer} [textSplitter] Function or `BaseDocumentTransformer` for\n * splitting the string contents of a message. Only used if `allowPartial: true`.\n * If `strategy: \"last\"` then the last split tokens from a partial message will be included.\n * If `strategy: \"first\"` then the first split tokens from a partial message will be included.\n * Token splitter assumes that separators are kept, so that split contents can be directly concatenated\n * to recreate the original text. Defaults to splitting on newlines.\n */\n textSplitter?: ((text: string) => string[]) | ((text: string) => Promise<string[]>) | _TextSplitterInterface;\n}\n/**\n * Trim messages to be below a token count.\n *\n * @param {BaseMessage[]} messages Array of `BaseMessage` instances to trim.\n * @param {TrimMessagesFields} options Trimming options.\n * @returns An array of trimmed `BaseMessage`s or a `Runnable` that takes a sequence of `BaseMessage`-like objects and returns\n * an array of trimmed `BaseMessage`s.\n * @throws {Error} If two incompatible arguments are specified or an unrecognized `strategy` is specified.\n *\n * @example\n * ```typescript\n * import { trimMessages, AIMessage, BaseMessage, HumanMessage, SystemMessage } from \"@langchain/core/messages\";\n *\n * const messages = [\n * new SystemMessage(\"This is a 4 token text. The full message is 10 tokens.\"),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * new AIMessage({\n * content: [\n * { type: \"text\", text: \"This is the FIRST 4 token block.\" },\n * { type: \"text\", text: \"This is the SECOND 4 token block.\" },\n * ],\n * id: \"second\",\n * }),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ];\n *\n * function dummyTokenCounter(messages: BaseMessage[]): number {\n * // treat each message like it adds 3 default tokens at the beginning\n * // of the message and at the end of the message. 3 + 4 + 3 = 10 tokens\n * // per message.\n *\n * const defaultContentLen = 4;\n * const defaultMsgPrefixLen = 3;\n * const defaultMsgSuffixLen = 3;\n *\n * let count = 0;\n * for (const msg of messages) {\n * if (typeof msg.content === \"string\") {\n * count += defaultMsgPrefixLen + defaultContentLen + defaultMsgSuffixLen;\n * }\n * if (Array.isArray(msg.content)) {\n * count +=\n * defaultMsgPrefixLen +\n * msg.content.length * defaultContentLen +\n * defaultMsgSuffixLen;\n * }\n * }\n * return count;\n * }\n * ```\n *\n * First 30 tokens, not allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"first\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * ]\n * ```\n *\n * First 30 tokens, allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"first\",\n * allowPartial: true,\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"This is the FIRST 4 token block.\" }],\n * id: \"second\",\n * }),\n * ]\n * ```\n *\n * First 30 tokens, allowing partial messages, have to end on HumanMessage:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"first\",\n * allowPartial: true,\n * endOn: \"human\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * ]\n * ```\n *\n * Last 30 tokens, including system message, not allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * includeSystem: true,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ]\n * ```\n *\n * Last 40 tokens, including system message, allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 40,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * allowPartial: true,\n * includeSystem: true,\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"This is the FIRST 4 token block.\" }],\n * id: \"second\",\n * }),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ]\n * ```\n *\n * Last 30 tokens, including system message, allowing partial messages, end on HumanMessage:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * endOn: \"human\",\n * includeSystem: true,\n * allowPartial: true,\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"This is the FIRST 4 token block.\" }],\n * id: \"second\",\n * }),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * ]\n * ```\n *\n * Last 40 tokens, including system message, allowing partial messages, start on HumanMessage:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 40,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * includeSystem: true,\n * allowPartial: true,\n * startOn: \"human\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ]\n * ```\n */\nexport declare function trimMessages(options: TrimMessagesFields): Runnable<BaseMessage[], BaseMessage[]>;\nexport declare function trimMessages(messages: BaseMessage[], options: TrimMessagesFields): Promise<BaseMessage[]>;\n/**\n * The default text splitter function that splits text by newlines.\n *\n * @param {string} text\n * @returns A promise that resolves to an array of strings split by newlines.\n */\nexport declare function defaultTextSplitter(text: string): Promise<string[]>;\nexport {};\n//# sourceMappingURL=transformers.d.ts.map"],"mappings":";;;;;;;;;;;;;;KAYYkB,YAAAA,UAAsBR,sBAAsBP,mBAAmBW,uBAAuBR,qBAAqBE,yBAAyBQ,qBAAqBH;KACzJM,iBAAAA,UAA2BR,2BAA2BP,wBAAwBW,4BAA4BN,8BAA8BQ,0BAA0BV,0BAA0BM;AAD5LK,KAEAE,kBAAAA,GAAqBR,WAFT,GAEuBM,YAFvB,GAEsCC,iBAFtC;AAAUT,UAGjBW,oBAAAA,CAHiBX;EAAsBP;;;EAA+DK,YAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAyBQ;;AAAkC;EACtKG,YAAAA,CAAAA,EAAAA,MAAiB,EAAA;EAAUR;;;;;EAAuIJ,YAAAA,CAAAA,EAgB3Ja,kBAhB2Jb,EAAAA;EAA0BM;AAAa;AACrN;;;EAA8DM,YAAAA,CAAAA,EAqB3CC,kBArB2CD,EAAAA;EAAiB;AAC/E;AAmEA;EAAiDE,UAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EAAgChB;;;EAAD,UAAA,CAAA,EAAA,MAAA,EAAA;AAChF;;;;AAA4G;AA2D5G;;;;AAAoD;AACpD;AAAiF;AAIjF;;;;;;;;;;;AAyDgH;AA6PhH;;;;;AAA2E;AAC3E;;;;;AAAmG;AAOnG;;iBA/XwBiB,cAAAA,WAAyBD,uBAAuBnB,SAASG,eAAeA;iBACxEiB,cAAAA,WAAyBjB,yBAAyBgB,uBAAuBhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2DzEkB,gBAAAA,CAAAA,GAAoBrB,SAASG,eAAeA;iBAC5CkB,gBAAAA,WAA2BlB,gBAAgBA;UACzDmB,sBAAAA,SAA+BxB;2BACZyB;;UAEZC,kBAAAA;;;;;;;;;;4BAUarB,wCAAwCA,kBAAkBoB,mBAAmBxB;;;;;;;;;;;;;;;;;;;;;;;UAuB/FmB,qBAAqBA;;;;;;;;;YASnBA,qBAAqBA;;;;;;;;;;;;;;;mEAekCK,qBAAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6PlEG,YAAAA,UAAsBD,qBAAqBxB,SAASG,eAAeA;iBACnEsB,YAAAA,WAAuBtB,wBAAwBqB,qBAAqBD,QAAQpB;;;;;;;iBAO5EuB,mBAAAA,gBAAmCH"}
@@ -14,7 +14,6 @@ import { RemoveMessage } from "./modifier.js";
14
14
  //#region src/messages/transformers.d.ts
15
15
  type MessageUnion = typeof HumanMessage | typeof AIMessage | typeof SystemMessage | typeof ChatMessage | typeof FunctionMessage | typeof ToolMessage | typeof RemoveMessage;
16
16
  type MessageChunkUnion = typeof HumanMessageChunk | typeof AIMessageChunk | typeof SystemMessageChunk | typeof FunctionMessageChunk | typeof ToolMessageChunk | typeof ChatMessageChunk | typeof RemoveMessage;
17
- // RemoveMessage does not have a chunk class.
18
17
  type MessageTypeOrClass = MessageType | MessageUnion | MessageChunkUnion;
19
18
  interface FilterMessagesFields {
20
19
  /**
@@ -145,8 +144,6 @@ declare function filterMessages(messages: BaseMessage[], options?: FilterMessage
145
144
  */
146
145
  declare function mergeMessageRuns(): Runnable<BaseMessage[], BaseMessage[]>;
147
146
  declare function mergeMessageRuns(messages: BaseMessage[]): BaseMessage[];
148
- // Since we can not import from `@langchain/textsplitters` we need
149
- // to reconstruct the interface here.
150
147
  interface _TextSplitterInterface extends BaseDocumentTransformer {
151
148
  splitText(text: string): Promise<string[]>;
152
149
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformers.d.ts","names":["BaseDocumentTransformer","BaseLanguageModel","Runnable","AIMessage","AIMessageChunk","BaseMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","MessageType","RemoveMessage","SystemMessage","SystemMessageChunk","ToolMessage","ToolMessageChunk","MessageUnion","MessageChunkUnion","MessageTypeOrClass","FilterMessagesFields","filterMessages","mergeMessageRuns","_TextSplitterInterface","Promise","TrimMessagesFields","trimMessages","defaultTextSplitter"],"sources":["../../src/messages/transformers.d.ts"],"sourcesContent":["import { BaseDocumentTransformer } from \"../documents/transformers.js\";\nimport { BaseLanguageModel } from \"../language_models/base.js\";\nimport { Runnable } from \"../runnables/base.js\";\nimport { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { MessageType } from \"./message.js\";\nimport { RemoveMessage } from \"./modifier.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { ToolMessage, ToolMessageChunk } from \"./tool.js\";\nexport type MessageUnion = typeof HumanMessage | typeof AIMessage | typeof SystemMessage | typeof ChatMessage | typeof FunctionMessage | typeof ToolMessage | typeof RemoveMessage;\nexport type MessageChunkUnion = typeof HumanMessageChunk | typeof AIMessageChunk | typeof SystemMessageChunk | typeof FunctionMessageChunk | typeof ToolMessageChunk | typeof ChatMessageChunk | typeof RemoveMessage;\nexport type MessageTypeOrClass = MessageType | MessageUnion | MessageChunkUnion;\nexport interface FilterMessagesFields {\n /**\n * @param {string[] | undefined} includeNames Message names to include.\n */\n includeNames?: string[];\n /**\n * @param {string[] | undefined} excludeNames Messages names to exclude.\n */\n excludeNames?: string[];\n /**\n * @param {(MessageType | BaseMessage)[] | undefined} includeTypes Message types to include. Can be specified as string names (e.g.\n * \"system\", \"human\", \"ai\", ...) or as BaseMessage classes (e.g.\n * SystemMessage, HumanMessage, AIMessage, ...).\n */\n includeTypes?: MessageTypeOrClass[];\n /**\n * @param {(MessageType | BaseMessage)[] | undefined} excludeTypes Message types to exclude. Can be specified as string names (e.g.\n * \"system\", \"human\", \"ai\", ...) or as BaseMessage classes (e.g.\n * SystemMessage, HumanMessage, AIMessage, ...).\n */\n excludeTypes?: MessageTypeOrClass[];\n /**\n * @param {string[] | undefined} includeIds Message IDs to include.\n */\n includeIds?: string[];\n /**\n * @param {string[] | undefined} excludeIds Message IDs to exclude.\n */\n excludeIds?: string[];\n}\n/**\n * Filter messages based on name, type or id.\n *\n * @param {BaseMessage[] | FilterMessagesFields} messagesOrOptions - Either an array of BaseMessage objects to filter or the filtering options. If an array is provided, the `options` parameter should also be supplied. If filtering options are provided, a RunnableLambda is returned.\n * @param {FilterMessagesFields} [options] - Optional filtering options. Should only be provided if `messagesOrOptions` is an array of BaseMessage objects.\n * @returns A list of Messages that meets at least one of the include conditions and none\n * of the exclude conditions, or a RunnableLambda which does the same. If no include conditions are specified then\n * anything that is not explicitly excluded will be included.\n * @throws {Error} If two incompatible arguments are provided.\n *\n * @example\n * ```typescript\n * import { filterMessages, AIMessage, HumanMessage, SystemMessage } from \"@langchain/core/messages\";\n *\n * const messages = [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({ content: \"what's your name\", id: \"foo\", name: \"example_user\" }),\n * new AIMessage({ content: \"steve-o\", id: \"bar\", name: \"example_assistant\" }),\n * new HumanMessage({ content: \"what's your favorite color\", id: \"baz\" }),\n * new AIMessage({ content: \"silicon blue\" , id: \"blah\" }),\n * ];\n *\n * filterMessages(messages, {\n * includeNames: [\"example_user\", \"example_assistant\"],\n * includeTypes: [\"system\"],\n * excludeIds: [\"bar\"],\n * });\n * ```\n *\n * The above example would return:\n * ```typescript\n * [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({ content: \"what's your name\", id: \"foo\", name: \"example_user\" }),\n * ]\n * ```\n */\nexport declare function filterMessages(options?: FilterMessagesFields): Runnable<BaseMessage[], BaseMessage[]>;\nexport declare function filterMessages(messages: BaseMessage[], options?: FilterMessagesFields): BaseMessage[];\n/**\n * Merge consecutive Messages of the same type.\n *\n * **NOTE**: ToolMessages are not merged, as each has a distinct tool call id that\n * can't be merged.\n *\n * @param {BaseMessage[] | undefined} messages Sequence of Message-like objects to merge. Optional. If not provided, a RunnableLambda is returned.\n * @returns List of BaseMessages with consecutive runs of message types merged into single\n * messages, or a RunnableLambda which returns a list of BaseMessages If two messages being merged both have string contents, the merged\n * content is a concatenation of the two strings with a new-line separator. If at\n * least one of the messages has a list of content blocks, the merged content is a\n * list of content blocks.\n *\n * @example\n * ```typescript\n * import { mergeMessageRuns, AIMessage, HumanMessage, SystemMessage, ToolCall } from \"@langchain/core/messages\";\n *\n * const messages = [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({ content: \"what's your favorite color\", id: \"foo\" }),\n * new HumanMessage({ content: \"wait your favorite food\", id: \"bar\" }),\n * new AIMessage({\n * content: \"my favorite colo\",\n * tool_calls: [{ name: \"blah_tool\", args: { x: 2 }, id: \"123\" }],\n * id: \"baz\",\n * }),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"my favorite dish is lasagna\" }],\n * tool_calls: [{ name: \"blah_tool\", args: { x: -10 }, id: \"456\" }],\n * id: \"blur\",\n * }),\n * ];\n *\n * mergeMessageRuns(messages);\n * ```\n *\n * The above example would return:\n * ```typescript\n * [\n * new SystemMessage(\"you're a good assistant.\"),\n * new HumanMessage({\n * content: \"what's your favorite colorwait your favorite food\",\n * id: \"foo\",\n * }),\n * new AIMessage({\n * content: [\n * { type: \"text\", text: \"my favorite colo\" },\n * { type: \"text\", text: \"my favorite dish is lasagna\" },\n * ],\n * tool_calls: [\n * { name: \"blah_tool\", args: { x: 2 }, id: \"123\" },\n * { name: \"blah_tool\", args: { x: -10 }, id: \"456\" },\n * ],\n * id: \"baz\",\n * }),\n * ]\n * ```\n */\nexport declare function mergeMessageRuns(): Runnable<BaseMessage[], BaseMessage[]>;\nexport declare function mergeMessageRuns(messages: BaseMessage[]): BaseMessage[];\ninterface _TextSplitterInterface extends BaseDocumentTransformer {\n splitText(text: string): Promise<string[]>;\n}\nexport interface TrimMessagesFields {\n /**\n * @param {number} maxTokens Max token count of trimmed messages.\n */\n maxTokens: number;\n /**\n * @param {((messages: BaseMessage[]) => number) | ((messages: BaseMessage[]) => Promise<number>) | BaseLanguageModel} tokenCounter\n * Function or LLM for counting tokens in an array of `BaseMessage`s.\n * If a `BaseLanguageModel` is passed in then `BaseLanguageModel.getNumTokens()` will be used.\n */\n tokenCounter: ((messages: BaseMessage[]) => number) | ((messages: BaseMessage[]) => Promise<number>) | BaseLanguageModel;\n /**\n * @param {\"first\" | \"last\"} [strategy=\"last\"] Strategy for trimming.\n * - \"first\": Keep the first <= n_count tokens of the messages.\n * - \"last\": Keep the last <= n_count tokens of the messages.\n * @default \"last\"\n */\n strategy?: \"first\" | \"last\";\n /**\n * @param {boolean} [allowPartial=false] Whether to split a message if only part of the message can be included.\n * If `strategy: \"last\"` then the last partial contents of a message are included.\n * If `strategy: \"first\"` then the first partial contents of a message are included.\n * @default false\n */\n allowPartial?: boolean;\n /**\n * @param {MessageTypeOrClass | MessageTypeOrClass[]} [endOn] The message type to end on.\n * If specified then every message after the last occurrence of this type is ignored.\n * If `strategy === \"last\"` then this is done before we attempt to get the last `maxTokens`.\n * If `strategy === \"first\"` then this is done after we get the first `maxTokens`.\n * Can be specified as string names (e.g. \"system\", \"human\", \"ai\", ...) or as `BaseMessage` classes\n * (e.g. `SystemMessage`, `HumanMessage`, `AIMessage`, ...). Can be a single type or an array of types.\n */\n endOn?: MessageTypeOrClass | MessageTypeOrClass[];\n /**\n * @param {MessageTypeOrClass | MessageTypeOrClass[]} [startOn] The message type to start on.\n * Should only be specified if `strategy: \"last\"`. If specified then every message before the first occurrence\n * of this type is ignored. This is done after we trim the initial messages to the last `maxTokens`.\n * Does not apply to a `SystemMessage` at index 0 if `includeSystem: true`.\n * Can be specified as string names (e.g. \"system\", \"human\", \"ai\", ...) or as `BaseMessage` classes\n * (e.g. `SystemMessage`, `HumanMessage`, `AIMessage`, ...). Can be a single type or an array of types.\n */\n startOn?: MessageTypeOrClass | MessageTypeOrClass[];\n /**\n * @param {boolean} [includeSystem=false] Whether to keep the `SystemMessage` if there is one at index 0.\n * Should only be specified if `strategy: \"last\"`.\n * @default false\n */\n includeSystem?: boolean;\n /**\n * @param {((text: string) => string[]) | BaseDocumentTransformer} [textSplitter] Function or `BaseDocumentTransformer` for\n * splitting the string contents of a message. Only used if `allowPartial: true`.\n * If `strategy: \"last\"` then the last split tokens from a partial message will be included.\n * If `strategy: \"first\"` then the first split tokens from a partial message will be included.\n * Token splitter assumes that separators are kept, so that split contents can be directly concatenated\n * to recreate the original text. Defaults to splitting on newlines.\n */\n textSplitter?: ((text: string) => string[]) | ((text: string) => Promise<string[]>) | _TextSplitterInterface;\n}\n/**\n * Trim messages to be below a token count.\n *\n * @param {BaseMessage[]} messages Array of `BaseMessage` instances to trim.\n * @param {TrimMessagesFields} options Trimming options.\n * @returns An array of trimmed `BaseMessage`s or a `Runnable` that takes a sequence of `BaseMessage`-like objects and returns\n * an array of trimmed `BaseMessage`s.\n * @throws {Error} If two incompatible arguments are specified or an unrecognized `strategy` is specified.\n *\n * @example\n * ```typescript\n * import { trimMessages, AIMessage, BaseMessage, HumanMessage, SystemMessage } from \"@langchain/core/messages\";\n *\n * const messages = [\n * new SystemMessage(\"This is a 4 token text. The full message is 10 tokens.\"),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * new AIMessage({\n * content: [\n * { type: \"text\", text: \"This is the FIRST 4 token block.\" },\n * { type: \"text\", text: \"This is the SECOND 4 token block.\" },\n * ],\n * id: \"second\",\n * }),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ];\n *\n * function dummyTokenCounter(messages: BaseMessage[]): number {\n * // treat each message like it adds 3 default tokens at the beginning\n * // of the message and at the end of the message. 3 + 4 + 3 = 10 tokens\n * // per message.\n *\n * const defaultContentLen = 4;\n * const defaultMsgPrefixLen = 3;\n * const defaultMsgSuffixLen = 3;\n *\n * let count = 0;\n * for (const msg of messages) {\n * if (typeof msg.content === \"string\") {\n * count += defaultMsgPrefixLen + defaultContentLen + defaultMsgSuffixLen;\n * }\n * if (Array.isArray(msg.content)) {\n * count +=\n * defaultMsgPrefixLen +\n * msg.content.length * defaultContentLen +\n * defaultMsgSuffixLen;\n * }\n * }\n * return count;\n * }\n * ```\n *\n * First 30 tokens, not allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"first\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * ]\n * ```\n *\n * First 30 tokens, allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"first\",\n * allowPartial: true,\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"This is the FIRST 4 token block.\" }],\n * id: \"second\",\n * }),\n * ]\n * ```\n *\n * First 30 tokens, allowing partial messages, have to end on HumanMessage:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"first\",\n * allowPartial: true,\n * endOn: \"human\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"first\",\n * }),\n * ]\n * ```\n *\n * Last 30 tokens, including system message, not allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * includeSystem: true,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ]\n * ```\n *\n * Last 40 tokens, including system message, allowing partial messages:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 40,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * allowPartial: true,\n * includeSystem: true,\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"This is the FIRST 4 token block.\" }],\n * id: \"second\",\n * }),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ]\n * ```\n *\n * Last 30 tokens, including system message, allowing partial messages, end on HumanMessage:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 30,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * endOn: \"human\",\n * includeSystem: true,\n * allowPartial: true,\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new AIMessage({\n * content: [{ type: \"text\", text: \"This is the FIRST 4 token block.\" }],\n * id: \"second\",\n * }),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * ]\n * ```\n *\n * Last 40 tokens, including system message, allowing partial messages, start on HumanMessage:\n * ```typescript\n * await trimMessages(messages, {\n * maxTokens: 40,\n * tokenCounter: dummyTokenCounter,\n * strategy: \"last\",\n * includeSystem: true,\n * allowPartial: true,\n * startOn: \"human\",\n * });\n * ```\n *\n * Output:\n * ```typescript\n * [\n * new SystemMessage(\n * \"This is a 4 token text. The full message is 10 tokens.\"\n * ),\n * new HumanMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"third\",\n * }),\n * new AIMessage({\n * content: \"This is a 4 token text. The full message is 10 tokens.\",\n * id: \"fourth\",\n * }),\n * ]\n * ```\n */\nexport declare function trimMessages(options: TrimMessagesFields): Runnable<BaseMessage[], BaseMessage[]>;\nexport declare function trimMessages(messages: BaseMessage[], options: TrimMessagesFields): Promise<BaseMessage[]>;\n/**\n * The default text splitter function that splits text by newlines.\n *\n * @param {string} text\n * @returns A promise that resolves to an array of strings split by newlines.\n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;;;;;;;;;;;;UAuB/FmB,qBAAqBA;;;;;;;;;YASnBA,qBAAqBA;;;;;;;;;;;;;;;mEAekCK,qBAAqBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6PlEG,YAAAA,UAAsBD,qBAAqBxB,SAASG,eAAeA;iBACnEsB,YAAAA,WAAuBtB,wBAAwBqB,qBAAqBD,QAAQpB;;;;;;;iBAO5EuB,mBAAAA,gBAAmCH"}
@@ -63,9 +63,7 @@ type $OnlyIndexSignatures<T$1> = $HasIndexSignature<T$1> extends true ? [$KnownK
63
63
  * // }
64
64
  * ```
65
65
  */
66
- type $MergeObjects<T$1, U$1> =
67
- // If U is purely index-signature based, prefer U as a whole
68
- $OnlyIndexSignatures<U$1> extends true ? U$1 : $OnlyIndexSignatures<T$1> extends true ? U$1 : { [K in keyof T$1 | keyof U$1]: K extends keyof T$1 ? K extends keyof U$1 ? T$1[K] extends Record<string, unknown> ? U$1[K] extends Record<string, unknown> ? $MergeObjects<T$1[K], U$1[K]> : U$1[K] : U$1[K] : T$1[K] : K extends keyof U$1 ? U$1[K] : never };
66
+ type $MergeObjects<T$1, U$1> = $OnlyIndexSignatures<U$1> extends true ? U$1 : $OnlyIndexSignatures<T$1> extends true ? U$1 : { [K in keyof T$1 | keyof U$1]: K extends keyof T$1 ? K extends keyof U$1 ? T$1[K] extends Record<string, unknown> ? U$1[K] extends Record<string, unknown> ? $MergeObjects<T$1[K], U$1[K]> : U$1[K] : U$1[K] : T$1[K] : K extends keyof U$1 ? U$1[K] : never };
69
67
  /**
70
68
  * Merges two discriminated unions A and B based on a discriminator key (defaults to "type").
71
69
  * For each possible value of the discriminator across both unions:
@@ -77,8 +75,7 @@ $OnlyIndexSignatures<U$1> extends true ? U$1 : $OnlyIndexSignatures<T$1> extends
77
75
  * @template B - Second discriminated union type that extends Record<Key, PropertyKey>
78
76
  * @template Key - The discriminator key property, defaults to "type"
79
77
  */
80
- type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = "type"> = { [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] // Check if B has a member with this discriminator value
81
- ? Extract<A, Record<Key, T>> : [Extract<A, Record<Key, T>>] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>> }[A[Key] | B[Key]];
78
+ type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = "type"> = { [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [Extract<A, Record<Key, T>>] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>> }[A[Key] | B[Key]];
82
79
  type Constructor<T$1> = new (...args: unknown[]) => T$1;
83
80
  /**
84
81
  * Immediately-invoked function expression.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.cts","names":["AIMessage","AIMessageChunk","BaseMessageLike","BaseMessage","StoredMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","SystemMessage","SystemMessageChunk","InvalidToolCall","ToolCall","ToolCallChunk","ToolMessage","$Expand","T","U","K","$KnownKeys","$HasIndexSignature","$OnlyIndexSignatures","$MergeObjects","Record","$MergeDiscriminatedUnion","A","B","Key","PropertyKey","Extract","Constructor","iife","coerceMessageLikeToMessage","getBufferString","mapStoredMessageToChatMessage","__message_js0","MessageStructure","mapStoredMessagesToChatMessages","mapChatMessagesToStoredMessages","convertToChunk","collapseToolCallChunks"],"sources":["../../src/messages/utils.d.ts"],"sourcesContent":["import { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessageLike, BaseMessage, StoredMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage } from \"./tool.js\";\nexport type $Expand<T> = T extends infer U ? {\n [K in keyof U]: U[K];\n} : never;\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : symbol extends K ? never : K;\n}[keyof T];\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T ? true : number extends keyof T ? true : symbol extends keyof T ? true : false;\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> = $HasIndexSignature<T> extends true ? [$KnownKeys<T>] extends [never] ? true : false : false;\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> = $OnlyIndexSignatures<U> extends true ? U : $OnlyIndexSignatures<T> extends true ? U : {\n [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] extends Record<string, unknown> ? U[K] extends Record<string, unknown> ? $MergeObjects<T[K], U[K]> : U[K] : U[K] : T[K] : K extends keyof U ? U[K] : never;\n};\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = \"type\"> = {\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [\n Extract<A, Record<Key, T>>\n ] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n}[A[Key] | B[Key]];\nexport type Constructor<T> = new (...args: unknown[]) => T;\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseMessage;\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n */\nexport declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;\nexport declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<import(\"./message.js\").MessageStructure> | ChatMessage<import(\"./message.js\").MessageStructure> | FunctionMessage<import(\"./message.js\").MessageStructure> | HumanMessage<import(\"./message.js\").MessageStructure> | SystemMessage<import(\"./message.js\").MessageStructure> | ToolMessage<import(\"./message.js\").MessageStructure>;\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): BaseMessage[];\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];\nexport declare function convertToChunk(message: BaseMessage): AIMessageChunk<import(\"./message.js\").MessageStructure> | ChatMessageChunk<import(\"./message.js\").MessageStructure> | FunctionMessageChunk<import(\"./message.js\").MessageStructure> | HumanMessageChunk<import(\"./message.js\").MessageStructure> | SystemMessageChunk<import(\"./message.js\").MessageStructure>;\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport declare function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n};\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;KAOYiB,eAAaC,oCACTC,IAAIA,EAAEC;AADtB;;;;;AACuB;AACb,KAOLC,UAAAA,CAAAA,GAAU,CAAA,GAAA,QACCH,MAAAA,GAAAA,GAAAA,MAAAA,SAAmBE,CAAnBF,GAAAA,KAAAA,GAAAA,MAAAA,SAA8CE,CAA9CF,GAAAA,KAAAA,GAAAA,MAAAA,SAAyEE,CAAzEF,GAAAA,KAAAA,GAAqFE,CAArFF,EAAmBE,CAAAA,MAC3BF,GAD2BE,CAAAA;;;;;AAC1B;AAAA;KAOJE,kBAA6CJ,CAAAA,GAAAA,CAAAA,GAAAA,MAAAA,SAAAA,MAAAA,GAAAA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgCA,GAAhCA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgEA,GAAhEA,GAAAA,IAAAA,GAAAA,KAAAA;;;AAAiE;AAAA;;;KAO9GK,oBAA2EL,CAAAA,GAAAA,CAAAA,GAAjDI,kBAAiDJ,CAA9BA,GAA8BA,CAAAA,SAAAA,IAAAA,GAAAA,CAAXG,UAAWH,CAAAA,GAAAA,CAAAA,CAAAA,SAAAA,CAAAA,KAAAA,CAAAA,GAAAA,IAAAA,GAAAA,KAAAA,GAAAA,KAAAA;;AAAD;AAkC/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACqNC,KADzMK,aACyML,CAAAA,GAAAA,EAAAA,GAAAA,CAAAA,GADnLI,oBACmLJ,CAD9JA,GAC8JA,CAAAA,SAAAA,IAAA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,GAgB+PP,aAhB/PO,kBAAAA,GAgBwTF,WAhBxTE,kBAAAA;;;;;;;;;AAAkEW,iBAyBzFU,+BAAAA,CAzByFV,QAAAA,EAyB/CzB,aAzB+CyB,EAAAA,CAAAA,EAyB7B1B,WAzB6B0B,EAAAA;;;;;;;AACtGD,iBA+BaY,+BAAAA,CA/BbZ,QAAAA,EA+BuDzB,WA/BvDyB,EAAAA,CAAAA,EA+BuExB,aA/BvEwB,EAAAA;AAAEC,iBAgCWY,cAAAA,CAhCXZ,OAAAA,EAgCmC1B,WAhCnC0B,CAAAA,EAgCiD5B,cAhCjD4B,kBAAAA,GAgC2GvB,gBAhC3GuB,kBAAAA,GAgCuKrB,oBAhCvKqB,kBAAAA,GAgCuOnB,iBAhCvOmB,kBAAAA,GAgCoSjB,kBAhCpSiB,kBAAAA;AAAG;AAChB;AAOA;AACA;AAKA;AACA;;;;;;;;;;;;;;AAAkX;AASlX;AAOA;AACA;;;;iBA2BwBa,sBAAAA,SAA+B3B;EA3BiET,gBAAAA,EA4BlGS,aA5BkGT,EAAAA;cA6BxGQ;EA7BoKN,kBAAAA,EA8B5JK,eA9B4JL,EAAAA"}
@@ -63,9 +63,7 @@ type $OnlyIndexSignatures<T$1> = $HasIndexSignature<T$1> extends true ? [$KnownK
63
63
  * // }
64
64
  * ```
65
65
  */
66
- type $MergeObjects<T$1, U$1> =
67
- // If U is purely index-signature based, prefer U as a whole
68
- $OnlyIndexSignatures<U$1> extends true ? U$1 : $OnlyIndexSignatures<T$1> extends true ? U$1 : { [K in keyof T$1 | keyof U$1]: K extends keyof T$1 ? K extends keyof U$1 ? T$1[K] extends Record<string, unknown> ? U$1[K] extends Record<string, unknown> ? $MergeObjects<T$1[K], U$1[K]> : U$1[K] : U$1[K] : T$1[K] : K extends keyof U$1 ? U$1[K] : never };
66
+ type $MergeObjects<T$1, U$1> = $OnlyIndexSignatures<U$1> extends true ? U$1 : $OnlyIndexSignatures<T$1> extends true ? U$1 : { [K in keyof T$1 | keyof U$1]: K extends keyof T$1 ? K extends keyof U$1 ? T$1[K] extends Record<string, unknown> ? U$1[K] extends Record<string, unknown> ? $MergeObjects<T$1[K], U$1[K]> : U$1[K] : U$1[K] : T$1[K] : K extends keyof U$1 ? U$1[K] : never };
69
67
  /**
70
68
  * Merges two discriminated unions A and B based on a discriminator key (defaults to "type").
71
69
  * For each possible value of the discriminator across both unions:
@@ -77,8 +75,7 @@ $OnlyIndexSignatures<U$1> extends true ? U$1 : $OnlyIndexSignatures<T$1> extends
77
75
  * @template B - Second discriminated union type that extends Record<Key, PropertyKey>
78
76
  * @template Key - The discriminator key property, defaults to "type"
79
77
  */
80
- type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = "type"> = { [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] // Check if B has a member with this discriminator value
81
- ? Extract<A, Record<Key, T>> : [Extract<A, Record<Key, T>>] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>> }[A[Key] | B[Key]];
78
+ type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = "type"> = { [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [Extract<A, Record<Key, T>>] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>> }[A[Key] | B[Key]];
82
79
  type Constructor<T$1> = new (...args: unknown[]) => T$1;
83
80
  /**
84
81
  * Immediately-invoked function expression.