@langchain/core 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (595) hide show
  1. package/README.md +3 -19
  2. package/dist/agents.d.ts.map +1 -1
  3. package/dist/caches/base.cjs +5 -18
  4. package/dist/caches/base.cjs.map +1 -1
  5. package/dist/caches/base.d.cts +4 -20
  6. package/dist/caches/base.d.cts.map +1 -1
  7. package/dist/caches/base.d.ts +4 -20
  8. package/dist/caches/base.d.ts.map +1 -1
  9. package/dist/caches/base.js +5 -18
  10. package/dist/caches/base.js.map +1 -1
  11. package/dist/callbacks/base.d.cts +3 -2
  12. package/dist/callbacks/base.d.cts.map +1 -1
  13. package/dist/callbacks/base.d.ts +3 -2
  14. package/dist/callbacks/base.d.ts.map +1 -1
  15. package/dist/callbacks/manager.d.cts +1 -1
  16. package/dist/callbacks/manager.d.ts +1 -1
  17. package/dist/document_loaders/langsmith.cjs +1 -1
  18. package/dist/document_loaders/langsmith.cjs.map +1 -1
  19. package/dist/document_loaders/langsmith.js +1 -1
  20. package/dist/document_loaders/langsmith.js.map +1 -1
  21. package/dist/embeddings.cjs.map +1 -1
  22. package/dist/embeddings.d.cts +6 -6
  23. package/dist/embeddings.d.cts.map +1 -1
  24. package/dist/embeddings.d.ts +6 -6
  25. package/dist/embeddings.d.ts.map +1 -1
  26. package/dist/embeddings.js.map +1 -1
  27. package/dist/errors/index.cjs.map +1 -1
  28. package/dist/errors/index.js.map +1 -1
  29. package/dist/indexing/base.cjs +2 -2
  30. package/dist/indexing/base.cjs.map +1 -1
  31. package/dist/indexing/base.d.cts +0 -3
  32. package/dist/indexing/base.d.cts.map +1 -1
  33. package/dist/indexing/base.d.ts +0 -3
  34. package/dist/indexing/base.d.ts.map +1 -1
  35. package/dist/indexing/base.js +2 -2
  36. package/dist/indexing/base.js.map +1 -1
  37. package/dist/language_models/base.cjs +1 -1
  38. package/dist/language_models/base.cjs.map +1 -1
  39. package/dist/language_models/base.d.cts +4 -4
  40. package/dist/language_models/base.d.cts.map +1 -1
  41. package/dist/language_models/base.d.ts +4 -4
  42. package/dist/language_models/base.d.ts.map +1 -1
  43. package/dist/language_models/base.js +1 -1
  44. package/dist/language_models/base.js.map +1 -1
  45. package/dist/language_models/chat_models.cjs +1 -0
  46. package/dist/language_models/chat_models.cjs.map +1 -1
  47. package/dist/language_models/chat_models.d.cts +2 -1
  48. package/dist/language_models/chat_models.d.cts.map +1 -1
  49. package/dist/language_models/chat_models.d.ts +2 -1
  50. package/dist/language_models/chat_models.d.ts.map +1 -1
  51. package/dist/language_models/chat_models.js +2 -1
  52. package/dist/language_models/chat_models.js.map +1 -1
  53. package/dist/language_models/llms.cjs.map +1 -1
  54. package/dist/language_models/llms.js.map +1 -1
  55. package/dist/load/import_map.cjs +1 -5
  56. package/dist/load/import_map.cjs.map +1 -1
  57. package/dist/load/import_map.js +3 -7
  58. package/dist/load/import_map.js.map +1 -1
  59. package/dist/load/index.cjs.map +1 -1
  60. package/dist/load/index.js.map +1 -1
  61. package/dist/load/serializable.cjs.map +1 -1
  62. package/dist/load/serializable.d.cts +1 -3
  63. package/dist/load/serializable.d.cts.map +1 -1
  64. package/dist/load/serializable.d.ts +1 -3
  65. package/dist/load/serializable.d.ts.map +1 -1
  66. package/dist/load/serializable.js.map +1 -1
  67. package/dist/messages/ai.cjs +34 -62
  68. package/dist/messages/ai.cjs.map +1 -1
  69. package/dist/messages/ai.d.cts +26 -119
  70. package/dist/messages/ai.d.cts.map +1 -1
  71. package/dist/messages/ai.d.ts +26 -119
  72. package/dist/messages/ai.d.ts.map +1 -1
  73. package/dist/messages/ai.js +34 -62
  74. package/dist/messages/ai.js.map +1 -1
  75. package/dist/messages/base.cjs +53 -33
  76. package/dist/messages/base.cjs.map +1 -1
  77. package/dist/messages/base.d.cts +38 -41
  78. package/dist/messages/base.d.cts.map +1 -1
  79. package/dist/messages/base.d.ts +38 -41
  80. package/dist/messages/base.d.ts.map +1 -1
  81. package/dist/messages/base.js +53 -33
  82. package/dist/messages/base.js.map +1 -1
  83. package/dist/messages/block_translators/utils.cjs +1 -1
  84. package/dist/messages/block_translators/utils.cjs.map +1 -1
  85. package/dist/messages/block_translators/utils.js +1 -1
  86. package/dist/messages/block_translators/utils.js.map +1 -1
  87. package/dist/messages/chat.cjs +18 -12
  88. package/dist/messages/chat.cjs.map +1 -1
  89. package/dist/messages/chat.d.cts +21 -13
  90. package/dist/messages/chat.d.cts.map +1 -1
  91. package/dist/messages/chat.d.ts +21 -13
  92. package/dist/messages/chat.d.ts.map +1 -1
  93. package/dist/messages/chat.js +18 -12
  94. package/dist/messages/chat.js.map +1 -1
  95. package/dist/messages/content/index.cjs.map +1 -1
  96. package/dist/messages/content/index.d.cts +1 -1
  97. package/dist/messages/content/index.d.cts.map +1 -1
  98. package/dist/messages/content/index.d.ts +1 -1
  99. package/dist/messages/content/index.d.ts.map +1 -1
  100. package/dist/messages/content/index.js.map +1 -1
  101. package/dist/messages/function.cjs +8 -13
  102. package/dist/messages/function.cjs.map +1 -1
  103. package/dist/messages/function.d.cts +11 -11
  104. package/dist/messages/function.d.cts.map +1 -1
  105. package/dist/messages/function.d.ts +11 -11
  106. package/dist/messages/function.d.ts.map +1 -1
  107. package/dist/messages/function.js +8 -13
  108. package/dist/messages/function.js.map +1 -1
  109. package/dist/messages/human.cjs +20 -11
  110. package/dist/messages/human.cjs.map +1 -1
  111. package/dist/messages/human.d.cts +20 -15
  112. package/dist/messages/human.d.cts.map +1 -1
  113. package/dist/messages/human.d.ts +20 -15
  114. package/dist/messages/human.d.ts.map +1 -1
  115. package/dist/messages/human.js +20 -11
  116. package/dist/messages/human.js.map +1 -1
  117. package/dist/messages/index.cjs +11 -1
  118. package/dist/messages/index.cjs.map +1 -1
  119. package/dist/messages/index.d.cts +9 -7
  120. package/dist/messages/index.d.ts +9 -7
  121. package/dist/messages/index.js +8 -2
  122. package/dist/messages/index.js.map +1 -1
  123. package/dist/messages/message.cjs +15 -0
  124. package/dist/messages/message.cjs.map +1 -0
  125. package/dist/messages/message.d.cts +598 -0
  126. package/dist/messages/message.d.cts.map +1 -0
  127. package/dist/messages/message.d.ts +598 -0
  128. package/dist/messages/message.d.ts.map +1 -0
  129. package/dist/messages/message.js +14 -0
  130. package/dist/messages/message.js.map +1 -0
  131. package/dist/messages/metadata.cjs +41 -0
  132. package/dist/messages/metadata.cjs.map +1 -0
  133. package/dist/messages/metadata.d.cts +98 -0
  134. package/dist/messages/metadata.d.cts.map +1 -0
  135. package/dist/messages/metadata.d.ts +98 -0
  136. package/dist/messages/metadata.d.ts.map +1 -0
  137. package/dist/messages/metadata.js +40 -0
  138. package/dist/messages/metadata.js.map +1 -0
  139. package/dist/messages/modifier.cjs +5 -4
  140. package/dist/messages/modifier.cjs.map +1 -1
  141. package/dist/messages/modifier.d.cts +7 -5
  142. package/dist/messages/modifier.d.cts.map +1 -1
  143. package/dist/messages/modifier.d.ts +7 -5
  144. package/dist/messages/modifier.d.ts.map +1 -1
  145. package/dist/messages/modifier.js +5 -4
  146. package/dist/messages/modifier.js.map +1 -1
  147. package/dist/messages/system.cjs +20 -11
  148. package/dist/messages/system.cjs.map +1 -1
  149. package/dist/messages/system.d.cts +20 -15
  150. package/dist/messages/system.d.cts.map +1 -1
  151. package/dist/messages/system.d.ts +20 -15
  152. package/dist/messages/system.d.ts.map +1 -1
  153. package/dist/messages/system.js +20 -11
  154. package/dist/messages/system.js.map +1 -1
  155. package/dist/messages/tool.cjs +21 -19
  156. package/dist/messages/tool.cjs.map +1 -1
  157. package/dist/messages/tool.d.cts +72 -46
  158. package/dist/messages/tool.d.cts.map +1 -1
  159. package/dist/messages/tool.d.ts +72 -46
  160. package/dist/messages/tool.d.ts.map +1 -1
  161. package/dist/messages/tool.js +21 -19
  162. package/dist/messages/tool.js.map +1 -1
  163. package/dist/messages/transformers.cjs +2 -2
  164. package/dist/messages/transformers.cjs.map +1 -1
  165. package/dist/messages/transformers.d.cts +2 -1
  166. package/dist/messages/transformers.d.cts.map +1 -1
  167. package/dist/messages/transformers.d.ts +2 -1
  168. package/dist/messages/transformers.d.ts.map +1 -1
  169. package/dist/messages/transformers.js +2 -2
  170. package/dist/messages/transformers.js.map +1 -1
  171. package/dist/messages/utils.cjs +13 -1
  172. package/dist/messages/utils.cjs.map +1 -1
  173. package/dist/messages/utils.d.cts +83 -3
  174. package/dist/messages/utils.d.cts.map +1 -1
  175. package/dist/messages/utils.d.ts +83 -3
  176. package/dist/messages/utils.d.ts.map +1 -1
  177. package/dist/messages/utils.js +13 -2
  178. package/dist/messages/utils.js.map +1 -1
  179. package/dist/output_parsers/list.cjs +1 -1
  180. package/dist/output_parsers/list.cjs.map +1 -1
  181. package/dist/output_parsers/list.js +1 -1
  182. package/dist/output_parsers/list.js.map +1 -1
  183. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.cts +1 -1
  184. package/dist/output_parsers/openai_functions/json_output_functions_parsers.d.ts +1 -1
  185. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs +1 -1
  186. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
  187. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +1 -1
  188. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +1 -1
  189. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js +1 -1
  190. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
  191. package/dist/output_parsers/structured.cjs +2 -1
  192. package/dist/output_parsers/structured.cjs.map +1 -1
  193. package/dist/output_parsers/structured.js +2 -1
  194. package/dist/output_parsers/structured.js.map +1 -1
  195. package/dist/prompt_values.d.cts +4 -3
  196. package/dist/prompt_values.d.cts.map +1 -1
  197. package/dist/prompt_values.d.ts +4 -3
  198. package/dist/prompt_values.d.ts.map +1 -1
  199. package/dist/prompts/chat.cjs +3 -1
  200. package/dist/prompts/chat.cjs.map +1 -1
  201. package/dist/prompts/chat.d.cts +7 -15
  202. package/dist/prompts/chat.d.cts.map +1 -1
  203. package/dist/prompts/chat.d.ts +7 -15
  204. package/dist/prompts/chat.d.ts.map +1 -1
  205. package/dist/prompts/chat.js +3 -1
  206. package/dist/prompts/chat.js.map +1 -1
  207. package/dist/prompts/few_shot.d.cts +1 -1
  208. package/dist/prompts/few_shot.d.ts +1 -1
  209. package/dist/prompts/image.cjs.map +1 -1
  210. package/dist/prompts/image.d.cts +1 -3
  211. package/dist/prompts/image.d.cts.map +1 -1
  212. package/dist/prompts/image.d.ts +1 -3
  213. package/dist/prompts/image.d.ts.map +1 -1
  214. package/dist/prompts/image.js.map +1 -1
  215. package/dist/prompts/pipeline.cjs.map +1 -1
  216. package/dist/prompts/pipeline.js.map +1 -1
  217. package/dist/prompts/prompt.cjs.map +1 -1
  218. package/dist/prompts/prompt.d.cts +5 -17
  219. package/dist/prompts/prompt.d.cts.map +1 -1
  220. package/dist/prompts/prompt.d.ts +5 -17
  221. package/dist/prompts/prompt.d.ts.map +1 -1
  222. package/dist/prompts/prompt.js.map +1 -1
  223. package/dist/prompts/structured.cjs.map +1 -1
  224. package/dist/prompts/structured.js.map +1 -1
  225. package/dist/prompts/template.cjs +4 -2
  226. package/dist/prompts/template.cjs.map +1 -1
  227. package/dist/prompts/template.d.cts +1 -1
  228. package/dist/prompts/template.d.ts +1 -1
  229. package/dist/prompts/template.js +4 -2
  230. package/dist/prompts/template.js.map +1 -1
  231. package/dist/runnables/base.cjs +6 -6
  232. package/dist/runnables/base.cjs.map +1 -1
  233. package/dist/runnables/base.d.cts +1 -4
  234. package/dist/runnables/base.d.cts.map +1 -1
  235. package/dist/runnables/base.d.ts +1 -4
  236. package/dist/runnables/base.d.ts.map +1 -1
  237. package/dist/runnables/base.js +6 -6
  238. package/dist/runnables/base.js.map +1 -1
  239. package/dist/runnables/branch.cjs +2 -2
  240. package/dist/runnables/branch.cjs.map +1 -1
  241. package/dist/runnables/branch.js +2 -2
  242. package/dist/runnables/branch.js.map +1 -1
  243. package/dist/runnables/config.cjs.map +1 -1
  244. package/dist/runnables/config.js.map +1 -1
  245. package/dist/runnables/graph.cjs +1 -1
  246. package/dist/runnables/graph.cjs.map +1 -1
  247. package/dist/runnables/graph.js +1 -1
  248. package/dist/runnables/graph.js.map +1 -1
  249. package/dist/runnables/graph_mermaid.cjs +26 -3
  250. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  251. package/dist/runnables/graph_mermaid.js +26 -3
  252. package/dist/runnables/graph_mermaid.js.map +1 -1
  253. package/dist/runnables/remote.cjs.map +1 -1
  254. package/dist/runnables/remote.js.map +1 -1
  255. package/dist/runnables/types.d.cts +0 -1
  256. package/dist/runnables/types.d.cts.map +1 -1
  257. package/dist/runnables/types.d.ts +0 -1
  258. package/dist/runnables/types.d.ts.map +1 -1
  259. package/dist/singletons/async_local_storage/context.cjs.map +1 -1
  260. package/dist/singletons/async_local_storage/context.d.cts +0 -1
  261. package/dist/singletons/async_local_storage/context.d.cts.map +1 -1
  262. package/dist/singletons/async_local_storage/context.d.ts +0 -1
  263. package/dist/singletons/async_local_storage/context.d.ts.map +1 -1
  264. package/dist/singletons/async_local_storage/context.js.map +1 -1
  265. package/dist/singletons/callbacks.cjs.map +1 -1
  266. package/dist/singletons/callbacks.js.map +1 -1
  267. package/dist/tools/index.cjs.map +1 -1
  268. package/dist/tools/index.d.cts +3 -3
  269. package/dist/tools/index.d.cts.map +1 -1
  270. package/dist/tools/index.d.ts +3 -3
  271. package/dist/tools/index.d.ts.map +1 -1
  272. package/dist/tools/index.js.map +1 -1
  273. package/dist/tools/types.d.cts +6 -6
  274. package/dist/tools/types.d.cts.map +1 -1
  275. package/dist/tools/types.d.ts +6 -6
  276. package/dist/tools/types.d.ts.map +1 -1
  277. package/dist/tracers/base.cjs.map +1 -1
  278. package/dist/tracers/base.d.cts +1 -1
  279. package/dist/tracers/base.d.ts +1 -1
  280. package/dist/tracers/base.js.map +1 -1
  281. package/dist/tracers/console.cjs +1 -1
  282. package/dist/tracers/console.cjs.map +1 -1
  283. package/dist/tracers/console.js +1 -1
  284. package/dist/tracers/console.js.map +1 -1
  285. package/dist/tracers/event_stream.cjs +1 -1
  286. package/dist/tracers/event_stream.cjs.map +1 -1
  287. package/dist/tracers/event_stream.d.cts +0 -1
  288. package/dist/tracers/event_stream.d.cts.map +1 -1
  289. package/dist/tracers/event_stream.d.ts +0 -1
  290. package/dist/tracers/event_stream.d.ts.map +1 -1
  291. package/dist/tracers/event_stream.js +1 -1
  292. package/dist/tracers/event_stream.js.map +1 -1
  293. package/dist/tracers/log_stream.cjs.map +1 -1
  294. package/dist/tracers/log_stream.js.map +1 -1
  295. package/dist/tracers/tracer_langchain.cjs.map +1 -1
  296. package/dist/tracers/tracer_langchain.js.map +1 -1
  297. package/dist/tracers/tracer_langchain_v1.d.cts +1 -1
  298. package/dist/tracers/tracer_langchain_v1.d.ts +1 -1
  299. package/dist/utils/chunk_array.cjs.map +1 -1
  300. package/dist/utils/chunk_array.js.map +1 -1
  301. package/dist/utils/env.cjs +1 -1
  302. package/dist/utils/env.cjs.map +1 -1
  303. package/dist/utils/env.js +1 -1
  304. package/dist/utils/env.js.map +1 -1
  305. package/dist/utils/event_source_parse.cjs.map +1 -1
  306. package/dist/utils/event_source_parse.d.cts.map +1 -1
  307. package/dist/utils/event_source_parse.d.ts.map +1 -1
  308. package/dist/utils/event_source_parse.js.map +1 -1
  309. package/dist/utils/hash.cjs +3 -8
  310. package/dist/utils/hash.cjs.map +1 -1
  311. package/dist/utils/hash.d.cts +1 -2
  312. package/dist/utils/hash.d.cts.map +1 -1
  313. package/dist/utils/hash.d.ts +1 -2
  314. package/dist/utils/hash.d.ts.map +1 -1
  315. package/dist/utils/hash.js +2 -6
  316. package/dist/utils/hash.js.map +1 -1
  317. package/dist/utils/js-sha256/hash.cjs +0 -9
  318. package/dist/utils/js-sha256/hash.cjs.map +1 -1
  319. package/dist/utils/js-sha256/hash.js +1 -5
  320. package/dist/utils/js-sha256/hash.js.map +1 -1
  321. package/dist/utils/json.cjs +2 -2
  322. package/dist/utils/json.cjs.map +1 -1
  323. package/dist/utils/json.js +2 -2
  324. package/dist/utils/json.js.map +1 -1
  325. package/dist/utils/json_schema.cjs +3 -2
  326. package/dist/utils/json_schema.cjs.map +1 -1
  327. package/dist/utils/json_schema.d.cts +8 -4
  328. package/dist/utils/json_schema.d.cts.map +1 -1
  329. package/dist/utils/json_schema.d.ts +8 -4
  330. package/dist/utils/json_schema.d.ts.map +1 -1
  331. package/dist/utils/json_schema.js +2 -1
  332. package/dist/utils/json_schema.js.map +1 -1
  333. package/dist/utils/stream.cjs.map +1 -1
  334. package/dist/utils/stream.js.map +1 -1
  335. package/dist/utils/testing/index.cjs.map +1 -1
  336. package/dist/utils/testing/index.d.cts +8 -12
  337. package/dist/utils/testing/index.d.cts.map +1 -1
  338. package/dist/utils/testing/index.d.ts +8 -12
  339. package/dist/utils/testing/index.d.ts.map +1 -1
  340. package/dist/utils/testing/index.js.map +1 -1
  341. package/dist/utils/zod-to-json-schema/Options.cjs +40 -0
  342. package/dist/utils/zod-to-json-schema/Options.cjs.map +1 -0
  343. package/dist/utils/zod-to-json-schema/Options.js +37 -0
  344. package/dist/utils/zod-to-json-schema/Options.js.map +1 -0
  345. package/dist/utils/zod-to-json-schema/Refs.cjs +30 -0
  346. package/dist/utils/zod-to-json-schema/Refs.cjs.map +1 -0
  347. package/dist/utils/zod-to-json-schema/Refs.js +30 -0
  348. package/dist/utils/zod-to-json-schema/Refs.js.map +1 -0
  349. package/dist/utils/zod-to-json-schema/errorMessages.cjs +18 -0
  350. package/dist/utils/zod-to-json-schema/errorMessages.cjs.map +1 -0
  351. package/dist/utils/zod-to-json-schema/errorMessages.d.cts +11 -0
  352. package/dist/utils/zod-to-json-schema/errorMessages.d.cts.map +1 -0
  353. package/dist/utils/zod-to-json-schema/errorMessages.d.ts +11 -0
  354. package/dist/utils/zod-to-json-schema/errorMessages.d.ts.map +1 -0
  355. package/dist/utils/zod-to-json-schema/errorMessages.js +16 -0
  356. package/dist/utils/zod-to-json-schema/errorMessages.js.map +1 -0
  357. package/dist/utils/zod-to-json-schema/getRelativePath.cjs +11 -0
  358. package/dist/utils/zod-to-json-schema/getRelativePath.cjs.map +1 -0
  359. package/dist/utils/zod-to-json-schema/getRelativePath.js +10 -0
  360. package/dist/utils/zod-to-json-schema/getRelativePath.js.map +1 -0
  361. package/dist/utils/zod-to-json-schema/index.cjs +37 -0
  362. package/dist/utils/zod-to-json-schema/index.js +37 -0
  363. package/dist/utils/zod-to-json-schema/parseDef.cjs +57 -0
  364. package/dist/utils/zod-to-json-schema/parseDef.cjs.map +1 -0
  365. package/dist/utils/zod-to-json-schema/parseDef.js +57 -0
  366. package/dist/utils/zod-to-json-schema/parseDef.js.map +1 -0
  367. package/dist/utils/zod-to-json-schema/parseTypes.d.cts +38 -0
  368. package/dist/utils/zod-to-json-schema/parseTypes.d.cts.map +1 -0
  369. package/dist/utils/zod-to-json-schema/parseTypes.d.ts +38 -0
  370. package/dist/utils/zod-to-json-schema/parseTypes.d.ts.map +1 -0
  371. package/dist/utils/zod-to-json-schema/parsers/any.cjs +17 -0
  372. package/dist/utils/zod-to-json-schema/parsers/any.cjs.map +1 -0
  373. package/dist/utils/zod-to-json-schema/parsers/any.d.cts +7 -0
  374. package/dist/utils/zod-to-json-schema/parsers/any.d.cts.map +1 -0
  375. package/dist/utils/zod-to-json-schema/parsers/any.d.ts +7 -0
  376. package/dist/utils/zod-to-json-schema/parsers/any.d.ts.map +1 -0
  377. package/dist/utils/zod-to-json-schema/parsers/any.js +17 -0
  378. package/dist/utils/zod-to-json-schema/parsers/any.js.map +1 -0
  379. package/dist/utils/zod-to-json-schema/parsers/array.cjs +24 -0
  380. package/dist/utils/zod-to-json-schema/parsers/array.cjs.map +1 -0
  381. package/dist/utils/zod-to-json-schema/parsers/array.d.cts +14 -0
  382. package/dist/utils/zod-to-json-schema/parsers/array.d.cts.map +1 -0
  383. package/dist/utils/zod-to-json-schema/parsers/array.d.ts +15 -0
  384. package/dist/utils/zod-to-json-schema/parsers/array.d.ts.map +1 -0
  385. package/dist/utils/zod-to-json-schema/parsers/array.js +23 -0
  386. package/dist/utils/zod-to-json-schema/parsers/array.js.map +1 -0
  387. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs +36 -0
  388. package/dist/utils/zod-to-json-schema/parsers/bigint.cjs.map +1 -0
  389. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts +16 -0
  390. package/dist/utils/zod-to-json-schema/parsers/bigint.d.cts.map +1 -0
  391. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts +17 -0
  392. package/dist/utils/zod-to-json-schema/parsers/bigint.d.ts.map +1 -0
  393. package/dist/utils/zod-to-json-schema/parsers/bigint.js +36 -0
  394. package/dist/utils/zod-to-json-schema/parsers/bigint.js.map +1 -0
  395. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs +9 -0
  396. package/dist/utils/zod-to-json-schema/parsers/boolean.cjs.map +1 -0
  397. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts +7 -0
  398. package/dist/utils/zod-to-json-schema/parsers/boolean.d.cts.map +1 -0
  399. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts +7 -0
  400. package/dist/utils/zod-to-json-schema/parsers/boolean.d.ts.map +1 -0
  401. package/dist/utils/zod-to-json-schema/parsers/boolean.js +8 -0
  402. package/dist/utils/zod-to-json-schema/parsers/boolean.js.map +1 -0
  403. package/dist/utils/zod-to-json-schema/parsers/branded.cjs +10 -0
  404. package/dist/utils/zod-to-json-schema/parsers/branded.cjs.map +1 -0
  405. package/dist/utils/zod-to-json-schema/parsers/branded.js +10 -0
  406. package/dist/utils/zod-to-json-schema/parsers/branded.js.map +1 -0
  407. package/dist/utils/zod-to-json-schema/parsers/catch.cjs +10 -0
  408. package/dist/utils/zod-to-json-schema/parsers/catch.cjs.map +1 -0
  409. package/dist/utils/zod-to-json-schema/parsers/catch.js +10 -0
  410. package/dist/utils/zod-to-json-schema/parsers/catch.js.map +1 -0
  411. package/dist/utils/zod-to-json-schema/parsers/date.cjs +39 -0
  412. package/dist/utils/zod-to-json-schema/parsers/date.cjs.map +1 -0
  413. package/dist/utils/zod-to-json-schema/parsers/date.d.cts +17 -0
  414. package/dist/utils/zod-to-json-schema/parsers/date.d.cts.map +1 -0
  415. package/dist/utils/zod-to-json-schema/parsers/date.d.ts +17 -0
  416. package/dist/utils/zod-to-json-schema/parsers/date.d.ts.map +1 -0
  417. package/dist/utils/zod-to-json-schema/parsers/date.js +39 -0
  418. package/dist/utils/zod-to-json-schema/parsers/date.js.map +1 -0
  419. package/dist/utils/zod-to-json-schema/parsers/default.cjs +13 -0
  420. package/dist/utils/zod-to-json-schema/parsers/default.cjs.map +1 -0
  421. package/dist/utils/zod-to-json-schema/parsers/default.js +13 -0
  422. package/dist/utils/zod-to-json-schema/parsers/default.js.map +1 -0
  423. package/dist/utils/zod-to-json-schema/parsers/effects.cjs +11 -0
  424. package/dist/utils/zod-to-json-schema/parsers/effects.cjs.map +1 -0
  425. package/dist/utils/zod-to-json-schema/parsers/effects.js +11 -0
  426. package/dist/utils/zod-to-json-schema/parsers/effects.js.map +1 -0
  427. package/dist/utils/zod-to-json-schema/parsers/enum.cjs +12 -0
  428. package/dist/utils/zod-to-json-schema/parsers/enum.cjs.map +1 -0
  429. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts +8 -0
  430. package/dist/utils/zod-to-json-schema/parsers/enum.d.cts.map +1 -0
  431. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts +10 -0
  432. package/dist/utils/zod-to-json-schema/parsers/enum.d.ts.map +1 -0
  433. package/dist/utils/zod-to-json-schema/parsers/enum.js +11 -0
  434. package/dist/utils/zod-to-json-schema/parsers/enum.js.map +1 -0
  435. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs +47 -0
  436. package/dist/utils/zod-to-json-schema/parsers/intersection.cjs.map +1 -0
  437. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts +10 -0
  438. package/dist/utils/zod-to-json-schema/parsers/intersection.d.cts.map +1 -0
  439. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts +11 -0
  440. package/dist/utils/zod-to-json-schema/parsers/intersection.d.ts.map +1 -0
  441. package/dist/utils/zod-to-json-schema/parsers/intersection.js +47 -0
  442. package/dist/utils/zod-to-json-schema/parsers/intersection.js.map +1 -0
  443. package/dist/utils/zod-to-json-schema/parsers/literal.cjs +18 -0
  444. package/dist/utils/zod-to-json-schema/parsers/literal.cjs.map +1 -0
  445. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts +11 -0
  446. package/dist/utils/zod-to-json-schema/parsers/literal.d.cts.map +1 -0
  447. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts +12 -0
  448. package/dist/utils/zod-to-json-schema/parsers/literal.d.ts.map +1 -0
  449. package/dist/utils/zod-to-json-schema/parsers/literal.js +17 -0
  450. package/dist/utils/zod-to-json-schema/parsers/literal.js.map +1 -0
  451. package/dist/utils/zod-to-json-schema/parsers/map.cjs +40 -0
  452. package/dist/utils/zod-to-json-schema/parsers/map.cjs.map +1 -0
  453. package/dist/utils/zod-to-json-schema/parsers/map.d.cts +17 -0
  454. package/dist/utils/zod-to-json-schema/parsers/map.d.cts.map +1 -0
  455. package/dist/utils/zod-to-json-schema/parsers/map.d.ts +17 -0
  456. package/dist/utils/zod-to-json-schema/parsers/map.d.ts.map +1 -0
  457. package/dist/utils/zod-to-json-schema/parsers/map.js +40 -0
  458. package/dist/utils/zod-to-json-schema/parsers/map.js.map +1 -0
  459. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs +18 -0
  460. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.cjs.map +1 -0
  461. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts +8 -0
  462. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.cts.map +1 -0
  463. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts +10 -0
  464. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.d.ts.map +1 -0
  465. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js +17 -0
  466. package/dist/utils/zod-to-json-schema/parsers/nativeEnum.js.map +1 -0
  467. package/dist/utils/zod-to-json-schema/parsers/never.cjs +13 -0
  468. package/dist/utils/zod-to-json-schema/parsers/never.cjs.map +1 -0
  469. package/dist/utils/zod-to-json-schema/parsers/never.d.cts +9 -0
  470. package/dist/utils/zod-to-json-schema/parsers/never.d.cts.map +1 -0
  471. package/dist/utils/zod-to-json-schema/parsers/never.d.ts +9 -0
  472. package/dist/utils/zod-to-json-schema/parsers/never.d.ts.map +1 -0
  473. package/dist/utils/zod-to-json-schema/parsers/never.js +13 -0
  474. package/dist/utils/zod-to-json-schema/parsers/never.js.map +1 -0
  475. package/dist/utils/zod-to-json-schema/parsers/null.cjs +12 -0
  476. package/dist/utils/zod-to-json-schema/parsers/null.cjs.map +1 -0
  477. package/dist/utils/zod-to-json-schema/parsers/null.d.cts +7 -0
  478. package/dist/utils/zod-to-json-schema/parsers/null.d.cts.map +1 -0
  479. package/dist/utils/zod-to-json-schema/parsers/null.d.ts +7 -0
  480. package/dist/utils/zod-to-json-schema/parsers/null.d.ts.map +1 -0
  481. package/dist/utils/zod-to-json-schema/parsers/null.js +11 -0
  482. package/dist/utils/zod-to-json-schema/parsers/null.js.map +1 -0
  483. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs +46 -0
  484. package/dist/utils/zod-to-json-schema/parsers/nullable.cjs.map +1 -0
  485. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts +12 -0
  486. package/dist/utils/zod-to-json-schema/parsers/nullable.d.cts.map +1 -0
  487. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts +13 -0
  488. package/dist/utils/zod-to-json-schema/parsers/nullable.d.ts.map +1 -0
  489. package/dist/utils/zod-to-json-schema/parsers/nullable.js +46 -0
  490. package/dist/utils/zod-to-json-schema/parsers/nullable.js.map +1 -0
  491. package/dist/utils/zod-to-json-schema/parsers/number.cjs +37 -0
  492. package/dist/utils/zod-to-json-schema/parsers/number.cjs.map +1 -0
  493. package/dist/utils/zod-to-json-schema/parsers/number.d.cts +15 -0
  494. package/dist/utils/zod-to-json-schema/parsers/number.d.cts.map +1 -0
  495. package/dist/utils/zod-to-json-schema/parsers/number.d.ts +16 -0
  496. package/dist/utils/zod-to-json-schema/parsers/number.d.ts.map +1 -0
  497. package/dist/utils/zod-to-json-schema/parsers/number.js +37 -0
  498. package/dist/utils/zod-to-json-schema/parsers/number.js.map +1 -0
  499. package/dist/utils/zod-to-json-schema/parsers/object.cjs +64 -0
  500. package/dist/utils/zod-to-json-schema/parsers/object.cjs.map +1 -0
  501. package/dist/utils/zod-to-json-schema/parsers/object.d.cts +12 -0
  502. package/dist/utils/zod-to-json-schema/parsers/object.d.cts.map +1 -0
  503. package/dist/utils/zod-to-json-schema/parsers/object.d.ts +13 -0
  504. package/dist/utils/zod-to-json-schema/parsers/object.d.ts.map +1 -0
  505. package/dist/utils/zod-to-json-schema/parsers/object.js +64 -0
  506. package/dist/utils/zod-to-json-schema/parsers/object.js.map +1 -0
  507. package/dist/utils/zod-to-json-schema/parsers/optional.cjs +20 -0
  508. package/dist/utils/zod-to-json-schema/parsers/optional.cjs.map +1 -0
  509. package/dist/utils/zod-to-json-schema/parsers/optional.js +20 -0
  510. package/dist/utils/zod-to-json-schema/parsers/optional.js.map +1 -0
  511. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs +28 -0
  512. package/dist/utils/zod-to-json-schema/parsers/pipeline.cjs.map +1 -0
  513. package/dist/utils/zod-to-json-schema/parsers/pipeline.js +28 -0
  514. package/dist/utils/zod-to-json-schema/parsers/pipeline.js.map +1 -0
  515. package/dist/utils/zod-to-json-schema/parsers/promise.cjs +10 -0
  516. package/dist/utils/zod-to-json-schema/parsers/promise.cjs.map +1 -0
  517. package/dist/utils/zod-to-json-schema/parsers/promise.js +10 -0
  518. package/dist/utils/zod-to-json-schema/parsers/promise.js.map +1 -0
  519. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs +10 -0
  520. package/dist/utils/zod-to-json-schema/parsers/readonly.cjs.map +1 -0
  521. package/dist/utils/zod-to-json-schema/parsers/readonly.js +10 -0
  522. package/dist/utils/zod-to-json-schema/parsers/readonly.js.map +1 -0
  523. package/dist/utils/zod-to-json-schema/parsers/record.cjs +57 -0
  524. package/dist/utils/zod-to-json-schema/parsers/record.cjs.map +1 -0
  525. package/dist/utils/zod-to-json-schema/parsers/record.d.cts +14 -0
  526. package/dist/utils/zod-to-json-schema/parsers/record.d.cts.map +1 -0
  527. package/dist/utils/zod-to-json-schema/parsers/record.d.ts +15 -0
  528. package/dist/utils/zod-to-json-schema/parsers/record.d.ts.map +1 -0
  529. package/dist/utils/zod-to-json-schema/parsers/record.js +56 -0
  530. package/dist/utils/zod-to-json-schema/parsers/record.js.map +1 -0
  531. package/dist/utils/zod-to-json-schema/parsers/set.cjs +22 -0
  532. package/dist/utils/zod-to-json-schema/parsers/set.cjs.map +1 -0
  533. package/dist/utils/zod-to-json-schema/parsers/set.d.cts +15 -0
  534. package/dist/utils/zod-to-json-schema/parsers/set.d.cts.map +1 -0
  535. package/dist/utils/zod-to-json-schema/parsers/set.d.ts +16 -0
  536. package/dist/utils/zod-to-json-schema/parsers/set.d.ts.map +1 -0
  537. package/dist/utils/zod-to-json-schema/parsers/set.js +22 -0
  538. package/dist/utils/zod-to-json-schema/parsers/set.js.map +1 -0
  539. package/dist/utils/zod-to-json-schema/parsers/string.cjs +255 -0
  540. package/dist/utils/zod-to-json-schema/parsers/string.cjs.map +1 -0
  541. package/dist/utils/zod-to-json-schema/parsers/string.d.cts +28 -0
  542. package/dist/utils/zod-to-json-schema/parsers/string.d.cts.map +1 -0
  543. package/dist/utils/zod-to-json-schema/parsers/string.d.ts +29 -0
  544. package/dist/utils/zod-to-json-schema/parsers/string.d.ts.map +1 -0
  545. package/dist/utils/zod-to-json-schema/parsers/string.js +254 -0
  546. package/dist/utils/zod-to-json-schema/parsers/string.js.map +1 -0
  547. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs +38 -0
  548. package/dist/utils/zod-to-json-schema/parsers/tuple.cjs.map +1 -0
  549. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts +15 -0
  550. package/dist/utils/zod-to-json-schema/parsers/tuple.d.cts.map +1 -0
  551. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts +16 -0
  552. package/dist/utils/zod-to-json-schema/parsers/tuple.d.ts.map +1 -0
  553. package/dist/utils/zod-to-json-schema/parsers/tuple.js +38 -0
  554. package/dist/utils/zod-to-json-schema/parsers/tuple.js.map +1 -0
  555. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs +10 -0
  556. package/dist/utils/zod-to-json-schema/parsers/undefined.cjs.map +1 -0
  557. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts +9 -0
  558. package/dist/utils/zod-to-json-schema/parsers/undefined.d.cts.map +1 -0
  559. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts +9 -0
  560. package/dist/utils/zod-to-json-schema/parsers/undefined.d.ts.map +1 -0
  561. package/dist/utils/zod-to-json-schema/parsers/undefined.js +10 -0
  562. package/dist/utils/zod-to-json-schema/parsers/undefined.js.map +1 -0
  563. package/dist/utils/zod-to-json-schema/parsers/union.cjs +67 -0
  564. package/dist/utils/zod-to-json-schema/parsers/union.cjs.map +1 -0
  565. package/dist/utils/zod-to-json-schema/parsers/union.d.cts +24 -0
  566. package/dist/utils/zod-to-json-schema/parsers/union.d.cts.map +1 -0
  567. package/dist/utils/zod-to-json-schema/parsers/union.d.ts +25 -0
  568. package/dist/utils/zod-to-json-schema/parsers/union.d.ts.map +1 -0
  569. package/dist/utils/zod-to-json-schema/parsers/union.js +66 -0
  570. package/dist/utils/zod-to-json-schema/parsers/union.js.map +1 -0
  571. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs +10 -0
  572. package/dist/utils/zod-to-json-schema/parsers/unknown.cjs.map +1 -0
  573. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts +7 -0
  574. package/dist/utils/zod-to-json-schema/parsers/unknown.d.cts.map +1 -0
  575. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts +7 -0
  576. package/dist/utils/zod-to-json-schema/parsers/unknown.d.ts.map +1 -0
  577. package/dist/utils/zod-to-json-schema/parsers/unknown.js +10 -0
  578. package/dist/utils/zod-to-json-schema/parsers/unknown.js.map +1 -0
  579. package/dist/utils/zod-to-json-schema/selectParser.cjs +81 -0
  580. package/dist/utils/zod-to-json-schema/selectParser.cjs.map +1 -0
  581. package/dist/utils/zod-to-json-schema/selectParser.js +80 -0
  582. package/dist/utils/zod-to-json-schema/selectParser.js.map +1 -0
  583. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs +70 -0
  584. package/dist/utils/zod-to-json-schema/zodToJsonSchema.cjs.map +1 -0
  585. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js +70 -0
  586. package/dist/utils/zod-to-json-schema/zodToJsonSchema.js.map +1 -0
  587. package/package.json +7 -36
  588. package/dist/utils/js-sha1/hash.cjs +0 -291
  589. package/dist/utils/js-sha1/hash.cjs.map +0 -1
  590. package/dist/utils/js-sha1/hash.d.cts +0 -9
  591. package/dist/utils/js-sha1/hash.d.cts.map +0 -1
  592. package/dist/utils/js-sha1/hash.d.ts +0 -9
  593. package/dist/utils/js-sha1/hash.d.ts.map +0 -1
  594. package/dist/utils/js-sha1/hash.js +0 -284
  595. package/dist/utils/js-sha1/hash.js.map +0 -1
