langchain 1.0.0-alpha.5 → 1.0.0-alpha.7

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 (405) hide show
  1. package/dist/agents/ReactAgent.cjs +5 -5
  2. package/dist/agents/ReactAgent.cjs.map +1 -1
  3. package/dist/agents/ReactAgent.d.cts +2 -5
  4. package/dist/agents/ReactAgent.d.cts.map +1 -1
  5. package/dist/agents/ReactAgent.d.ts +2 -5
  6. package/dist/agents/ReactAgent.d.ts.map +1 -1
  7. package/dist/agents/ReactAgent.js +6 -6
  8. package/dist/agents/ReactAgent.js.map +1 -1
  9. package/dist/agents/annotation.cjs.map +1 -1
  10. package/dist/agents/annotation.d.cts +13 -8
  11. package/dist/agents/annotation.d.cts.map +1 -1
  12. package/dist/agents/annotation.d.ts +13 -8
  13. package/dist/agents/annotation.d.ts.map +1 -1
  14. package/dist/agents/annotation.js.map +1 -1
  15. package/dist/agents/createAgent.cjs.map +1 -1
  16. package/dist/agents/createAgent.js.map +1 -1
  17. package/dist/agents/index.cjs +2 -2
  18. package/dist/agents/index.cjs.map +1 -1
  19. package/dist/agents/index.d.cts +50 -50
  20. package/dist/agents/index.d.cts.map +1 -1
  21. package/dist/agents/index.d.ts +50 -50
  22. package/dist/agents/index.d.ts.map +1 -1
  23. package/dist/agents/index.js +2 -2
  24. package/dist/agents/index.js.map +1 -1
  25. package/dist/agents/interrupt.d.cts +14 -1
  26. package/dist/agents/interrupt.d.cts.map +1 -1
  27. package/dist/agents/interrupt.d.ts +14 -1
  28. package/dist/agents/interrupt.d.ts.map +1 -1
  29. package/dist/agents/middlewareAgent/ReactAgent.cjs +273 -66
  30. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
  31. package/dist/agents/middlewareAgent/ReactAgent.d.cts +102 -16
  32. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
  33. package/dist/agents/middlewareAgent/ReactAgent.d.ts +102 -16
  34. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
  35. package/dist/agents/middlewareAgent/ReactAgent.js +275 -68
  36. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
  37. package/dist/agents/middlewareAgent/annotation.cjs +12 -6
  38. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
  39. package/dist/agents/middlewareAgent/annotation.js +12 -6
  40. package/dist/agents/middlewareAgent/annotation.js.map +1 -1
  41. package/dist/agents/middlewareAgent/constants.d.cts +5 -0
  42. package/dist/agents/middlewareAgent/constants.d.cts.map +1 -0
  43. package/dist/agents/middlewareAgent/constants.d.ts +5 -0
  44. package/dist/agents/middlewareAgent/constants.d.ts.map +1 -0
  45. package/dist/agents/middlewareAgent/index.cjs.map +1 -1
  46. package/dist/agents/middlewareAgent/index.js.map +1 -1
  47. package/dist/agents/middlewareAgent/middleware/bigTool.cjs +162 -0
  48. package/dist/agents/middlewareAgent/middleware/bigTool.cjs.map +1 -0
  49. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts +113 -0
  50. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts.map +1 -0
  51. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts +113 -0
  52. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts.map +1 -0
  53. package/dist/agents/middlewareAgent/middleware/bigTool.js +161 -0
  54. package/dist/agents/middlewareAgent/middleware/bigTool.js.map +1 -0
  55. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs +58 -0
  56. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs.map +1 -0
  57. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts +46 -0
  58. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts.map +1 -0
  59. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts +46 -0
  60. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts.map +1 -0
  61. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js +58 -0
  62. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js.map +1 -0
  63. package/dist/agents/middlewareAgent/middleware/hitl.cjs +311 -0
  64. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -0
  65. package/dist/agents/middlewareAgent/middleware/hitl.d.cts +419 -0
  66. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -0
  67. package/dist/agents/middlewareAgent/middleware/hitl.d.ts +419 -0
  68. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -0
  69. package/dist/agents/middlewareAgent/middleware/hitl.js +310 -0
  70. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -0
  71. package/dist/agents/middlewareAgent/middleware/index.cjs +32 -0
  72. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -0
  73. package/dist/agents/middlewareAgent/middleware/index.d.cts +6 -0
  74. package/dist/agents/middlewareAgent/middleware/index.d.ts +6 -0
  75. package/dist/agents/middlewareAgent/middleware/index.js +21 -0
  76. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -0
  77. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.cjs +72 -27
  78. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -0
  79. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.cts +60 -15
  80. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -0
  81. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.ts +60 -15
  82. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -0
  83. package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.js +71 -26
  84. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -0
  85. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.cjs +35 -23
  86. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -0
  87. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.cts +7 -5
  88. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -0
  89. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.ts +7 -5
  90. package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +1 -0
  91. package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.js +29 -17
  92. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -0
  93. package/dist/agents/middlewareAgent/middleware.cjs +8 -5
  94. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
  95. package/dist/agents/middlewareAgent/middleware.d.cts +67 -7
  96. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
  97. package/dist/agents/middlewareAgent/middleware.d.ts +67 -7
  98. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
  99. package/dist/agents/middlewareAgent/middleware.js +8 -5
  100. package/dist/agents/middlewareAgent/middleware.js.map +1 -1
  101. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +2 -2
  102. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
  103. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +2 -2
  104. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
  105. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +125 -83
  106. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
  107. package/dist/agents/middlewareAgent/nodes/AgentNode.js +128 -86
  108. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
  109. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +2 -2
  110. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
  111. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +2 -2
  112. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
  113. package/dist/agents/middlewareAgent/nodes/middleware.cjs +42 -17
  114. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
  115. package/dist/agents/middlewareAgent/nodes/middleware.js +42 -18
  116. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
  117. package/dist/agents/middlewareAgent/nodes/utils.cjs +30 -16
  118. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
  119. package/dist/agents/middlewareAgent/nodes/utils.js +28 -14
  120. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
  121. package/dist/agents/middlewareAgent/types.d.cts +162 -88
  122. package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
  123. package/dist/agents/middlewareAgent/types.d.ts +162 -88
  124. package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
  125. package/dist/agents/model.cjs +13 -0
  126. package/dist/agents/model.cjs.map +1 -0
  127. package/dist/agents/model.js +11 -0
  128. package/dist/agents/model.js.map +1 -0
  129. package/dist/agents/nodes/AgentNode.cjs +60 -32
  130. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  131. package/dist/agents/nodes/AgentNode.js +61 -33
  132. package/dist/agents/nodes/AgentNode.js.map +1 -1
  133. package/dist/agents/nodes/ToolNode.cjs +4 -4
  134. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  135. package/dist/agents/nodes/ToolNode.d.cts +2 -3
  136. package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
  137. package/dist/agents/nodes/ToolNode.d.ts +1 -2
  138. package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
  139. package/dist/agents/nodes/ToolNode.js +5 -5
  140. package/dist/agents/nodes/ToolNode.js.map +1 -1
  141. package/dist/agents/responses.cjs +53 -11
  142. package/dist/agents/responses.cjs.map +1 -1
  143. package/dist/agents/responses.d.cts +12 -20
  144. package/dist/agents/responses.d.cts.map +1 -1
  145. package/dist/agents/responses.d.ts +12 -20
  146. package/dist/agents/responses.d.ts.map +1 -1
  147. package/dist/agents/responses.js +53 -12
  148. package/dist/agents/responses.js.map +1 -1
  149. package/dist/agents/types.d.cts +3 -6
  150. package/dist/agents/types.d.cts.map +1 -1
  151. package/dist/agents/types.d.ts +3 -6
  152. package/dist/agents/types.d.ts.map +1 -1
  153. package/dist/agents/utils.cjs +11 -29
  154. package/dist/agents/utils.cjs.map +1 -1
  155. package/dist/agents/utils.js +9 -26
  156. package/dist/agents/utils.js.map +1 -1
  157. package/dist/agents/withAgentName.cjs.map +1 -1
  158. package/dist/agents/withAgentName.js.map +1 -1
  159. package/dist/chains/api/prompts.cjs.map +1 -1
  160. package/dist/chains/api/prompts.js.map +1 -1
  161. package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
  162. package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
  163. package/dist/chains/index.cjs +0 -3
  164. package/dist/chains/index.cjs.map +1 -1
  165. package/dist/chains/index.d.cts +1 -2
  166. package/dist/chains/index.d.ts +1 -2
  167. package/dist/chains/index.js +1 -3
  168. package/dist/chains/index.js.map +1 -1
  169. package/dist/chains/openai_functions/extraction.cjs.map +1 -1
  170. package/dist/chains/openai_functions/extraction.d.cts +1 -3
  171. package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
  172. package/dist/chains/openai_functions/extraction.d.ts +1 -3
  173. package/dist/chains/openai_functions/extraction.d.ts.map +1 -1
  174. package/dist/chains/openai_functions/extraction.js.map +1 -1
  175. package/dist/chains/openai_functions/index.cjs +0 -5
  176. package/dist/chains/openai_functions/index.cjs.map +1 -1
  177. package/dist/chains/openai_functions/index.d.cts +1 -2
  178. package/dist/chains/openai_functions/index.d.ts +1 -2
  179. package/dist/chains/openai_functions/index.js +1 -4
  180. package/dist/chains/openai_functions/index.js.map +1 -1
  181. package/dist/chains/openai_functions/openapi.cjs +4 -4
  182. package/dist/chains/openai_functions/openapi.cjs.map +1 -1
  183. package/dist/chains/openai_functions/openapi.d.cts +1 -1
  184. package/dist/chains/openai_functions/openapi.js +4 -4
  185. package/dist/chains/openai_functions/openapi.js.map +1 -1
  186. package/dist/chains/openai_functions/tagging.cjs.map +1 -1
  187. package/dist/chains/openai_functions/tagging.d.cts +1 -3
  188. package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
  189. package/dist/chains/openai_functions/tagging.d.ts +1 -3
  190. package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
  191. package/dist/chains/openai_functions/tagging.js.map +1 -1
  192. package/dist/chains/query_constructor/index.cjs +4 -4
  193. package/dist/chains/query_constructor/index.cjs.map +1 -1
  194. package/dist/chains/query_constructor/index.d.cts +4 -2
  195. package/dist/chains/query_constructor/index.d.cts.map +1 -1
  196. package/dist/chains/query_constructor/index.d.ts +4 -2
  197. package/dist/chains/query_constructor/index.d.ts.map +1 -1
  198. package/dist/chains/query_constructor/index.js +1 -1
  199. package/dist/chains/query_constructor/index.js.map +1 -1
  200. package/dist/chains/question_answering/load.d.ts +2 -2
  201. package/dist/chains/question_answering/load.d.ts.map +1 -1
  202. package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
  203. package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
  204. package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
  205. package/dist/chains/question_answering/refine_prompts.js.map +1 -1
  206. package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
  207. package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
  208. package/dist/chains/router/multi_prompt.cjs +4 -4
  209. package/dist/chains/router/multi_prompt.cjs.map +1 -1
  210. package/dist/chains/router/multi_prompt.js +1 -1
  211. package/dist/chains/router/multi_prompt.js.map +1 -1
  212. package/dist/chains/router/multi_retrieval_qa.cjs +4 -4
  213. package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
  214. package/dist/chains/router/multi_retrieval_qa.js +1 -1
  215. package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
  216. package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
  217. package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
  218. package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
  219. package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
  220. package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
  221. package/dist/chains/summarization/stuff_prompts.js.map +1 -1
  222. package/dist/chat_models/universal.cjs +8 -5
  223. package/dist/chat_models/universal.cjs.map +1 -1
  224. package/dist/chat_models/universal.d.cts +2 -2
  225. package/dist/chat_models/universal.d.cts.map +1 -1
  226. package/dist/chat_models/universal.d.ts +2 -2
  227. package/dist/chat_models/universal.d.ts.map +1 -1
  228. package/dist/chat_models/universal.js +8 -5
  229. package/dist/chat_models/universal.js.map +1 -1
  230. package/dist/document_loaders/fs/directory.cjs.map +1 -1
  231. package/dist/document_loaders/fs/directory.d.cts +0 -1
  232. package/dist/document_loaders/fs/directory.d.cts.map +1 -1
  233. package/dist/document_loaders/fs/directory.d.ts +0 -1
  234. package/dist/document_loaders/fs/directory.d.ts.map +1 -1
  235. package/dist/document_loaders/fs/directory.js.map +1 -1
  236. package/dist/document_loaders/fs/json.cjs +7 -1
  237. package/dist/document_loaders/fs/json.cjs.map +1 -1
  238. package/dist/document_loaders/fs/json.js +7 -1
  239. package/dist/document_loaders/fs/json.js.map +1 -1
  240. package/dist/embeddings/cache_backed.cjs +1 -1
  241. package/dist/embeddings/cache_backed.cjs.map +1 -1
  242. package/dist/embeddings/cache_backed.d.cts +1 -1
  243. package/dist/embeddings/cache_backed.d.ts +2 -2
  244. package/dist/embeddings/cache_backed.js +2 -2
  245. package/dist/embeddings/cache_backed.js.map +1 -1
  246. package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
  247. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  248. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  249. package/dist/evaluation/embedding_distance/base.cjs +2 -4
  250. package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
  251. package/dist/evaluation/embedding_distance/base.js +2 -3
  252. package/dist/evaluation/embedding_distance/base.js.map +1 -1
  253. package/dist/evaluation/loader.cjs +7 -12
  254. package/dist/evaluation/loader.cjs.map +1 -1
  255. package/dist/evaluation/loader.d.cts +8 -2
  256. package/dist/evaluation/loader.d.cts.map +1 -1
  257. package/dist/evaluation/loader.d.ts +8 -2
  258. package/dist/evaluation/loader.d.ts.map +1 -1
  259. package/dist/evaluation/loader.js +7 -12
  260. package/dist/evaluation/loader.js.map +1 -1
  261. package/dist/hub/base.cjs.map +1 -1
  262. package/dist/hub/base.js.map +1 -1
  263. package/dist/index.cjs +38 -6
  264. package/dist/index.cjs.map +1 -1
  265. package/dist/index.d.cts +11 -4
  266. package/dist/index.d.ts +11 -4
  267. package/dist/index.js +18 -4
  268. package/dist/index.js.map +1 -1
  269. package/dist/langchain-core/dist/load/serializable.d.cts.map +1 -1
  270. package/dist/langchain-core/dist/messages/base.d.cts +24 -33
  271. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  272. package/dist/langchain-core/dist/messages/content/index.d.cts +21 -2
  273. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  274. package/dist/langchain-core/dist/messages/content/tools.d.cts +67 -6
  275. package/dist/langchain-core/dist/messages/content/tools.d.cts.map +1 -1
  276. package/dist/langchain-core/dist/messages/message.d.cts +598 -0
  277. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -0
  278. package/dist/langchain-core/dist/messages/metadata.d.cts +97 -0
  279. package/dist/langchain-core/dist/messages/metadata.d.cts.map +1 -0
  280. package/dist/langchain-core/dist/messages/utils.d.cts +75 -0
  281. package/dist/langchain-core/dist/messages/utils.d.cts.map +1 -0
  282. package/dist/langchain-core/dist/prompt_values.d.cts.map +1 -1
  283. package/dist/langchain-core/dist/utils/types/index.d.cts.map +1 -1
  284. package/dist/libs/langchain-core/dist/load/serializable.d.ts.map +1 -1
  285. package/dist/libs/langchain-core/dist/messages/base.d.ts +24 -33
  286. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  287. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +21 -2
  288. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  289. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts +67 -6
  290. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts.map +1 -1
  291. package/dist/libs/langchain-core/dist/messages/message.d.ts +598 -0
  292. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -0
  293. package/dist/libs/langchain-core/dist/messages/metadata.d.ts +97 -0
  294. package/dist/libs/langchain-core/dist/messages/metadata.d.ts.map +1 -0
  295. package/dist/libs/langchain-core/dist/messages/utils.d.ts +75 -0
  296. package/dist/libs/langchain-core/dist/messages/utils.d.ts.map +1 -0
  297. package/dist/libs/langchain-core/dist/prompt_values.d.ts.map +1 -1
  298. package/dist/libs/langchain-core/dist/utils/types/index.d.ts +2 -0
  299. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  300. package/dist/libs/langchain-core/dist/utils/types/zod.d.ts +1 -0
  301. package/dist/load/import_map.cjs +3 -14
  302. package/dist/load/import_map.cjs.map +1 -1
  303. package/dist/load/import_map.js +3 -14
  304. package/dist/load/import_map.js.map +1 -1
  305. package/dist/memory/prompt.cjs.map +1 -1
  306. package/dist/memory/prompt.d.cts.map +1 -1
  307. package/dist/memory/prompt.d.ts.map +1 -1
  308. package/dist/memory/prompt.js.map +1 -1
  309. package/dist/output_parsers/combining.cjs +1 -1
  310. package/dist/output_parsers/combining.cjs.map +1 -1
  311. package/dist/output_parsers/combining.js +1 -1
  312. package/dist/output_parsers/combining.js.map +1 -1
  313. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map +1 -1
  314. package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map +1 -1
  315. package/dist/output_parsers/expression_type_handlers/base.cjs +1 -1
  316. package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
  317. package/dist/output_parsers/expression_type_handlers/base.js +1 -1
  318. package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
  319. package/dist/output_parsers/regex.cjs.map +1 -1
  320. package/dist/output_parsers/regex.js.map +1 -1
  321. package/dist/output_parsers/structured.cjs +4 -4
  322. package/dist/output_parsers/structured.cjs.map +1 -1
  323. package/dist/output_parsers/structured.d.cts +1 -1
  324. package/dist/output_parsers/structured.d.cts.map +1 -1
  325. package/dist/output_parsers/structured.d.ts +1 -1
  326. package/dist/output_parsers/structured.d.ts.map +1 -1
  327. package/dist/output_parsers/structured.js +2 -2
  328. package/dist/output_parsers/structured.js.map +1 -1
  329. package/dist/retrievers/ensemble.cjs.map +1 -1
  330. package/dist/retrievers/ensemble.js.map +1 -1
  331. package/dist/storage/file_system.cjs +1 -1
  332. package/dist/storage/file_system.cjs.map +1 -1
  333. package/dist/storage/file_system.js +1 -1
  334. package/dist/storage/file_system.js.map +1 -1
  335. package/dist/tools/fs.cjs +5 -5
  336. package/dist/tools/fs.cjs.map +1 -1
  337. package/dist/tools/fs.d.cts +1 -1
  338. package/dist/tools/fs.d.cts.map +1 -1
  339. package/dist/tools/fs.d.ts +1 -1
  340. package/dist/tools/fs.d.ts.map +1 -1
  341. package/dist/tools/fs.js +1 -1
  342. package/dist/tools/fs.js.map +1 -1
  343. package/dist/tools/retriever.cjs +2 -2
  344. package/dist/tools/retriever.cjs.map +1 -1
  345. package/dist/tools/retriever.d.cts +1 -1
  346. package/dist/tools/retriever.d.cts.map +1 -1
  347. package/dist/tools/retriever.d.ts +1 -1
  348. package/dist/tools/retriever.d.ts.map +1 -1
  349. package/dist/tools/retriever.js +1 -1
  350. package/dist/tools/retriever.js.map +1 -1
  351. package/dist/tools/sql.cjs +1 -2
  352. package/dist/tools/sql.cjs.map +1 -1
  353. package/dist/tools/sql.d.cts +1 -1
  354. package/dist/tools/sql.d.cts.map +1 -1
  355. package/dist/tools/sql.d.ts +1 -1
  356. package/dist/tools/sql.d.ts.map +1 -1
  357. package/dist/tools/sql.js +1 -2
  358. package/dist/tools/sql.js.map +1 -1
  359. package/dist/types/expression-parser.d.cts +2 -0
  360. package/dist/types/expression-parser.d.cts.map +1 -1
  361. package/dist/types/expression-parser.d.ts +2 -0
  362. package/dist/types/expression-parser.d.ts.map +1 -1
  363. package/dist/util/hub.cjs +1 -1
  364. package/dist/util/hub.js +1 -1
  365. package/dist/util/openapi.cjs +1 -1
  366. package/dist/util/openapi.cjs.map +1 -1
  367. package/dist/util/openapi.js +1 -1
  368. package/dist/util/openapi.js.map +1 -1
  369. package/package.json +15 -21
  370. package/dist/agents/middlewareAgent/middlewares/hitl.cjs +0 -235
  371. package/dist/agents/middlewareAgent/middlewares/hitl.cjs.map +0 -1
  372. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts +0 -199
  373. package/dist/agents/middlewareAgent/middlewares/hitl.d.cts.map +0 -1
  374. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts +0 -199
  375. package/dist/agents/middlewareAgent/middlewares/hitl.d.ts.map +0 -1
  376. package/dist/agents/middlewareAgent/middlewares/hitl.js +0 -234
  377. package/dist/agents/middlewareAgent/middlewares/hitl.js.map +0 -1
  378. package/dist/agents/middlewareAgent/middlewares/index.cjs +0 -8
  379. package/dist/agents/middlewareAgent/middlewares/index.d.cts +0 -4
  380. package/dist/agents/middlewareAgent/middlewares/index.d.ts +0 -4
  381. package/dist/agents/middlewareAgent/middlewares/index.js +0 -5
  382. package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs.map +0 -1
  383. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts.map +0 -1
  384. package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts.map +0 -1
  385. package/dist/agents/middlewareAgent/middlewares/promptCaching.js.map +0 -1
  386. package/dist/agents/middlewareAgent/middlewares/summarization.cjs.map +0 -1
  387. package/dist/agents/middlewareAgent/middlewares/summarization.d.cts.map +0 -1
  388. package/dist/agents/middlewareAgent/middlewares/summarization.d.ts.map +0 -1
  389. package/dist/agents/middlewareAgent/middlewares/summarization.js.map +0 -1
  390. package/dist/chains/openai_functions/structured_output.cjs +0 -107
  391. package/dist/chains/openai_functions/structured_output.cjs.map +0 -1
  392. package/dist/chains/openai_functions/structured_output.d.cts +0 -38
  393. package/dist/chains/openai_functions/structured_output.d.cts.map +0 -1
  394. package/dist/chains/openai_functions/structured_output.d.ts +0 -38
  395. package/dist/chains/openai_functions/structured_output.d.ts.map +0 -1
  396. package/dist/chains/openai_functions/structured_output.js +0 -105
  397. package/dist/chains/openai_functions/structured_output.js.map +0 -1
  398. package/dist/chains/openai_moderation.cjs +0 -107
  399. package/dist/chains/openai_moderation.cjs.map +0 -1
  400. package/dist/chains/openai_moderation.d.cts +0 -74
  401. package/dist/chains/openai_moderation.d.cts.map +0 -1
  402. package/dist/chains/openai_moderation.d.ts +0 -74
  403. package/dist/chains/openai_moderation.d.ts.map +0 -1
  404. package/dist/chains/openai_moderation.js +0 -106
  405. package/dist/chains/openai_moderation.js.map +0 -1