@@ -1,8 +1,8 @@
1
- import { BaseMessage, BaseMessageChunk, BaseMessageFields, MessageContent, MessageType } from "./base.cjs";
1
+ import { BaseMessage, BaseMessageChunk, BaseMessageFields } from "./base.cjs";
2
+ import { $InferMessageContent, MessageStructure } from "./message.cjs";
2
3
 
3
4
  //#region src/messages/tool.d.ts
4
- type ToolMessageFields = BaseMessageFields;
5
- interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {
5
+ interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, "tool"> {
6
6
  /**
7
7
  * Artifact of the Tool execution which is not meant to be sent to the model.
8
8
  *
@@ -13,10 +13,6 @@ interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
14
  artifact?: any;
15
15
  tool_call_id: string;
16
- /**
17
- * Status of the tool invocation.
18
- * @version 0.2.19
19
- */
20
16
  status?: "success" | "error";
21
17
  }
22
18
  /**
@@ -33,11 +29,11 @@ declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;
33
29
  /**
34
30
  * Represents a tool message in a conversation.
35
31
  */
36
- declare class ToolMessage extends BaseMessage implements DirectToolOutput {
37
- content: MessageContent;
32
+ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, "tool"> implements DirectToolOutput {
38
33
  static lc_name(): string;
39
34
  get lc_aliases(): Record<string, string>;
40
35
  lc_direct_tool_output: true;
36
+ readonly type: "tool";
41
37
  /**
42
38
  * Status of the tool invocation.
43
39
  * @version 0.2.19
@@ -53,18 +49,17 @@ declare class ToolMessage extends BaseMessage implements DirectToolOutput {
53
49
  */
54
50
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
51
  artifact?: any;
56
- constructor(fields: ToolMessageFieldsWithToolCallId);
57
- constructor(fields: string | ToolMessageFields, tool_call_id: string, name?: string);
58
- _getType(): MessageType;
59
- static isInstance(message: BaseMessage): message is ToolMessage;
52
+ constructor(fields: $InferMessageContent<TStructure, "tool"> | ToolMessageFields, tool_call_id: string, name?: string);
53
+ constructor(fields: ToolMessageFields<TStructure>);
54
+ static isInstance(message: unknown): message is ToolMessage;
60
55
  get _printableFields(): Record<string, unknown>;
61
56
  }
62
57
  /**
63
58
  * Represents a chunk of a tool message, which can be concatenated
64
59
  * with other tool message chunks.
65
60
  */
66
- declare class ToolMessageChunk extends BaseMessageChunk {
67
- content: MessageContent;
61
+ declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, "tool"> {
62
+ readonly type: "tool";
68
63
  tool_call_id: string;
69
64
  /**
70
65
  * Status of the tool invocation.
@@ -80,25 +75,26 @@ declare class ToolMessageChunk extends BaseMessageChunk {
80
75
  */
81
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
77
  artifact?: any;
83
- constructor(fields: ToolMessageFieldsWithToolCallId);
78
+ constructor(fields: ToolMessageFields<TStructure>);
84
79
  static lc_name(): string;
85
- _getType(): MessageType;
86
- concat(chunk: ToolMessageChunk): ToolMessageChunk;
80
+ concat(chunk: ToolMessageChunk<TStructure>): this;
87
81
  get _printableFields(): Record<string, unknown>;
88
82
  }
89
- /**
90
- * A call to a tool.
91
- * @property {string} name - The name of the tool to be called
92
- * @property {Record<string, any>} args - The arguments to the tool call
93
- * @property {string} [id] - If provided, an identifier associated with the tool call
94
- */
95
- type ToolCall = {
96
- name: string;
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- args: Record<string, any>;
83
+ interface ToolCall<TName extends string = string, TArgs extends Record<string, unknown> = Record<string, unknown>> {
84
+ readonly type?: "tool_call";
85
+ /**
86
+ * If provided, an identifier associated with the tool call
87
+ */
99
88
  id?: string;
100
- type?: "tool_call";
101
- };
89
+ /**
90
+ * The name of the tool being called
91
+ */
92
+ name: TName;
93
+ /**
94
+ * The arguments to the tool call
95
+ */
96
+ args: TArgs;
97
+ }
102
98
  /**
103
99
  * A chunk of a tool call (e.g., as part of a stream).
104
100
  * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
@@ -143,31 +139,61 @@ type ToolCall = {
143
139
  * // }
144
140
  * // ]
145
141
  * ```
146
- *
147
- * @property {string} [name] - If provided, a substring of the name of the tool to be called
148
- * @property {string} [args] - If provided, a JSON substring of the arguments to the tool call
149
- * @property {string} [id] - If provided, a substring of an identifier for the tool call
150
- * @property {number} [index] - If provided, the index of the tool call in a sequence
151
142
  */
152
- type ToolCallChunk = {
153
- name?: string;
154
- args?: string;
143
+ interface ToolCallChunk<TName extends string = string> {
144
+ readonly type?: "tool_call_chunk";
145
+ /**
146
+ * If provided, a substring of an identifier for the tool call
147
+ */
155
148
  id?: string;
156
- index?: number;
157
- type?: "tool_call_chunk";
158
- };
159
- type InvalidToolCall = {
160
- name?: string;
149
+ /**
150
+ * If provided, a substring of the name of the tool to be called
151
+ */
152
+ name?: TName;
153
+ /**
154
+ * If provided, a JSON substring of the arguments to the tool call
155
+ */
161
156
  args?: string;
157
+ /**
158
+ * If provided, the index of the tool call in a sequence
159
+ */
160
+ index?: number;
161
+ }
162
+ interface InvalidToolCall<TName extends string = string> {
163
+ readonly type?: "invalid_tool_call";
164
+ /**
165
+ * If provided, an identifier associated with the tool call
166
+ */
162
167
  id?: string;
168
+ /**
169
+ /**
170
+ * The name of the tool being called
171
+ */
172
+ name?: TName;
173
+ /**
174
+ * The arguments to the tool call
175
+ */
176
+ args?: string;
177
+ /**
178
+ * An error message associated with the tool call
179
+ */
163
180
  error?: string;
164
- type?: "invalid_tool_call";
165
- };
181
+ /**
182
+ * Index of block in aggregate response
183
+ */
184
+ index?: string | number;
185
+ }
166
186
  declare function defaultToolCallParser(
167
187
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
188
  rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];
189
+ /**
190
+ * @deprecated Use {@link ToolMessage.isInstance} instead
191
+ */
169
192
  declare function isToolMessage(x: unknown): x is ToolMessage;
193
+ /**
194
+ * @deprecated Use {@link ToolMessageChunk.isInstance} instead
195
+ */
170
196
  declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;
171
197
  //#endregion
172
- export { DirectToolOutput, InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, ToolMessageFieldsWithToolCallId, defaultToolCallParser, isDirectToolOutput, isToolMessage, isToolMessageChunk };
198
+ export { DirectToolOutput, InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, defaultToolCallParser, isDirectToolOutput, isToolMessage, isToolMessageChunk };
173
199
  //# sourceMappingURL=tool.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.cts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","MessageType","MessageContent","ToolMessageFields","ToolMessageFieldsWithToolCallId","DirectToolOutput","isDirectToolOutput","ToolMessage","Record","ToolMessageChunk","ToolCall","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields, type MessageType, type MessageContent } from \"./base.js\";\nexport type ToolMessageFields = BaseMessageFields;\nexport interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\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 extends BaseMessage implements DirectToolOutput {\n content: MessageContent;\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFieldsWithToolCallId);\n constructor(fields: string | ToolMessageFields, tool_call_id: string, name?: string);\n _getType(): MessageType;\n static isInstance(message: BaseMessage): 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 extends BaseMessageChunk {\n content: MessageContent;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFieldsWithToolCallId);\n static lc_name(): string;\n _getType(): MessageType;\n concat(chunk: ToolMessageChunk): ToolMessageChunk;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * A call to a tool.\n * @property {string} name - The name of the tool to be called\n * @property {Record<string, any>} args - The arguments to the tool call\n * @property {string} [id] - If provided, an identifier associated with the tool call\n */\nexport type ToolCall = {\n name: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n args: Record<string, any>;\n id?: string;\n type?: \"tool_call\";\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 *\n * @property {string} [name] - If provided, a substring of the name of the tool to be called\n * @property {string} [args] - If provided, a JSON substring of the arguments to the tool call\n * @property {string} [id] - If provided, a substring of an identifier for the tool call\n * @property {number} [index] - If provided, the index of the tool call in a sequence\n */\nexport type ToolCallChunk = {\n name?: string;\n args?: string;\n id?: string;\n index?: number;\n type?: \"tool_call_chunk\";\n};\nexport type InvalidToolCall = {\n name?: string;\n args?: string;\n id?: string;\n error?: string;\n type?: \"invalid_tool_call\";\n};\nexport declare function defaultToolCallParser(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n"],"mappings":";;;KACYK,iBAAAA,GAAoBH;UACfI,+BAAAA,SAAwCD;EAD7CA;AACZ;AAwBA;AAGA;AAIA;;;EAC2B;EAEC,QAiBJC,CAAAA,EAAAA,GAAAA;EAA+B,YACtBD,EAAAA,MAAAA;EAAiB;;;;EAGhB,MAxBOL,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;;AAAuC;AA8BhF;;;;;;AAoBqCW,UAzDpBJ,gBAAAA,CAyDoBI;EAAgB,SACzBD,qBAAAA,EAAAA,IAAAA;;AArBkC,iBAlCtCF,kBAAAA,CAkCsC,CAAA,EAAA,OAAA,CAAA,EAAA,CAAA,IAlCDD,gBAkCC;AA6B9D;AAyDA;AAOA;AAOwBQ,cAlIHN,WAAAA,SAAoBT,WAAAA,YAAuBO,gBAkInB,CAAA;EAAA,OAAA,EAjIhCH,cAiIgC;EAAA,OAE/BM,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAM,IAAmBE,UAAAA,CAAAA,CAAAA,EAjIjBF,MAiIiBE,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAQ,qBAAIE,EAAAA,IAAAA;EAAe;AAClE;AACA;;EAA0C,MAAIb,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;sBAlH9DL;+BACSD;cACjBF;6BACeH,yBAAyBS;0BAC5BC;;;;;;cAMPC,gBAAAA,SAAyBV,gBAAAA;WACjCG;;;;;;;;;;;;;;;;sBAgBWE;;cAERH;gBACEQ,mBAAmBA;0BACTD;;;;;;;;KAQhBE,QAAAA;;;QAGFF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDEG,aAAAA;;;;;;;KAOAC,eAAAA;;;;;;;iBAOYC,qBAAAA;;cAEVL,yBAAyBE,YAAYE;iBAC3BE,aAAAA,mBAAgCP;iBAChCQ,kBAAAA,IAAsBhB,wBAAwBU"}
1
+ {"version":3,"file":"tool.d.cts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","DirectToolOutput","isDirectToolOutput","ToolMessage","Record","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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\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 /**\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\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, unknown> = Record<string, unknown>> {\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(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: 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"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH;EAoBnGC,QAAAA,CAAAA,EAAAA,GAAAA;EAGOC,YAAAA,EAAAA,MAAAA;EAIHC,MAAAA,CAAAA,EAAAA,SAAW,GAAA,OAAA;;;;;;;;;AAqBUH,UA5BzBC,gBAAAA,CA4ByBD;EAAU,SAA5BD,qBAAAA,EAAAA,IAAAA;;AAEIK,iBA3BJF,kBAAAA,CA2BIE,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BiCH,gBA2BjCG;;;AAvBgI;AA6BvIC,cA7BAF,WA6BgB,CAAA,mBA7BeL,gBA6Bf,GA7BkCA,gBA6BlC,CAAA,SA7B4DJ,WA6B5D,CA7BwEM,UA6BxE,EAAA,MAAA,CAAA,YA7BuGC,gBA6BvG,CAAA;EAAA,OAAA,OAAA,CAAA,CAAA,EAAA,MAAA;EAAA,IAAoBH,UAAAA,CAAAA,CAAAA,EA3BnCM,MA2BmCN,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAgB,qBAAGA,EAAAA,IAAAA;EAAgB,SAA2BE,IAAAA,EAAAA,MAAAA;EAAU;;;;EAmB/F,MACNI,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAM,YApBoET,EAAAA,MAAAA;EAAgB;AAsBtH;;;;;;EAae;EA+CEc,QAAAA,CAAAA,EAAAA,GAAAA;EAmBAC,WAAAA,CAAAA,MAAe,EA9GRb,oBAwHR,CAxH6BG,UAwH7B,EAAA,MAAA,CAAA,GAxHmDD,iBAwHnD,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAAA,MAAA;EAcQY,WAAAA,CAAAA,MAAAA,EArIAZ,iBAqIqB,CArIHC,UAqIG,CAAA;EAAA,OAAA,UAAA,CAAA,OAAA,EAAA,OAAA,CAAA,EAAA,OAAA,IApIOG,WAoIP;EAAA,IAE/BC,gBAAAA,CAAAA,CAAAA,EArIcA,MAqIdA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;AAAoD;AAIlE;AAIA;AAA0C,cAvIrBC,gBAuIqB,CAAA,mBAvIeP,gBAuIf,GAvIkCA,gBAuIlC,CAAA,SAvI4DH,gBAuI5D,CAvI6EK,UAuI7E,EAAA,MAAA,CAAA,CAAA;EAAA,SAAIL,IAAAA,EAAAA,MAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;;;;;;sBAtH9DN,kBAAkBC;;gBAExBK,iBAAiBL;0BACPI;;UAEXE,sDAAsDF,0BAA0BA;;;;;;;;;QASvFG;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA;;cAEVP,yBAAyBE,YAAYI;;;;iBAI3BE,aAAAA,mBAAgCT;;;;iBAIhCU,kBAAAA,IAAsBlB,wBAAwBU"}
@@ -1,8 +1,8 @@
1
- import { BaseMessage, BaseMessageChunk, BaseMessageFields, MessageContent, MessageType } from "./base.js";
1
+ import { BaseMessage, BaseMessageChunk, BaseMessageFields } from "./base.js";
2
+ import { $InferMessageContent, MessageStructure } from "./message.js";
2
3
 
3
4
  //#region src/messages/tool.d.ts
4
- type ToolMessageFields = BaseMessageFields;
5
- interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {
5
+ interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, "tool"> {
6
6
  /**
7
7
  * Artifact of the Tool execution which is not meant to be sent to the model.
8
8
  *
@@ -13,10 +13,6 @@ interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
14
  artifact?: any;
15
15
  tool_call_id: string;
16
- /**
17
- * Status of the tool invocation.
18
- * @version 0.2.19
19
- */
20
16
  status?: "success" | "error";
21
17
  }
22
18
  /**
@@ -33,11 +29,11 @@ declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;
33
29
  /**
34
30
  * Represents a tool message in a conversation.
35
31
  */
36
- declare class ToolMessage extends BaseMessage implements DirectToolOutput {
37
- content: MessageContent;
32
+ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, "tool"> implements DirectToolOutput {
38
33
  static lc_name(): string;
39
34
  get lc_aliases(): Record<string, string>;
40
35
  lc_direct_tool_output: true;
36
+ readonly type: "tool";
41
37
  /**
42
38
  * Status of the tool invocation.
43
39
  * @version 0.2.19
@@ -53,18 +49,17 @@ declare class ToolMessage extends BaseMessage implements DirectToolOutput {
53
49
  */
54
50
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
51
  artifact?: any;
56
- constructor(fields: ToolMessageFieldsWithToolCallId);
57
- constructor(fields: string | ToolMessageFields, tool_call_id: string, name?: string);
58
- _getType(): MessageType;
59
- static isInstance(message: BaseMessage): message is ToolMessage;
52
+ constructor(fields: $InferMessageContent<TStructure, "tool"> | ToolMessageFields, tool_call_id: string, name?: string);
53
+ constructor(fields: ToolMessageFields<TStructure>);
54
+ static isInstance(message: unknown): message is ToolMessage;
60
55
  get _printableFields(): Record<string, unknown>;
61
56
  }
62
57
  /**
63
58
  * Represents a chunk of a tool message, which can be concatenated
64
59
  * with other tool message chunks.
65
60
  */
66
- declare class ToolMessageChunk extends BaseMessageChunk {
67
- content: MessageContent;
61
+ declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, "tool"> {
62
+ readonly type: "tool";
68
63
  tool_call_id: string;
69
64
  /**
70
65
  * Status of the tool invocation.
@@ -80,25 +75,26 @@ declare class ToolMessageChunk extends BaseMessageChunk {
80
75
  */
81
76
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
77
  artifact?: any;
83
- constructor(fields: ToolMessageFieldsWithToolCallId);
78
+ constructor(fields: ToolMessageFields<TStructure>);
84
79
  static lc_name(): string;
85
- _getType(): MessageType;
86
- concat(chunk: ToolMessageChunk): ToolMessageChunk;
80
+ concat(chunk: ToolMessageChunk<TStructure>): this;
87
81
  get _printableFields(): Record<string, unknown>;
88
82
  }
89
- /**
90
- * A call to a tool.
91
- * @property {string} name - The name of the tool to be called
92
- * @property {Record<string, any>} args - The arguments to the tool call
93
- * @property {string} [id] - If provided, an identifier associated with the tool call
94
- */
95
- type ToolCall = {
96
- name: string;
97
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
- args: Record<string, any>;
83
+ interface ToolCall<TName extends string = string, TArgs extends Record<string, unknown> = Record<string, unknown>> {
84
+ readonly type?: "tool_call";
85
+ /**
86
+ * If provided, an identifier associated with the tool call
87
+ */
99
88
  id?: string;
100
- type?: "tool_call";
101
- };
89
+ /**
90
+ * The name of the tool being called
91
+ */
92
+ name: TName;
93
+ /**
94
+ * The arguments to the tool call
95
+ */
96
+ args: TArgs;
97
+ }
102
98
  /**
103
99
  * A chunk of a tool call (e.g., as part of a stream).
104
100
  * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
@@ -143,31 +139,61 @@ type ToolCall = {
143
139
  * // }
144
140
  * // ]
145
141
  * ```
146
- *
147
- * @property {string} [name] - If provided, a substring of the name of the tool to be called
148
- * @property {string} [args] - If provided, a JSON substring of the arguments to the tool call
149
- * @property {string} [id] - If provided, a substring of an identifier for the tool call
150
- * @property {number} [index] - If provided, the index of the tool call in a sequence
151
142
  */
152
- type ToolCallChunk = {
153
- name?: string;
154
- args?: string;
143
+ interface ToolCallChunk<TName extends string = string> {
144
+ readonly type?: "tool_call_chunk";
145
+ /**
146
+ * If provided, a substring of an identifier for the tool call
147
+ */
155
148
  id?: string;
156
- index?: number;
157
- type?: "tool_call_chunk";
158
- };
159
- type InvalidToolCall = {
160
- name?: string;
149
+ /**
150
+ * If provided, a substring of the name of the tool to be called
151
+ */
152
+ name?: TName;
153
+ /**
154
+ * If provided, a JSON substring of the arguments to the tool call
155
+ */
161
156
  args?: string;
157
+ /**
158
+ * If provided, the index of the tool call in a sequence
159
+ */
160
+ index?: number;
161
+ }
162
+ interface InvalidToolCall<TName extends string = string> {
163
+ readonly type?: "invalid_tool_call";
164
+ /**
165
+ * If provided, an identifier associated with the tool call
166
+ */
162
167
  id?: string;
168
+ /**
169
+ /**
170
+ * The name of the tool being called
171
+ */
172
+ name?: TName;
173
+ /**
174
+ * The arguments to the tool call
175
+ */
176
+ args?: string;
177
+ /**
178
+ * An error message associated with the tool call
179
+ */
163
180
  error?: string;
164
- type?: "invalid_tool_call";
165
- };
181
+ /**
182
+ * Index of block in aggregate response
183
+ */
184
+ index?: string | number;
185
+ }
166
186
  declare function defaultToolCallParser(
167
187
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
188
  rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];
189
+ /**
190
+ * @deprecated Use {@link ToolMessage.isInstance} instead
191
+ */
169
192
  declare function isToolMessage(x: unknown): x is ToolMessage;
193
+ /**
194
+ * @deprecated Use {@link ToolMessageChunk.isInstance} instead
195
+ */
170
196
  declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;
171
197
  //#endregion
172
- export { DirectToolOutput, InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, ToolMessageFieldsWithToolCallId, defaultToolCallParser, isDirectToolOutput, isToolMessage, isToolMessageChunk };
198
+ export { DirectToolOutput, InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage, ToolMessageChunk, ToolMessageFields, defaultToolCallParser, isDirectToolOutput, isToolMessage, isToolMessageChunk };
173
199
  //# sourceMappingURL=tool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","MessageType","MessageContent","ToolMessageFields","ToolMessageFieldsWithToolCallId","DirectToolOutput","isDirectToolOutput","ToolMessage","Record","ToolMessageChunk","ToolCall","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields, type MessageType, type MessageContent } from \"./base.js\";\nexport type ToolMessageFields = BaseMessageFields;\nexport interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\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 extends BaseMessage implements DirectToolOutput {\n content: MessageContent;\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFieldsWithToolCallId);\n constructor(fields: string | ToolMessageFields, tool_call_id: string, name?: string);\n _getType(): MessageType;\n static isInstance(message: BaseMessage): 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 extends BaseMessageChunk {\n content: MessageContent;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFieldsWithToolCallId);\n static lc_name(): string;\n _getType(): MessageType;\n concat(chunk: ToolMessageChunk): ToolMessageChunk;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * A call to a tool.\n * @property {string} name - The name of the tool to be called\n * @property {Record<string, any>} args - The arguments to the tool call\n * @property {string} [id] - If provided, an identifier associated with the tool call\n */\nexport type ToolCall = {\n name: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n args: Record<string, any>;\n id?: string;\n type?: \"tool_call\";\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 *\n * @property {string} [name] - If provided, a substring of the name of the tool to be called\n * @property {string} [args] - If provided, a JSON substring of the arguments to the tool call\n * @property {string} [id] - If provided, a substring of an identifier for the tool call\n * @property {number} [index] - If provided, the index of the tool call in a sequence\n */\nexport type ToolCallChunk = {\n name?: string;\n args?: string;\n id?: string;\n index?: number;\n type?: \"tool_call_chunk\";\n};\nexport type InvalidToolCall = {\n name?: string;\n args?: string;\n id?: string;\n error?: string;\n type?: \"invalid_tool_call\";\n};\nexport declare function defaultToolCallParser(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n"],"mappings":";;;KACYK,iBAAAA,GAAoBH;UACfI,+BAAAA,SAAwCD;EAD7CA;AACZ;AAwBA;AAGA;AAIA;;;EAC2B;EAEC,QAiBJC,CAAAA,EAAAA,GAAAA;EAA+B,YACtBD,EAAAA,MAAAA;EAAiB;;;;EAGhB,MAxBOL,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;;AAAuC;AA8BhF;;;;;;AAoBqCW,UAzDpBJ,gBAAAA,CAyDoBI;EAAgB,SACzBD,qBAAAA,EAAAA,IAAAA;;AArBkC,iBAlCtCF,kBAAAA,CAkCsC,CAAA,EAAA,OAAA,CAAA,EAAA,CAAA,IAlCDD,gBAkCC;AA6B9D;AAyDA;AAOA;AAOwBQ,cAlIHN,WAAAA,SAAoBT,WAAAA,YAAuBO,gBAkInB,CAAA;EAAA,OAAA,EAjIhCH,cAiIgC;EAAA,OAE/BM,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAM,IAAmBE,UAAAA,CAAAA,CAAAA,EAjIjBF,MAiIiBE,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAQ,qBAAIE,EAAAA,IAAAA;EAAe;AAClE;AACA;;EAA0C,MAAIb,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;sBAlH9DL;+BACSD;cACjBF;6BACeH,yBAAyBS;0BAC5BC;;;;;;cAMPC,gBAAAA,SAAyBV,gBAAAA;WACjCG;;;;;;;;;;;;;;;;sBAgBWE;;cAERH;gBACEQ,mBAAmBA;0BACTD;;;;;;;;KAQhBE,QAAAA;;;QAGFF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDEG,aAAAA;;;;;;;KAOAC,eAAAA;;;;;;;iBAOYC,qBAAAA;;cAEVL,yBAAyBE,YAAYE;iBAC3BE,aAAAA,mBAAgCP;iBAChCQ,kBAAAA,IAAsBhB,wBAAwBU"}
1
+ {"version":3,"file":"tool.d.ts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","DirectToolOutput","isDirectToolOutput","ToolMessage","Record","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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\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 /**\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\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, unknown> = Record<string, unknown>> {\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(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: 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"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH;EAoBnGC,QAAAA,CAAAA,EAAAA,GAAAA;EAGOC,YAAAA,EAAAA,MAAAA;EAIHC,MAAAA,CAAAA,EAAAA,SAAW,GAAA,OAAA;;;;;;;;;AAqBUH,UA5BzBC,gBAAAA,CA4ByBD;EAAU,SAA5BD,qBAAAA,EAAAA,IAAAA;;AAEIK,iBA3BJF,kBAAAA,CA2BIE,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BiCH,gBA2BjCG;;;AAvBgI;AA6BvIC,cA7BAF,WA6BgB,CAAA,mBA7BeL,gBA6Bf,GA7BkCA,gBA6BlC,CAAA,SA7B4DJ,WA6B5D,CA7BwEM,UA6BxE,EAAA,MAAA,CAAA,YA7BuGC,gBA6BvG,CAAA;EAAA,OAAA,OAAA,CAAA,CAAA,EAAA,MAAA;EAAA,IAAoBH,UAAAA,CAAAA,CAAAA,EA3BnCM,MA2BmCN,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAgB,qBAAGA,EAAAA,IAAAA;EAAgB,SAA2BE,IAAAA,EAAAA,MAAAA;EAAU;;;;EAmB/F,MACNI,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAM,YApBoET,EAAAA,MAAAA;EAAgB;AAsBtH;;;;;;EAae;EA+CEc,QAAAA,CAAAA,EAAAA,GAAAA;EAmBAC,WAAAA,CAAAA,MAAe,EA9GRb,oBAwHR,CAxH6BG,UAwH7B,EAAA,MAAA,CAAA,GAxHmDD,iBAwHnD,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAAA,MAAA;EAcQY,WAAAA,CAAAA,MAAAA,EArIAZ,iBAqIqB,CArIHC,UAqIG,CAAA;EAAA,OAAA,UAAA,CAAA,OAAA,EAAA,OAAA,CAAA,EAAA,OAAA,IApIOG,WAoIP;EAAA,IAE/BC,gBAAAA,CAAAA,CAAAA,EArIcA,MAqIdA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;AAAoD;AAIlE;AAIA;AAA0C,cAvIrBC,gBAuIqB,CAAA,mBAvIeP,gBAuIf,GAvIkCA,gBAuIlC,CAAA,SAvI4DH,gBAuI5D,CAvI6EK,UAuI7E,EAAA,MAAA,CAAA,CAAA;EAAA,SAAIL,IAAAA,EAAAA,MAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;;;;;;sBAtH9DN,kBAAkBC;;gBAExBK,iBAAiBL;0BACPI;;UAEXE,sDAAsDF,0BAA0BA;;;;;;;;;QASvFG;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA;;cAEVP,yBAAyBE,YAAYI;;;;iBAI3BE,aAAAA,mBAAgCT;;;;iBAIhCU,kBAAAA,IAAsBlB,wBAAwBU"}
@@ -25,6 +25,7 @@ var ToolMessage = class extends BaseMessage {
25
25
  return { tool_call_id: "tool_call_id" };
26
26
  }
27
27
  lc_direct_tool_output = true;
28
+ type = "tool";
28
29
  /**
29
30
  * Status of the tool invocation.
30
31
  * @version 0.2.19
@@ -40,21 +41,18 @@ var ToolMessage = class extends BaseMessage {
40
41
  */
41
42
  artifact;
42
43
  constructor(fields, tool_call_id, name) {
43
- if (typeof fields === "string") fields = {
44
+ const toolMessageFields = typeof fields === "string" || Array.isArray(fields) ? {
44
45
  content: fields,
45
46
  name,
46
47
  tool_call_id
47
- };
48
- super(fields);
49
- this.tool_call_id = fields.tool_call_id;
50
- this.artifact = fields.artifact;
51
- this.status = fields.status;
52
- }
53
- _getType() {
54
- return "tool";
48
+ } : fields;
49
+ super(toolMessageFields);
50
+ this.tool_call_id = toolMessageFields.tool_call_id;
51
+ this.artifact = toolMessageFields.artifact;
52
+ this.status = toolMessageFields.status;
55
53
  }
56
54
  static isInstance(message) {
57
- return message._getType() === "tool";
55
+ return super.isInstance(message) && message.type === "tool";
58
56
  }
59
57
  get _printableFields() {
60
58
  return {
@@ -68,7 +66,8 @@ var ToolMessage = class extends BaseMessage {
68
66
  * Represents a chunk of a tool message, which can be concatenated
69
67
  * with other tool message chunks.
70
68
  */
71
- var ToolMessageChunk = class ToolMessageChunk extends BaseMessageChunk {
69
+ var ToolMessageChunk = class extends BaseMessageChunk {
70
+ type = "tool";
72
71
  tool_call_id;
73
72
  /**
74
73
  * Status of the tool invocation.
@@ -92,11 +91,9 @@ var ToolMessageChunk = class ToolMessageChunk extends BaseMessageChunk {
92
91
  static lc_name() {
93
92
  return "ToolMessageChunk";
94
93
  }
95
- _getType() {
96
- return "tool";
97
- }
98
94
  concat(chunk) {
99
- return new ToolMessageChunk({
95
+ const Cls = this.constructor;
96
+ return new Cls({
100
97
  content: mergeContent(this.content, chunk.content),
101
98
  additional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs),
102
99
  response_metadata: _mergeDicts(this.response_metadata, chunk.response_metadata),
@@ -122,13 +119,12 @@ function defaultToolCallParser(rawToolCalls) {
122
119
  const functionName = toolCall.function.name;
123
120
  try {
124
121
  const functionArgs = JSON.parse(toolCall.function.arguments);
125
- const parsed = {
122
+ toolCalls.push({
126
123
  name: functionName || "",
127
124
  args: functionArgs || {},
128
125
  id: toolCall.id
129
- };
130
- toolCalls.push(parsed);
131
- } catch (error) {
126
+ });
127
+ } catch {
132
128
  invalidToolCalls.push({
133
129
  name: functionName,
134
130
  args: toolCall.function.arguments,
@@ -139,9 +135,15 @@ function defaultToolCallParser(rawToolCalls) {
139
135
  }
140
136
  return [toolCalls, invalidToolCalls];
141
137
  }
138
+ /**
139
+ * @deprecated Use {@link ToolMessage.isInstance} instead
140
+ */
142
141
  function isToolMessage(x) {
143
142
  return typeof x === "object" && x !== null && "getType" in x && typeof x.getType === "function" && x.getType() === "tool";
144
143
  }
144
+ /**
145
+ * @deprecated Use {@link ToolMessageChunk.isInstance} instead
146
+ */
145
147
  function isToolMessageChunk(x) {
146
148
  return x._getType() === "tool";
147
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tool.js","names":["x: unknown","fields: string | ToolMessageFieldsWithToolCallId","tool_call_id?: string","name?: string","message: BaseMessage","fields: ToolMessageFieldsWithToolCallId","chunk: ToolMessageChunk","rawToolCalls: Record<string, any>[]","toolCalls: ToolCall[]","invalidToolCalls: InvalidToolCall[]","x: BaseMessageChunk"],"sources":["../../src/messages/tool.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageChunk,\n type BaseMessageFields,\n mergeContent,\n _mergeDicts,\n type MessageType,\n _mergeObj,\n _mergeStatus,\n type MessageContent,\n} from \"./base.js\";\n\nexport type ToolMessageFields = BaseMessageFields;\n\nexport interface ToolMessageFieldsWithToolCallId extends ToolMessageFields {\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n}\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}\n\nexport function isDirectToolOutput(x: unknown): x is DirectToolOutput {\n return (\n x != null &&\n typeof x === \"object\" &&\n \"lc_direct_tool_output\" in x &&\n x.lc_direct_tool_output === true\n );\n}\n\n/**\n * Represents a tool message in a conversation.\n */\nexport class ToolMessage extends BaseMessage implements DirectToolOutput {\n declare content: MessageContent;\n\n static lc_name() {\n return \"ToolMessage\";\n }\n\n get lc_aliases(): Record<string, string> {\n // exclude snake case conversion to pascal case\n return { tool_call_id: \"tool_call_id\" };\n }\n\n lc_direct_tool_output = true as const;\n\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n\n tool_call_id: string;\n\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n\n constructor(fields: ToolMessageFieldsWithToolCallId);\n\n constructor(\n fields: string | ToolMessageFields,\n tool_call_id: string,\n name?: string\n );\n\n constructor(\n fields: string | ToolMessageFieldsWithToolCallId,\n tool_call_id?: string,\n name?: string\n ) {\n if (typeof fields === \"string\") {\n // eslint-disable-next-line no-param-reassign, @typescript-eslint/no-non-null-assertion\n fields = { content: fields, name, tool_call_id: tool_call_id! };\n }\n super(fields);\n this.tool_call_id = fields.tool_call_id;\n this.artifact = fields.artifact;\n this.status = fields.status;\n }\n\n _getType(): MessageType {\n return \"tool\";\n }\n\n static isInstance(message: BaseMessage): message is ToolMessage {\n return message._getType() === \"tool\";\n }\n\n override get _printableFields(): Record<string, unknown> {\n return {\n ...super._printableFields,\n tool_call_id: this.tool_call_id,\n artifact: this.artifact,\n };\n }\n}\n\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport class ToolMessageChunk extends BaseMessageChunk {\n declare content: MessageContent;\n\n tool_call_id: string;\n\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n\n constructor(fields: ToolMessageFieldsWithToolCallId) {\n super(fields);\n this.tool_call_id = fields.tool_call_id;\n this.artifact = fields.artifact;\n this.status = fields.status;\n }\n\n static lc_name() {\n return \"ToolMessageChunk\";\n }\n\n _getType(): MessageType {\n return \"tool\";\n }\n\n concat(chunk: ToolMessageChunk) {\n return new ToolMessageChunk({\n content: mergeContent(this.content, chunk.content),\n additional_kwargs: _mergeDicts(\n this.additional_kwargs,\n chunk.additional_kwargs\n ),\n response_metadata: _mergeDicts(\n this.response_metadata,\n chunk.response_metadata\n ),\n artifact: _mergeObj(this.artifact, chunk.artifact),\n tool_call_id: this.tool_call_id,\n id: this.id ?? chunk.id,\n status: _mergeStatus(this.status, chunk.status),\n });\n }\n\n override get _printableFields(): Record<string, unknown> {\n return {\n ...super._printableFields,\n tool_call_id: this.tool_call_id,\n artifact: this.artifact,\n };\n }\n}\n\n/**\n * A call to a tool.\n * @property {string} name - The name of the tool to be called\n * @property {Record<string, any>} args - The arguments to the tool call\n * @property {string} [id] - If provided, an identifier associated with the tool call\n */\nexport type ToolCall = {\n name: string;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n args: Record<string, any>;\n\n id?: string;\n\n type?: \"tool_call\";\n};\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 *\n * @property {string} [name] - If provided, a substring of the name of the tool to be called\n * @property {string} [args] - If provided, a JSON substring of the arguments to the tool call\n * @property {string} [id] - If provided, a substring of an identifier for the tool call\n * @property {number} [index] - If provided, the index of the tool call in a sequence\n */\nexport type ToolCallChunk = {\n name?: string;\n\n args?: string;\n\n id?: string;\n\n index?: number;\n\n type?: \"tool_call_chunk\";\n};\n\nexport type InvalidToolCall = {\n name?: string;\n args?: string;\n id?: string;\n error?: string;\n type?: \"invalid_tool_call\";\n};\n\nexport function defaultToolCallParser(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rawToolCalls: Record<string, any>[]\n): [ToolCall[], InvalidToolCall[]] {\n const toolCalls: ToolCall[] = [];\n const invalidToolCalls: InvalidToolCall[] = [];\n for (const toolCall of rawToolCalls) {\n if (!toolCall.function) {\n continue;\n } else {\n const functionName = toolCall.function.name;\n try {\n const functionArgs = JSON.parse(toolCall.function.arguments);\n const parsed = {\n name: functionName || \"\",\n args: functionArgs || {},\n id: toolCall.id,\n };\n toolCalls.push(parsed);\n } catch (error) {\n invalidToolCalls.push({\n name: functionName,\n args: toolCall.function.arguments,\n id: toolCall.id,\n error: \"Malformed args.\",\n });\n }\n }\n }\n return [toolCalls, invalidToolCalls];\n}\n\nexport function isToolMessage(x: unknown): x is ToolMessage {\n return (\n typeof x === \"object\" &&\n x !== null &&\n \"getType\" in x &&\n typeof x.getType === \"function\" &&\n x.getType() === \"tool\"\n );\n}\n\nexport function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk {\n return x._getType() === \"tool\";\n}\n"],"mappings":";;;;;;;;;;;;;AA2CA,SAAgB,mBAAmBA,GAAmC;AACpE,QACE,KAAK,QACL,OAAO,MAAM,YACb,2BAA2B,KAC3B,EAAE,0BAA0B;AAE/B;;;;AAKD,IAAa,cAAb,cAAiC,YAAwC;CAGvE,OAAO,UAAU;AACf,SAAO;CACR;CAED,IAAI,aAAqC;AAEvC,SAAO,EAAE,cAAc,eAAgB;CACxC;CAED,wBAAwB;;;;;CAMxB;CAEA;;;;;;;;CAUA;CAUA,YACEC,QACAC,cACAC,MACA;AACA,MAAI,OAAO,WAAW,UAEpB,SAAS;GAAE,SAAS;GAAQ;GAAoB;EAAe;EAEjE,MAAM,OAAO;EACb,KAAK,eAAe,OAAO;EAC3B,KAAK,WAAW,OAAO;EACvB,KAAK,SAAS,OAAO;CACtB;CAED,WAAwB;AACtB,SAAO;CACR;CAED,OAAO,WAAWC,SAA8C;AAC9D,SAAO,QAAQ,UAAU,KAAK;CAC/B;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;;;;;AAMD,IAAa,mBAAb,MAAa,yBAAyB,iBAAiB;CAGrD;;;;;CAMA;;;;;;;;CAUA;CAEA,YAAYC,QAAyC;EACnD,MAAM,OAAO;EACb,KAAK,eAAe,OAAO;EAC3B,KAAK,WAAW,OAAO;EACvB,KAAK,SAAS,OAAO;CACtB;CAED,OAAO,UAAU;AACf,SAAO;CACR;CAED,WAAwB;AACtB,SAAO;CACR;CAED,OAAOC,OAAyB;AAC9B,SAAO,IAAI,iBAAiB;GAC1B,SAAS,aAAa,KAAK,SAAS,MAAM,QAAQ;GAClD,mBAAmB,YACjB,KAAK,mBACL,MAAM,kBACP;GACD,mBAAmB,YACjB,KAAK,mBACL,MAAM,kBACP;GACD,UAAU,UAAU,KAAK,UAAU,MAAM,SAAS;GAClD,cAAc,KAAK;GACnB,IAAI,KAAK,MAAM,MAAM;GACrB,QAAQ,aAAa,KAAK,QAAQ,MAAM,OAAO;EAChD;CACF;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;AAyFD,SAAgB,sBAEdC,cACiC;CACjC,MAAMC,YAAwB,CAAE;CAChC,MAAMC,mBAAsC,CAAE;AAC9C,MAAK,MAAM,YAAY,aACrB,KAAI,CAAC,SAAS,SACZ;MACK;EACL,MAAM,eAAe,SAAS,SAAS;AACvC,MAAI;GACF,MAAM,eAAe,KAAK,MAAM,SAAS,SAAS,UAAU;GAC5D,MAAM,SAAS;IACb,MAAM,gBAAgB;IACtB,MAAM,gBAAgB,CAAE;IACxB,IAAI,SAAS;GACd;GACD,UAAU,KAAK,OAAO;EACvB,SAAQ,OAAO;GACd,iBAAiB,KAAK;IACpB,MAAM;IACN,MAAM,SAAS,SAAS;IACxB,IAAI,SAAS;IACb,OAAO;GACR,EAAC;EACH;CACF;AAEH,QAAO,CAAC,WAAW,gBAAiB;AACrC;AAED,SAAgB,cAAcT,GAA8B;AAC1D,QACE,OAAO,MAAM,YACb,MAAM,QACN,aAAa,KACb,OAAO,EAAE,YAAY,cACrB,EAAE,SAAS,KAAK;AAEnB;AAED,SAAgB,mBAAmBU,GAA4C;AAC7E,QAAO,EAAE,UAAU,KAAK;AACzB"}
1
+ {"version":3,"file":"tool.js","names":["x: unknown","fields:\n | $InferMessageContent<TStructure, \"tool\">\n | ToolMessageFields<TStructure>","tool_call_id?: string","name?: string","toolMessageFields: ToolMessageFields<TStructure>","message: unknown","fields: ToolMessageFields<TStructure>","chunk: ToolMessageChunk<TStructure>","rawToolCalls: Record<string, any>[]","toolCalls: ToolCall[]","invalidToolCalls: InvalidToolCall[]","x: BaseMessageChunk"],"sources":["../../src/messages/tool.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageChunk,\n type BaseMessageFields,\n mergeContent,\n _mergeDicts,\n _mergeObj,\n _mergeStatus,\n} from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nimport { Constructor } from \"./utils.js\";\n\nexport interface ToolMessageFields<\n TStructure extends MessageStructure = MessageStructure\n> 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n}\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}\n\nexport function isDirectToolOutput(x: unknown): x is DirectToolOutput {\n return (\n x != null &&\n typeof x === \"object\" &&\n \"lc_direct_tool_output\" in x &&\n x.lc_direct_tool_output === true\n );\n}\n\n/**\n * Represents a tool message in a conversation.\n */\nexport class ToolMessage<TStructure extends MessageStructure = MessageStructure>\n extends BaseMessage<TStructure, \"tool\">\n implements DirectToolOutput\n{\n static lc_name() {\n return \"ToolMessage\";\n }\n\n get lc_aliases(): Record<string, string> {\n // exclude snake case conversion to pascal case\n return { tool_call_id: \"tool_call_id\" };\n }\n\n lc_direct_tool_output = true as const;\n\n readonly type = \"tool\" as const;\n\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n\n tool_call_id: string;\n\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n\n constructor(\n fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields,\n tool_call_id: string,\n name?: string\n );\n\n constructor(fields: ToolMessageFields<TStructure>);\n\n constructor(\n fields:\n | $InferMessageContent<TStructure, \"tool\">\n | ToolMessageFields<TStructure>,\n tool_call_id?: string,\n name?: string\n ) {\n const toolMessageFields: ToolMessageFields<TStructure> =\n typeof fields === \"string\" || Array.isArray(fields)\n ? { content: fields, name, tool_call_id: tool_call_id! }\n : fields;\n super(toolMessageFields);\n this.tool_call_id = toolMessageFields.tool_call_id;\n this.artifact = toolMessageFields.artifact;\n this.status = toolMessageFields.status;\n }\n\n static isInstance(message: unknown): message is ToolMessage {\n return super.isInstance(message) && message.type === \"tool\";\n }\n\n override get _printableFields(): Record<string, unknown> {\n return {\n ...super._printableFields,\n tool_call_id: this.tool_call_id,\n artifact: this.artifact,\n };\n }\n}\n\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport class ToolMessageChunk<\n TStructure extends MessageStructure = MessageStructure\n> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type = \"tool\" as const;\n\n tool_call_id: string;\n\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n\n constructor(fields: ToolMessageFields<TStructure>) {\n super(fields);\n this.tool_call_id = fields.tool_call_id;\n this.artifact = fields.artifact;\n this.status = fields.status;\n }\n\n static lc_name() {\n return \"ToolMessageChunk\";\n }\n\n concat(chunk: ToolMessageChunk<TStructure>) {\n const Cls = this.constructor as Constructor<this>;\n return new Cls({\n content: mergeContent(this.content, chunk.content),\n additional_kwargs: _mergeDicts(\n this.additional_kwargs,\n chunk.additional_kwargs\n ),\n response_metadata: _mergeDicts(\n this.response_metadata,\n chunk.response_metadata\n ),\n artifact: _mergeObj(this.artifact, chunk.artifact),\n tool_call_id: this.tool_call_id,\n id: this.id ?? chunk.id,\n status: _mergeStatus(this.status, chunk.status),\n });\n }\n\n override get _printableFields(): Record<string, unknown> {\n return {\n ...super._printableFields,\n tool_call_id: this.tool_call_id,\n artifact: this.artifact,\n };\n }\n}\n\nexport interface ToolCall<\n TName extends string = string,\n TArgs extends Record<string, unknown> = Record<string, unknown>\n> {\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/**\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}\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}\n\nexport function defaultToolCallParser(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n rawToolCalls: Record<string, any>[]\n): [ToolCall[], InvalidToolCall[]] {\n const toolCalls: ToolCall[] = [];\n const invalidToolCalls: InvalidToolCall[] = [];\n for (const toolCall of rawToolCalls) {\n if (!toolCall.function) {\n continue;\n } else {\n const functionName = toolCall.function.name;\n try {\n const functionArgs = JSON.parse(toolCall.function.arguments);\n toolCalls.push({\n name: functionName || \"\",\n args: functionArgs || {},\n id: toolCall.id,\n });\n } catch {\n invalidToolCalls.push({\n name: functionName,\n args: toolCall.function.arguments,\n id: toolCall.id,\n error: \"Malformed args.\",\n });\n }\n }\n }\n return [toolCalls, invalidToolCalls];\n}\n\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport function isToolMessage(x: unknown): x is ToolMessage {\n return (\n typeof x === \"object\" &&\n x !== null &&\n \"getType\" in x &&\n typeof x.getType === \"function\" &&\n x.getType() === \"tool\"\n );\n}\n\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk {\n return x._getType() === \"tool\";\n}\n"],"mappings":";;;;;;;;;;;;;AAuCA,SAAgB,mBAAmBA,GAAmC;AACpE,QACE,KAAK,QACL,OAAO,MAAM,YACb,2BAA2B,KAC3B,EAAE,0BAA0B;AAE/B;;;;AAKD,IAAa,cAAb,cACU,YAEV;CACE,OAAO,UAAU;AACf,SAAO;CACR;CAED,IAAI,aAAqC;AAEvC,SAAO,EAAE,cAAc,eAAgB;CACxC;CAED,wBAAwB;CAExB,AAAS,OAAO;;;;;CAMhB;CAEA;;;;;;;;CAUA;CAUA,YACEC,QAGAC,cACAC,MACA;EACA,MAAMC,oBACJ,OAAO,WAAW,YAAY,MAAM,QAAQ,OAAO,GAC/C;GAAE,SAAS;GAAQ;GAAoB;EAAe,IACtD;EACN,MAAM,kBAAkB;EACxB,KAAK,eAAe,kBAAkB;EACtC,KAAK,WAAW,kBAAkB;EAClC,KAAK,SAAS,kBAAkB;CACjC;CAED,OAAO,WAAWC,SAA0C;AAC1D,SAAO,MAAM,WAAW,QAAQ,IAAI,QAAQ,SAAS;CACtD;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;;;;;AAMD,IAAa,mBAAb,cAEU,iBAAqC;CAC7C,AAAS,OAAO;CAEhB;;;;;CAMA;;;;;;;;CAUA;CAEA,YAAYC,QAAuC;EACjD,MAAM,OAAO;EACb,KAAK,eAAe,OAAO;EAC3B,KAAK,WAAW,OAAO;EACvB,KAAK,SAAS,OAAO;CACtB;CAED,OAAO,UAAU;AACf,SAAO;CACR;CAED,OAAOC,OAAqC;EAC1C,MAAM,MAAM,KAAK;AACjB,SAAO,IAAI,IAAI;GACb,SAAS,aAAa,KAAK,SAAS,MAAM,QAAQ;GAClD,mBAAmB,YACjB,KAAK,mBACL,MAAM,kBACP;GACD,mBAAmB,YACjB,KAAK,mBACL,MAAM,kBACP;GACD,UAAU,UAAU,KAAK,UAAU,MAAM,SAAS;GAClD,cAAc,KAAK;GACnB,IAAI,KAAK,MAAM,MAAM;GACrB,QAAQ,aAAa,KAAK,QAAQ,MAAM,OAAO;EAChD;CACF;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;AA+GD,SAAgB,sBAEdC,cACiC;CACjC,MAAMC,YAAwB,CAAE;CAChC,MAAMC,mBAAsC,CAAE;AAC9C,MAAK,MAAM,YAAY,aACrB,KAAI,CAAC,SAAS,SACZ;MACK;EACL,MAAM,eAAe,SAAS,SAAS;AACvC,MAAI;GACF,MAAM,eAAe,KAAK,MAAM,SAAS,SAAS,UAAU;GAC5D,UAAU,KAAK;IACb,MAAM,gBAAgB;IACtB,MAAM,gBAAgB,CAAE;IACxB,IAAI,SAAS;GACd,EAAC;EACH,QAAO;GACN,iBAAiB,KAAK;IACpB,MAAM;IACN,MAAM,SAAS,SAAS;IACxB,IAAI,SAAS;IACb,OAAO;GACR,EAAC;EACH;CACF;AAEH,QAAO,CAAC,WAAW,gBAAiB;AACrC;;;;AAKD,SAAgB,cAAcV,GAA8B;AAC1D,QACE,OAAO,MAAM,YACb,MAAM,QACN,aAAa,KACb,OAAO,EAAE,YAAY,cACrB,EAAE,SAAS,KAAK;AAEnB;;;;AAKD,SAAgB,mBAAmBW,GAA4C;AAC7E,QAAO,EAAE,UAAU,KAAK;AACzB"}
@@ -5,9 +5,9 @@ const require_chat = require('./chat.cjs');
5
5
  const require_function = require('./function.cjs');
6
6
  const require_human = require('./human.cjs');
7
7
  const require_system = require('./system.cjs');
8
+ const require_modifier = require('./modifier.cjs');
8
9
  const require_utils = require('./utils.cjs');
9
10
  const require_base$1 = require('../runnables/base.cjs');
10
- const require_modifier = require('./modifier.cjs');
11
11
 
12
12
  //#region src/messages/transformers.ts
13
13
  const _isMessageType = (msg, types) => {
@@ -114,7 +114,7 @@ async function _firstMaxTokens(messages, options) {
114
114
  break;
115
115
  }
116
116
  }
117
- if (idx < messagesCopy.length - 1 && partialStrategy) {
117
+ if (idx < messagesCopy.length && partialStrategy) {
118
118
  let includedPartial = false;
119
119
  if (Array.isArray(messagesCopy[idx].content)) {
120
120
  const excluded = messagesCopy[idx];