@@ -0,0 +1,598 @@
1
+ import { ContentBlock } from "./content/index.cjs";
2
+ import { ResponseMetadata, UsageMetadata } from "./metadata.cjs";
3
+ import { $MergeDiscriminatedUnion, $MergeObjects } from "./utils.cjs";
4
+
5
+ //#region ../langchain-core/dist/messages/message.d.ts
6
+
7
+ //#region src/messages/message.d.ts
8
+ /**
9
+ * Represents the possible types of messages in the system.
10
+ * Includes standard message types ("ai", "human", "tool", "system")
11
+ * and allows for custom string types that are non-null.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // Standard message types
16
+ * const messageType1: MessageType = "ai";
17
+ * const messageType2: MessageType = "human";
18
+ *
19
+ * // Custom message type
20
+ * const messageType3: MessageType = "custom_type";
21
+ * ```
22
+ */
23
+ type MessageType = "ai" | "human" | "tool" | "system" | (string & NonNullable<unknown>);
24
+ /**
25
+ * Represents the output version format for message content.
26
+ *
27
+ * This type determines how the content field is structured in a message:
28
+ * - "v0": Content is represented as a simple string or array of content blocks
29
+ * - provides backward compatibility with simpler content representations
30
+ * - "v1": Content follows the structured ContentBlock format with typed discriminated unions
31
+ * - enables full type safety and structured content block handling
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * // v0 format - simple content representation
36
+ * const v0Message: Message<{ outputVersion: "v0", content: ... }> = {
37
+ * type: "human",
38
+ * content: "Hello world" // string | Array<ContentBlock | ContentBlock.Text>
39
+ * };
40
+ *
41
+ * // v1 format - structured content blocks
42
+ * const v1Message: Message<{ outputVersion: "v1", content: ... }> = {
43
+ * type: "human",
44
+ * content: [
45
+ * { type: "text", text: "Hello world" },
46
+ * { type: "image", image_url: "..." }
47
+ * ] // Array<ContentBlock | ...> (determined by the structure)
48
+ * };
49
+ * ```
50
+ */
51
+ type MessageOutputVersion = "v0" | "v1";
52
+ /**
53
+ * Represents the input and output types of a tool that can be used in messages.
54
+ *
55
+ * @template TInput - The type of input the tool accepts.
56
+ * @template TOutput - The type of output the tool produces.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * // Tool that takes a string input and returns a number
61
+ * interface StringToNumberTool extends MessageToolDefinition<string, number> {
62
+ * input: string;
63
+ * output: number;
64
+ * }
65
+ * ```
66
+ */
67
+ interface MessageToolDefinition<TInput = unknown, TOutput = unknown> {
68
+ input: TInput;
69
+ output: TOutput;
70
+ }
71
+ /**
72
+ * Represents a structured set of tools by mapping tool names to definitions
73
+ * that can be used in messages.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * interface MyToolSet extends MessageToolSet {
78
+ * calculator: MessageToolDefinition<
79
+ * { operation: string; numbers: number[] },
80
+ * number
81
+ * >;
82
+ * translator: MessageToolDefinition<
83
+ * { text: string; targetLanguage: string },
84
+ * string
85
+ * >;
86
+ * }
87
+ * ```
88
+ */
89
+ interface MessageToolSet {
90
+ [key: string]: MessageToolDefinition;
91
+ }
92
+ /**
93
+ * Represents a tool call block within a message structure by mapping tool names to their
94
+ * corresponding tool call formats, including the input arguments and an optional identifier.
95
+ *
96
+ * @template TStructure - A message structure type that may contain tool definitions
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * // Given a message structure with a calculator tool:
101
+ * interface MyStructure extends MessageStructure {
102
+ * tools: {
103
+ * calculator: MessageToolDefinition<{ operation: string, numbers: number[] }, number>
104
+ * }
105
+ * }
106
+ *
107
+ * // The tool call block would be:
108
+ * type CalcToolCall = $MessageToolCallBlock<MyStructure>;
109
+ * // Resolves to:
110
+ * // {
111
+ * // type: "tool_call";
112
+ * // name: "calculator";
113
+ * // args: { operation: string, numbers: number[] };
114
+ * // id?: string;
115
+ * // }
116
+ * ```
117
+ */
118
+ type $MessageToolCallBlock<TStructure extends MessageStructure> = TStructure["tools"] extends MessageToolSet ? { [K in keyof TStructure["tools"]]: K extends string ? TStructure["tools"][K] extends MessageToolDefinition ? ContentBlock.Tools.ToolCall<K, TStructure["tools"][K]["input"]> : never : never }[keyof TStructure["tools"]] : never;
119
+ /**
120
+ * Core interface that defines the structure of messages.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * // Basic message structure with just content blocks
125
+ * interface SimpleMessageStructure extends MessageStructure {
126
+ * content: {
127
+ * human: ContentBlock.Text;
128
+ * // allows for text + reasoning blocks in ai messages
129
+ * ai: ContentBlock.Text | ContentBlock.Reasoning;
130
+ * }
131
+ * }
132
+ *
133
+ * // Message structure with tools and properties
134
+ * interface AdvancedMessageStructure extends MessageStructure {
135
+ * tools: {
136
+ * calculator: MessageToolDefinition<
137
+ * { operation: string; numbers: number[] },
138
+ * number
139
+ * >;
140
+ * };
141
+ * content: {
142
+ * // allows for text + image blocks in human messages
143
+ * human: ContentBlock.Text | ContentBlock.Multimodal.Image;
144
+ * // only allows for text blocks in ai messages
145
+ * ai: ContentBlock.Text;
146
+ * };
147
+ * properties: {
148
+ * // pins properties to ai messages
149
+ * ai: {
150
+ * response_metadata: {
151
+ * confidence: number;
152
+ * model: string;
153
+ * };
154
+ * };
155
+ * }
156
+ * }
157
+ *
158
+ * // Using with $MergeMessageStructure to combine structures
159
+ * // The resulting type when passed into BaseMessage will have a calculator tool,
160
+ * // allow for text + image blocks in human messages,
161
+ * // and text + reasoning blocks + additional arbitrary properties in ai messages.
162
+ * type CombinedStructure = $MergeMessageStructure<
163
+ * SimpleMessageStructure,
164
+ * AdvancedMessageStructure
165
+ * >;
166
+ *
167
+ * // Using in a Message object
168
+ * const message: Message<CombinedStructure> = {
169
+ * id: "msg-123",
170
+ * type: "human",
171
+ * content: [
172
+ * { type: "text", text: "Hello!" }
173
+ * { type: "image", mimeType: "image/jpeg", url: "https://example.com/image.jpg" }
174
+ * // this block will throw an error because it's not defined in the structure
175
+ * { type: "reasoning", reasoning: "The answer is 42" }
176
+ * ]
177
+ * };
178
+ * ```
179
+ */
180
+ interface MessageStructure {
181
+ /**
182
+ * Optional output version for the message structure.
183
+ * If not provided, defaults to "v0".
184
+ */
185
+ readonly outputVersion?: MessageOutputVersion;
186
+ /**
187
+ * Optional set of tool definitions that can be used in messages.
188
+ * Each tool is defined with input/output types and can be referenced in tool messages.
189
+ */
190
+ readonly tools?: MessageToolSet;
191
+ /**
192
+ * Optional mapping of message types to their allowed content blocks.
193
+ * Each message type can specify what content block types it supports (text, images, etc).
194
+ */
195
+ readonly content?: Partial<{ [key in MessageType]: ContentBlock }>;
196
+ /**
197
+ * Optional mapping of message types to arbitrary property objects.
198
+ * Allows attaching custom metadata or other information to specific message types.
199
+ */
200
+ readonly properties?: Partial<{ [key in MessageType]: Record<string, unknown> }>;
201
+ }
202
+ /**
203
+ * Normalizes an arbitrary type to a message output version or undefined.
204
+ * Accepts unknown and narrows to a valid MessageOutputVersion if present.
205
+ */
206
+ type $NormalizeMessageOutputVersion<T> = Extract<T, MessageOutputVersion> | undefined;
207
+ /**
208
+ * Merges two output version types from message structures.
209
+ *
210
+ * This utility type determines the resulting output version when combining two message structures.
211
+ * The merge logic follows these rules:
212
+ *
213
+ * - If both T and U are undefined, defaults to "v0" for backwards compatibility
214
+ * - If T is undefined but U is defined, uses U's version
215
+ * - If U is undefined but T is defined, uses T's version
216
+ * - If both T and U are defined, U takes precedence (later structure wins)
217
+ *
218
+ * @template T - The output version from the first message structure
219
+ * @template U - The output version from the second message structure
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * // Both undefined - defaults to "v0"
224
+ * type Result1 = $MergeOutputVersion<undefined, undefined>; // "v0"
225
+ *
226
+ * // One defined - uses the defined version
227
+ * type Result2 = $MergeOutputVersion<undefined, "v1">; // "v1"
228
+ * type Result3 = $MergeOutputVersion<"v0", undefined>; // "v0"
229
+ *
230
+ * // Both defined - second takes precedence
231
+ * type Result4 = $MergeOutputVersion<"v0", "v1">; // "v1"
232
+ * ```
233
+ */
234
+ 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;
235
+ /**
236
+ * Merges two content definition objects from message structures.
237
+ *
238
+ * This utility type combines content definitions from two message structures, handling
239
+ * the merging of content block types for each message type. The merge logic follows
240
+ * these rules:
241
+ *
242
+ * - For keys that exist in both T and U: Merges the content blocks using discriminated
243
+ * union merging based on the "type" property. This allows combining different content
244
+ * block types (e.g., text + image) for the same message type.
245
+ * - For keys that exist only in T: Uses T's content definition as-is
246
+ * - For keys that exist only in U: Uses U's content definition as-is
247
+ *
248
+ * @template T - The content definition from the first message structure
249
+ * @template U - The content definition from the second message structure
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * // T allows text content for human messages
254
+ * type ContentA = {
255
+ * human: ContentBlock.Text;
256
+ * };
257
+ *
258
+ * // U allows image content for human messages and text for AI messages
259
+ * type ContentB = {
260
+ * human: ContentBlock.Multimodal.Image;
261
+ * ai: ContentBlock.Text;
262
+ * };
263
+ *
264
+ * // Merged result allows both text and images for human messages, text for AI
265
+ * type Merged = $MergeContentDefinition<ContentA, ContentB>;
266
+ * // Result: {
267
+ * // human: ContentBlock.Text | ContentBlock.Multimodal.Image;
268
+ * // ai: ContentBlock.Text;
269
+ * // }
270
+ * ```
271
+ */
272
+ type $MergeContentDefinition<T, U> = { [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 };
273
+ /**
274
+ * Merges two message structures A and B into a combined structure.
275
+ * This is a type utility that handles merging of tools, content blocks, and properties
276
+ * from two message structures. The resulting type is usable as its own message structure.
277
+ *
278
+ * @example
279
+ * ```ts
280
+ * // Structure A allows text in human messages and has a confidence property on AI messages
281
+ * interface StructureA extends MessageStructure {
282
+ * content: {
283
+ * human: ContentBlock.Text;
284
+ * };
285
+ * properties: {
286
+ * ai: { confidence: number };
287
+ * }
288
+ * }
289
+ *
290
+ * // Structure B allows images in human messages and has a model property on AI messages
291
+ * interface StructureB extends MessageStructure {
292
+ * content: {
293
+ * human: ContentBlock.Multimodal.Image;
294
+ * };
295
+ * properties: {
296
+ * ai: { model: string };
297
+ * }
298
+ * }
299
+ *
300
+ * // Merged structure allows both text and images in human messages
301
+ * // AI messages have both confidence and model properties
302
+ * type Merged = $MergeMessageStructure<StructureA, StructureB>;
303
+ * ```
304
+ *
305
+ * @template A - First message structure to merge
306
+ * @template B - Second message structure to merge (takes precedence over A)
307
+ */
308
+ type $MergeMessageStructure<T extends MessageStructure, U extends MessageStructure> = {
309
+ outputVersion: $MergeOutputVersion<T["outputVersion"], U["outputVersion"]>;
310
+ tools: $MergeObjects<T["tools"], U["tools"]>;
311
+ content: $MergeContentDefinition<T["content"], U["content"]>;
312
+ properties: $MergeObjects<T["properties"], U["properties"]>;
313
+ };
314
+ /**
315
+ * Standard message structured used to define the most basic message structure that's
316
+ * used throughout the library.
317
+ *
318
+ * This is also the message structure that's used when a message structure is not provided.
319
+ */
320
+ interface StandardMessageStructure extends MessageStructure {
321
+ content: {
322
+ /** Text content for AI messages */
323
+ ai: ContentBlock.Text;
324
+ /** Text content for human messages */
325
+ human: ContentBlock.Text;
326
+ /** Text content for system messages */
327
+ system: ContentBlock.Text;
328
+ /** Text content for tool messages */
329
+ tool: ContentBlock.Text;
330
+ };
331
+ properties: {
332
+ /** Properties specific to AI messages */
333
+ ai: {
334
+ /** Metadata about the AI model response */
335
+ response_metadata: ResponseMetadata;
336
+ /** Usage statistics for the AI response */
337
+ usage_metadata: UsageMetadata;
338
+ };
339
+ human: {
340
+ /** Metadata about the human message */
341
+ response_metadata: Record<string, unknown>;
342
+ };
343
+ system: {
344
+ /** Metadata about the system message */
345
+ response_metadata: Record<string, unknown>;
346
+ };
347
+ tool: {
348
+ /** Metadata about the tool message */
349
+ response_metadata: Record<string, unknown>;
350
+ };
351
+ };
352
+ }
353
+ /**
354
+ * Takes a message structure type T and normalizes it by merging it with the standard message structure.
355
+ * If T is already a standard message structure, returns T unchanged.
356
+ *
357
+ * This ensures that any custom message structure includes all the standard message structure fields
358
+ * by default while allowing overrides and extensions.
359
+ *
360
+ * @template T - The message structure type to normalize, must extend MessageStructure
361
+ * @returns Either T if it's already a standard structure, or the merged result of T with standard structure
362
+ */
363
+ type $NormalizedMessageStructure<T extends MessageStructure> = T extends StandardMessageStructure ? T : $MergeMessageStructure<StandardMessageStructure, T>;
364
+ /**
365
+ * Infers the content blocks for a specific message type in a message structure.
366
+ *
367
+ * This utility type extracts the content block type that corresponds to a given message type
368
+ * from the message structure's content definition.
369
+ *
370
+ * @template TStructure - The message structure to infer content from
371
+ * @template TRole - The message role/type to get content for (e.g., "ai", "human", "system", "tool")
372
+ * @returns The content block type for the specified type, or never if its not defined in the structure
373
+ *
374
+ * @example
375
+ * ```ts
376
+ * interface MyStructure extends MessageStructure {
377
+ * content: {
378
+ * human: ContentBlock.Text;
379
+ * ai: ContentBlock.Text | ContentBlock.ToolCall;
380
+ * };
381
+ * }
382
+ *
383
+ * type HumanContent = $InferMessageContentBlocks<MyStructure, "human">;
384
+ * // HumanContent = ContentBlock.Text
385
+ *
386
+ * type AIContent = $InferMessageContentBlocks<MyStructure, "ai">;
387
+ * // AIContent = ContentBlock.Text | ContentBlock.ToolCall
388
+ * ```
389
+ */
390
+ 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;
391
+ /**
392
+ * Infers the content type for a specific message type from a message structure.
393
+ *
394
+ * This utility type determines the appropriate content type based on the message structure's
395
+ * output version and the specified message type. The content type varies depending on the
396
+ * output version (see {@link MessageOutputVersion})
397
+ *
398
+ * @template TStructure - The message structure to infer content from
399
+ * @template TRole - The message role/type to get content for (e.g., "ai", "human", "system", "tool")
400
+ * @returns The content type for the specified role based on the output version
401
+ *
402
+ * @example
403
+ * ```ts
404
+ * interface MyStructure extends MessageStructure {
405
+ * outputVersion: "v0";
406
+ * content: {
407
+ * human: ContentBlock.Text;
408
+ * ai: ContentBlock.Text | ContentBlock.ToolCall;
409
+ * };
410
+ * }
411
+ *
412
+ * type HumanContentV0 = $InferMessageContent<MyStructure, "human">;
413
+ * // HumanContentV0 = string | Array<ContentBlock | ContentBlock.Text>
414
+ *
415
+ * interface MyStructureV1 extends MessageStructure {
416
+ * outputVersion: "v1";
417
+ * content: {
418
+ * human: ContentBlock.Text;
419
+ * ai: ContentBlock.Text | ContentBlock.Reasoning;
420
+ * };
421
+ * }
422
+ *
423
+ * type HumanContentV1 = $InferMessageContent<MyStructureV1, "human">;
424
+ * // HumanContentV1 = ContentBlock.Text
425
+ *
426
+ * type AIContentV1 = $InferMessageContent<MyStructureV1, "ai">;
427
+ * // AIContentV1 = ContentBlock.Text | ContentBlock.Reasoning
428
+ * ```
429
+ */
430
+ type $InferMessageContent<TStructure extends MessageStructure, TRole extends MessageType> = TStructure["outputVersion"] extends "v1" ? Array<$InferMessageContentBlocks<TStructure, TRole>> : string | Array<ContentBlock | ContentBlock.Text>;
431
+ /**
432
+ * Infers the properties for a specific message type from a message structure.
433
+ *
434
+ * This utility type extracts the properties object that corresponds to a given message type
435
+ * from the message structure's properties definition, and excludes the reserved
436
+ * "content" and "type" properties to avoid conflicts with the core message structure.
437
+ *
438
+ * If the specified type is not defined in the message structure's properties, it returns
439
+ * a generic Record<string, unknown> type to allow for arbitrary properties.
440
+ *
441
+ * @template TStructure - The message structure to infer properties from
442
+ * @template TRole - The message type/role to get properties for (e.g., "ai", "human", "system", "tool")
443
+ * @returns The properties object type for the specified type, excluding "content" and "type"
444
+ *
445
+ * @example
446
+ * ```ts
447
+ * interface MyStructure extends MessageStructure {
448
+ * properties: {
449
+ * ai: {
450
+ * response_metadata: { model: string };
451
+ * usage_metadata: { tokens: number };
452
+ * content: string; // This will be omitted
453
+ * type: string; // This will be omitted
454
+ * };
455
+ * human: { metadata: Record<string, unknown> };
456
+ * };
457
+ * }
458
+ *
459
+ * type AIProperties = $InferMessageProperties<MyStructure, "ai">;
460
+ * // AIProperties = { response_metadata: { model: string }; usage_metadata: { tokens: number } }
461
+ *
462
+ * type HumanProperties = $InferMessageProperties<MyStructure, "human">;
463
+ * // HumanProperties = { metadata: Record<string, unknown> }
464
+ *
465
+ * type SystemProperties = $InferMessageProperties<MyStructure, "system">;
466
+ * // SystemProperties = Record<string, unknown> (fallback for undefined role)
467
+ * ```
468
+ */
469
+ 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;
470
+ /**
471
+ * Infers the type of a specific property for a message type from a message structure.
472
+ *
473
+ * This utility type extracts the type of a single property by name from the properties
474
+ * object that corresponds to a given message type. If the specified property key does
475
+ * not exist in the type's properties, it returns `never`.
476
+ *
477
+ * @template TStructure - The message structure to infer the property from
478
+ * @template TRole - The message type/role to get the property for (e.g., "ai", "human", "system", "tool")
479
+ * @template K - The property key to extract the type for
480
+ * @returns The type of the specified property, or `never` if the property doesn't exist
481
+ *
482
+ * @example
483
+ * ```ts
484
+ * interface MyStructure extends MessageStructure {
485
+ * properties: {
486
+ * ai: {
487
+ * response_metadata: { model: string; temperature: number };
488
+ * usage_metadata: { input_tokens: number; output_tokens: number };
489
+ * };
490
+ * human: { metadata: Record<string, unknown> };
491
+ * };
492
+ * }
493
+ *
494
+ * type ResponseMetadata = $InferMessageProperty<MyStructure, "ai", "response_metadata">;
495
+ * // ResponseMetadata = { model: string; temperature: number }
496
+ *
497
+ * type UsageMetadata = $InferMessageProperty<MyStructure, "ai", "usage_metadata">;
498
+ * // UsageMetadata = { input_tokens: number; output_tokens: number }
499
+ *
500
+ * type NonExistentProperty = $InferMessageProperty<MyStructure, "ai", "nonExistent">;
501
+ * // NonExistentProperty = Record<string, unknown>
502
+ *
503
+ * type HumanMetadata = $InferMessageProperty<MyStructure, "human", "metadata">;
504
+ * // HumanMetadata = Record<string, unknown>
505
+ * ```
506
+ */
507
+ type $InferMessageProperty<TStructure extends MessageStructure, TRole extends MessageType, K extends string> = K extends keyof $InferMessageProperties<TStructure, TRole> ? $InferMessageProperties<TStructure, TRole>[K] : never;
508
+ /**
509
+ * Infers the response metadata type for a specific message type from a message structure.
510
+ *
511
+ * This utility type extracts the `response_metadata` property type for a given message type.
512
+ *
513
+ * @template TStructure - The message structure to infer the response metadata from
514
+ * @template TRole - The message type/role to get the response metadata for (e.g., "ai", "human", "system", "tool")
515
+ * @returns The type of the response_metadata property, or `Record<string, unknown>` as fallback
516
+ *
517
+ * @example
518
+ * ```ts
519
+ * interface MyStructure extends MessageStructure {
520
+ * properties: {
521
+ * ai: {
522
+ * response_metadata: { model: string; temperature: number; tokens: number };
523
+ * };
524
+ * human: { metadata: Record<string, unknown> };
525
+ * };
526
+ * }
527
+ *
528
+ * type AIResponseMetadata = $InferResponseMetadata<MyStructure, "ai">;
529
+ * // AIResponseMetadata = { model: string; temperature: number; tokens: number }
530
+ *
531
+ * type HumanResponseMetadata = $InferResponseMetadata<MyStructure, "human">;
532
+ * // HumanResponseMetadata = Record<string, unknown> (fallback since not defined)
533
+ * ```
534
+ */
535
+ type $InferResponseMetadata<TStructure extends MessageStructure, TRole extends MessageType> = $InferMessageProperty<TStructure, TRole, "response_metadata"> extends infer P ? [P] extends [never] ? Record<string, unknown> : P : never;
536
+ /**
537
+ * Represents a message object that organizes context for an LLM.
538
+ *
539
+ * @example
540
+ * ```ts
541
+ * // Basic message with text content
542
+ * const message: Message = {
543
+ * id: "msg-123",
544
+ * name: "user",
545
+ * type: "human",
546
+ * content: [{ type: "text", text: "Hello!" }]
547
+ * };
548
+ *
549
+ * // Basic ai message interface extension
550
+ * interface MyMessage extends Message<StandardMessageStructure, "ai"> {
551
+ * // Additional AI-specific properties can be added here
552
+ * }
553
+ *`
554
+ * // Custom message structure
555
+ * interface CustomStructure extends MessageStructure {
556
+ * content: {
557
+ * ai: ContentBlock.Text | ContentBlock.ToolCall<"search", { query: string }>;
558
+ * human: ContentBlock.Text | ContentBlock.Multimodal.Image;
559
+ * };
560
+ * }
561
+ *
562
+ * // Create a message with custom structure
563
+ * const message: Message<CustomStructure> = {
564
+ * id: "msg-123",
565
+ * name: "user",
566
+ * type: "ai",
567
+ * content: [
568
+ * { type: "text", text: "Hello!" },
569
+ * {
570
+ * type: "tool_call",
571
+ * name: "search",
572
+ * args: { query: "What is the capital of France?" }
573
+ * }
574
+ * ]
575
+ * };
576
+ * ```
577
+ */
578
+ interface Message<TStructure extends MessageStructure = StandardMessageStructure, TRole extends MessageType = MessageType> {
579
+ /** The message type/role */
580
+ readonly type: TRole;
581
+ /** Unique identifier for this message */
582
+ id?: string;
583
+ /** Optional name/identifier for the entity that created this message */
584
+ name?: string;
585
+ /** Array of content blocks that make up the message content */
586
+ content: $InferMessageContent<TStructure, TRole>;
587
+ /** Metadata about the message */
588
+ response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;
589
+ }
590
+ /**
591
+ * Type guard to check if a value is a valid Message object.
592
+ *
593
+ * @param message - The value to check
594
+ * @returns true if the value is a valid Message object, false otherwise
595
+ */
596
+ //#endregion
597
+ export { $InferMessageContent, $InferResponseMetadata, Message, MessageStructure, MessageType };
598
+ //# sourceMappingURL=message.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.cts","names":["ContentBlock","ResponseMetadata","UsageMetadata","$MergeDiscriminatedUnion","$MergeObjects","MessageType","NonNullable","MessageOutputVersion","MessageToolDefinition","TInput","TOutput","MessageToolSet","$MessageToolCallBlock","MessageStructure","TStructure","K","Tools","ToolCall","Partial","Record","$NormalizeMessageOutputVersion","T","Extract","$MergeOutputVersion","U","TV","UV","Exclude","$MergeContentDefinition","$MergeMessageStructure","StandardMessageStructure","Text","$NormalizedMessageStructure","$InferMessageContentBlocks","S","C","PropertyKey","TRole","$InferMessageContent","Array","$InferMessageProperties","P","Omit","$InferMessageProperty","$InferResponseMetadata","Message","isMessage"],"sources":["../../../../../langchain-core/dist/messages/message.d.ts"],"sourcesContent":["import { ContentBlock } from \"./content/index.js\";\nimport { ResponseMetadata, UsageMetadata } from \"./metadata.js\";\nimport { $MergeDiscriminatedUnion, $MergeObjects } from \"./utils.js\";\n\n//#region src/messages/message.d.ts\n\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 */\ntype 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 */\ntype 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 */\ninterface 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 */\ninterface 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 */\ntype $MessageToolCallBlock<TStructure extends MessageStructure> = TStructure[\"tools\"] extends MessageToolSet ? { [K in keyof TStructure[\"tools\"]]: K extends string ? TStructure[\"tools\"][K] extends MessageToolDefinition ? ContentBlock.Tools.ToolCall<K, TStructure[\"tools\"][K][\"input\"]> : never : never }[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 */\ninterface 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<{ [key in MessageType]: ContentBlock }>;\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<{ [key in MessageType]: Record<string, unknown> }>;\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 */\ntype $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 */\ntype $MergeContentDefinition<T, U> = { [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 * 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 */\ntype $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 */\ninterface 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 */\ntype $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 */\ntype $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 */\ntype $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 */\ntype $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 */\ntype $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 */\ntype $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 */\ninterface 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 */\ndeclare function isMessage(message: unknown): message is Message;\n//#endregion\nexport { $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $MergeContentDefinition, $MergeMessageStructure, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, Message, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, StandardMessageStructure, isMessage };\n//# sourceMappingURL=message.d.ts.map"],"mappings":"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"}