@langchain/core 1.1.5 → 1.2.0-dev-1765937705265

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 (316) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/caches/index.d.cts +2 -2
  3. package/dist/caches/index.d.cts.map +1 -1
  4. package/dist/caches/index.d.ts +2 -2
  5. package/dist/caches/index.d.ts.map +1 -1
  6. package/dist/callbacks/base.d.cts +2 -2
  7. package/dist/callbacks/base.d.cts.map +1 -1
  8. package/dist/callbacks/base.d.ts +2 -2
  9. package/dist/callbacks/base.d.ts.map +1 -1
  10. package/dist/load/index.d.cts.map +1 -1
  11. package/dist/messages/ai.cjs +13 -9
  12. package/dist/messages/ai.cjs.map +1 -1
  13. package/dist/messages/ai.d.cts +25 -5
  14. package/dist/messages/ai.d.cts.map +1 -1
  15. package/dist/messages/ai.d.ts +25 -5
  16. package/dist/messages/ai.d.ts.map +1 -1
  17. package/dist/messages/ai.js +13 -9
  18. package/dist/messages/ai.js.map +1 -1
  19. package/dist/messages/base.cjs +2 -2
  20. package/dist/messages/base.cjs.map +1 -1
  21. package/dist/messages/base.d.cts +1 -1
  22. package/dist/messages/base.d.cts.map +1 -1
  23. package/dist/messages/base.d.ts +1 -1
  24. package/dist/messages/base.d.ts.map +1 -1
  25. package/dist/messages/base.js +2 -2
  26. package/dist/messages/base.js.map +1 -1
  27. package/dist/messages/index.d.cts +2 -2
  28. package/dist/messages/index.d.ts +2 -2
  29. package/dist/messages/message.cjs.map +1 -1
  30. package/dist/messages/message.d.cts +62 -6
  31. package/dist/messages/message.d.cts.map +1 -1
  32. package/dist/messages/message.d.ts +62 -6
  33. package/dist/messages/message.d.ts.map +1 -1
  34. package/dist/messages/message.js.map +1 -1
  35. package/dist/messages/tool.cjs.map +1 -1
  36. package/dist/messages/tool.d.cts +10 -0
  37. package/dist/messages/tool.d.cts.map +1 -1
  38. package/dist/messages/tool.d.ts +10 -0
  39. package/dist/messages/tool.d.ts.map +1 -1
  40. package/dist/messages/tool.js.map +1 -1
  41. package/dist/messages/utils.d.cts +3 -3
  42. package/dist/messages/utils.d.cts.map +1 -1
  43. package/dist/messages/utils.d.ts +3 -3
  44. package/dist/messages/utils.d.ts.map +1 -1
  45. package/dist/prompt_values.d.cts +4 -4
  46. package/dist/prompt_values.d.cts.map +1 -1
  47. package/dist/prompt_values.d.ts +4 -4
  48. package/dist/prompt_values.d.ts.map +1 -1
  49. package/dist/prompts/chat.d.cts +2 -2
  50. package/dist/prompts/chat.d.cts.map +1 -1
  51. package/dist/prompts/chat.d.ts +2 -2
  52. package/dist/prompts/chat.d.ts.map +1 -1
  53. package/dist/stores.d.cts.map +1 -1
  54. package/dist/stores.d.ts.map +1 -1
  55. package/dist/tools/index.cjs +2 -1
  56. package/dist/tools/index.cjs.map +1 -1
  57. package/dist/tools/index.d.cts +17 -12
  58. package/dist/tools/index.d.cts.map +1 -1
  59. package/dist/tools/index.d.ts +17 -12
  60. package/dist/tools/index.d.ts.map +1 -1
  61. package/dist/tools/index.js +2 -1
  62. package/dist/tools/index.js.map +1 -1
  63. package/dist/tracers/event_stream.cjs +5 -1
  64. package/dist/tracers/event_stream.cjs.map +1 -1
  65. package/dist/tracers/event_stream.d.cts.map +1 -1
  66. package/dist/tracers/event_stream.d.ts.map +1 -1
  67. package/dist/tracers/event_stream.js +5 -1
  68. package/dist/tracers/event_stream.js.map +1 -1
  69. package/dist/utils/event_source_parse.d.cts.map +1 -1
  70. package/dist/utils/stream.d.cts.map +1 -1
  71. package/dist/utils/testing/chat_models.cjs +4 -1
  72. package/dist/utils/testing/chat_models.cjs.map +1 -1
  73. package/dist/utils/testing/chat_models.d.cts +5 -5
  74. package/dist/utils/testing/chat_models.d.cts.map +1 -1
  75. package/dist/utils/testing/chat_models.d.ts +5 -5
  76. package/dist/utils/testing/chat_models.d.ts.map +1 -1
  77. package/dist/utils/testing/chat_models.js +4 -1
  78. package/dist/utils/testing/chat_models.js.map +1 -1
  79. package/dist/vectorstores.d.cts.map +1 -1
  80. package/package.json +2 -2
  81. package/agents.cjs +0 -1
  82. package/agents.d.cts +0 -1
  83. package/agents.d.ts +0 -1
  84. package/agents.js +0 -1
  85. package/caches.cjs +0 -1
  86. package/caches.d.cts +0 -1
  87. package/caches.d.ts +0 -1
  88. package/caches.js +0 -1
  89. package/callbacks/base.cjs +0 -1
  90. package/callbacks/base.d.cts +0 -1
  91. package/callbacks/base.d.ts +0 -1
  92. package/callbacks/base.js +0 -1
  93. package/callbacks/dispatch/web.cjs +0 -1
  94. package/callbacks/dispatch/web.d.cts +0 -1
  95. package/callbacks/dispatch/web.d.ts +0 -1
  96. package/callbacks/dispatch/web.js +0 -1
  97. package/callbacks/dispatch.cjs +0 -1
  98. package/callbacks/dispatch.d.cts +0 -1
  99. package/callbacks/dispatch.d.ts +0 -1
  100. package/callbacks/dispatch.js +0 -1
  101. package/callbacks/manager.cjs +0 -1
  102. package/callbacks/manager.d.cts +0 -1
  103. package/callbacks/manager.d.ts +0 -1
  104. package/callbacks/manager.js +0 -1
  105. package/callbacks/promises.cjs +0 -1
  106. package/callbacks/promises.d.cts +0 -1
  107. package/callbacks/promises.d.ts +0 -1
  108. package/callbacks/promises.js +0 -1
  109. package/chat_history.cjs +0 -1
  110. package/chat_history.d.cts +0 -1
  111. package/chat_history.d.ts +0 -1
  112. package/chat_history.js +0 -1
  113. package/context.cjs +0 -1
  114. package/context.d.cts +0 -1
  115. package/context.d.ts +0 -1
  116. package/context.js +0 -1
  117. package/document_loaders/base.cjs +0 -1
  118. package/document_loaders/base.d.cts +0 -1
  119. package/document_loaders/base.d.ts +0 -1
  120. package/document_loaders/base.js +0 -1
  121. package/document_loaders/langsmith.cjs +0 -1
  122. package/document_loaders/langsmith.d.cts +0 -1
  123. package/document_loaders/langsmith.d.ts +0 -1
  124. package/document_loaders/langsmith.js +0 -1
  125. package/documents.cjs +0 -1
  126. package/documents.d.cts +0 -1
  127. package/documents.d.ts +0 -1
  128. package/documents.js +0 -1
  129. package/embeddings.cjs +0 -1
  130. package/embeddings.d.cts +0 -1
  131. package/embeddings.d.ts +0 -1
  132. package/embeddings.js +0 -1
  133. package/example_selectors.cjs +0 -1
  134. package/example_selectors.d.cts +0 -1
  135. package/example_selectors.d.ts +0 -1
  136. package/example_selectors.js +0 -1
  137. package/indexing.cjs +0 -1
  138. package/indexing.d.cts +0 -1
  139. package/indexing.d.ts +0 -1
  140. package/indexing.js +0 -1
  141. package/language_models/base.cjs +0 -1
  142. package/language_models/base.d.cts +0 -1
  143. package/language_models/base.d.ts +0 -1
  144. package/language_models/base.js +0 -1
  145. package/language_models/chat_models.cjs +0 -1
  146. package/language_models/chat_models.d.cts +0 -1
  147. package/language_models/chat_models.d.ts +0 -1
  148. package/language_models/chat_models.js +0 -1
  149. package/language_models/llms.cjs +0 -1
  150. package/language_models/llms.d.cts +0 -1
  151. package/language_models/llms.d.ts +0 -1
  152. package/language_models/llms.js +0 -1
  153. package/language_models/profile.cjs +0 -1
  154. package/language_models/profile.d.cts +0 -1
  155. package/language_models/profile.d.ts +0 -1
  156. package/language_models/profile.js +0 -1
  157. package/load/serializable.cjs +0 -1
  158. package/load/serializable.d.cts +0 -1
  159. package/load/serializable.d.ts +0 -1
  160. package/load/serializable.js +0 -1
  161. package/load.cjs +0 -1
  162. package/load.d.cts +0 -1
  163. package/load.d.ts +0 -1
  164. package/load.js +0 -1
  165. package/memory.cjs +0 -1
  166. package/memory.d.cts +0 -1
  167. package/memory.d.ts +0 -1
  168. package/memory.js +0 -1
  169. package/messages/tool.cjs +0 -1
  170. package/messages/tool.d.cts +0 -1
  171. package/messages/tool.d.ts +0 -1
  172. package/messages/tool.js +0 -1
  173. package/messages.cjs +0 -1
  174. package/messages.d.cts +0 -1
  175. package/messages.d.ts +0 -1
  176. package/messages.js +0 -1
  177. package/output_parsers/openai_functions.cjs +0 -1
  178. package/output_parsers/openai_functions.d.cts +0 -1
  179. package/output_parsers/openai_functions.d.ts +0 -1
  180. package/output_parsers/openai_functions.js +0 -1
  181. package/output_parsers/openai_tools.cjs +0 -1
  182. package/output_parsers/openai_tools.d.cts +0 -1
  183. package/output_parsers/openai_tools.d.ts +0 -1
  184. package/output_parsers/openai_tools.js +0 -1
  185. package/output_parsers.cjs +0 -1
  186. package/output_parsers.d.cts +0 -1
  187. package/output_parsers.d.ts +0 -1
  188. package/output_parsers.js +0 -1
  189. package/outputs.cjs +0 -1
  190. package/outputs.d.cts +0 -1
  191. package/outputs.d.ts +0 -1
  192. package/outputs.js +0 -1
  193. package/prompt_values.cjs +0 -1
  194. package/prompt_values.d.cts +0 -1
  195. package/prompt_values.d.ts +0 -1
  196. package/prompt_values.js +0 -1
  197. package/prompts.cjs +0 -1
  198. package/prompts.d.cts +0 -1
  199. package/prompts.d.ts +0 -1
  200. package/prompts.js +0 -1
  201. package/retrievers/document_compressors.cjs +0 -1
  202. package/retrievers/document_compressors.d.cts +0 -1
  203. package/retrievers/document_compressors.d.ts +0 -1
  204. package/retrievers/document_compressors.js +0 -1
  205. package/retrievers.cjs +0 -1
  206. package/retrievers.d.cts +0 -1
  207. package/retrievers.d.ts +0 -1
  208. package/retrievers.js +0 -1
  209. package/runnables/graph.cjs +0 -1
  210. package/runnables/graph.d.cts +0 -1
  211. package/runnables/graph.d.ts +0 -1
  212. package/runnables/graph.js +0 -1
  213. package/runnables.cjs +0 -1
  214. package/runnables.d.cts +0 -1
  215. package/runnables.d.ts +0 -1
  216. package/runnables.js +0 -1
  217. package/singletons.cjs +0 -1
  218. package/singletons.d.cts +0 -1
  219. package/singletons.d.ts +0 -1
  220. package/singletons.js +0 -1
  221. package/stores.cjs +0 -1
  222. package/stores.d.cts +0 -1
  223. package/stores.d.ts +0 -1
  224. package/stores.js +0 -1
  225. package/structured_query.cjs +0 -1
  226. package/structured_query.d.cts +0 -1
  227. package/structured_query.d.ts +0 -1
  228. package/structured_query.js +0 -1
  229. package/tools.cjs +0 -1
  230. package/tools.d.cts +0 -1
  231. package/tools.d.ts +0 -1
  232. package/tools.js +0 -1
  233. package/tracers/base.cjs +0 -1
  234. package/tracers/base.d.cts +0 -1
  235. package/tracers/base.d.ts +0 -1
  236. package/tracers/base.js +0 -1
  237. package/tracers/console.cjs +0 -1
  238. package/tracers/console.d.cts +0 -1
  239. package/tracers/console.d.ts +0 -1
  240. package/tracers/console.js +0 -1
  241. package/tracers/log_stream.cjs +0 -1
  242. package/tracers/log_stream.d.cts +0 -1
  243. package/tracers/log_stream.d.ts +0 -1
  244. package/tracers/log_stream.js +0 -1
  245. package/tracers/run_collector.cjs +0 -1
  246. package/tracers/run_collector.d.cts +0 -1
  247. package/tracers/run_collector.d.ts +0 -1
  248. package/tracers/run_collector.js +0 -1
  249. package/tracers/tracer_langchain.cjs +0 -1
  250. package/tracers/tracer_langchain.d.cts +0 -1
  251. package/tracers/tracer_langchain.d.ts +0 -1
  252. package/tracers/tracer_langchain.js +0 -1
  253. package/types/stream.cjs +0 -1
  254. package/types/stream.d.cts +0 -1
  255. package/types/stream.d.ts +0 -1
  256. package/types/stream.js +0 -1
  257. package/utils/async_caller.cjs +0 -1
  258. package/utils/async_caller.d.cts +0 -1
  259. package/utils/async_caller.d.ts +0 -1
  260. package/utils/async_caller.js +0 -1
  261. package/utils/chunk_array.cjs +0 -1
  262. package/utils/chunk_array.d.cts +0 -1
  263. package/utils/chunk_array.d.ts +0 -1
  264. package/utils/chunk_array.js +0 -1
  265. package/utils/env.cjs +0 -1
  266. package/utils/env.d.cts +0 -1
  267. package/utils/env.d.ts +0 -1
  268. package/utils/env.js +0 -1
  269. package/utils/event_source_parse.cjs +0 -1
  270. package/utils/event_source_parse.d.cts +0 -1
  271. package/utils/event_source_parse.d.ts +0 -1
  272. package/utils/event_source_parse.js +0 -1
  273. package/utils/format.cjs +0 -1
  274. package/utils/format.d.cts +0 -1
  275. package/utils/format.d.ts +0 -1
  276. package/utils/format.js +0 -1
  277. package/utils/function_calling.cjs +0 -1
  278. package/utils/function_calling.d.cts +0 -1
  279. package/utils/function_calling.d.ts +0 -1
  280. package/utils/function_calling.js +0 -1
  281. package/utils/hash.cjs +0 -1
  282. package/utils/hash.d.cts +0 -1
  283. package/utils/hash.d.ts +0 -1
  284. package/utils/hash.js +0 -1
  285. package/utils/json_patch.cjs +0 -1
  286. package/utils/json_patch.d.cts +0 -1
  287. package/utils/json_patch.d.ts +0 -1
  288. package/utils/json_patch.js +0 -1
  289. package/utils/json_schema.cjs +0 -1
  290. package/utils/json_schema.d.cts +0 -1
  291. package/utils/json_schema.d.ts +0 -1
  292. package/utils/json_schema.js +0 -1
  293. package/utils/math.cjs +0 -1
  294. package/utils/math.d.cts +0 -1
  295. package/utils/math.d.ts +0 -1
  296. package/utils/math.js +0 -1
  297. package/utils/stream.cjs +0 -1
  298. package/utils/stream.d.cts +0 -1
  299. package/utils/stream.d.ts +0 -1
  300. package/utils/stream.js +0 -1
  301. package/utils/testing.cjs +0 -1
  302. package/utils/testing.d.cts +0 -1
  303. package/utils/testing.d.ts +0 -1
  304. package/utils/testing.js +0 -1
  305. package/utils/tiktoken.cjs +0 -1
  306. package/utils/tiktoken.d.cts +0 -1
  307. package/utils/tiktoken.d.ts +0 -1
  308. package/utils/tiktoken.js +0 -1
  309. package/utils/types.cjs +0 -1
  310. package/utils/types.d.cts +0 -1
  311. package/utils/types.d.ts +0 -1
  312. package/utils/types.js +0 -1
  313. package/vectorstores.cjs +0 -1
  314. package/vectorstores.d.cts +0 -1
  315. package/vectorstores.d.ts +0 -1
  316. package/vectorstores.js +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tool.cjs","names":["x: unknown","BaseMessage","fields:\n | $InferMessageContent<TStructure, \"tool\">\n | ToolMessageFields<TStructure>","tool_call_id?: string","name?: string","toolMessageFields: ToolMessageFields<TStructure>","message: unknown","BaseMessageChunk","fields: ToolMessageFields<TStructure>","chunk: ToolMessageChunk<TStructure>","mergeContent","_mergeDicts","_mergeObj","_mergeStatus","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 metadata?: Record<string, unknown>;\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 metadata?: Record<string, unknown>;\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 this.metadata = toolMessageFields.metadata;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs extends Record<string, any> = Record<string, any>\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":";;;;;;;;;;;;;AAwCA,SAAgB,mBAAmBA,GAAmC;AACpE,QACE,KAAK,QACL,OAAO,MAAM,YACb,2BAA2B,KAC3B,EAAE,0BAA0B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ChD;CACF;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;AAgHD,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,cAAchB,GAA8B;AAC1D,QACE,OAAO,MAAM,YACb,MAAM,QACN,aAAa,KACb,OAAO,EAAE,YAAY,cACrB,EAAE,SAAS,KAAK;AAEnB;;;;AAKD,SAAgB,mBAAmBiB,GAA4C;AAC7E,QAAO,EAAE,UAAU,KAAK;AACzB"}
1
+ {"version":3,"file":"tool.cjs","names":["x: unknown","BaseMessage","fields:\n | $InferMessageContent<TStructure, \"tool\">\n | ToolMessageFields<TStructure>","tool_call_id?: string","name?: string","toolMessageFields: ToolMessageFields<TStructure>","message: BaseMessage<T> | unknown","BaseMessageChunk","fields: ToolMessageFields<TStructure>","chunk: ToolMessageChunk<TStructure>","mergeContent","_mergeDicts","_mergeObj","_mergeStatus","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 metadata?: Record<string, unknown>;\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 metadata?: Record<string, unknown>;\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 ? ({\n content: fields,\n name,\n tool_call_id: tool_call_id!,\n } as ToolMessageFields<TStructure>)\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 this.metadata = toolMessageFields.metadata;\n }\n\n /**\n * Type guard to check if an object is a ToolMessage.\n * Preserves the MessageStructure type parameter when called with a typed BaseMessage.\n * @overload When called with a typed BaseMessage, preserves the TStructure type\n */\n static isInstance<T extends MessageStructure>(\n message: BaseMessage<T>\n ): message is ToolMessage<T>;\n /**\n * Type guard to check if an object is a ToolMessage.\n * @overload When called with unknown, returns base ToolMessage type\n */\n static isInstance(message: unknown): message is ToolMessage;\n static isInstance<T extends MessageStructure = MessageStructure>(\n message: BaseMessage<T> | unknown\n ): message is ToolMessage<T> {\n return (\n super.isInstance(message) && (message as { type: string }).type === \"tool\"\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 * 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs extends Record<string, any> = Record<string, any>\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":";;;;;;;;;;;;;AAwCA,SAAgB,mBAAmBA,GAAmC;AACpE,QACE,KAAK,QACL,OAAO,MAAM,YACb,2BAA2B,KAC3B,EAAE,0BAA0B;AAE/B;;;;AAKD,IAAa,cAAb,cACUC,yBAEV;CACE,OAAO,UAAU;AACf,SAAO;CACR;CAED,IAAI,aAAqC;AAEvC,SAAO,EAAE,cAAc,eAAgB;CACxC;CAED,wBAAwB;CAExB,AAAS,OAAO;;;;;CAMhB;CAEA;CAEA;;;;;;;;CAUA;CAUA,YACEC,QAGAC,cACAC,MACA;EACA,MAAMC,oBACJ,OAAO,WAAW,YAAY,MAAM,QAAQ,OAAO,GAC9C;GACC,SAAS;GACT;GACc;EACf,IACD;EACN,MAAM,kBAAkB;EACxB,KAAK,eAAe,kBAAkB;EACtC,KAAK,WAAW,kBAAkB;EAClC,KAAK,SAAS,kBAAkB;EAChC,KAAK,WAAW,kBAAkB;CACnC;CAeD,OAAO,WACLC,SAC2B;AAC3B,SACE,MAAM,WAAW,QAAQ,IAAK,QAA6B,SAAS;CAEvE;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;;;;;AAMD,IAAa,mBAAb,cAEUC,8BAAqC;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,SAASC,0BAAa,KAAK,SAAS,MAAM,QAAQ;GAClD,mBAAmBC,yBACjB,KAAK,mBACL,MAAM,kBACP;GACD,mBAAmBA,yBACjB,KAAK,mBACL,MAAM,kBACP;GACD,UAAUC,uBAAU,KAAK,UAAU,MAAM,SAAS;GAClD,cAAc,KAAK;GACnB,IAAI,KAAK,MAAM,MAAM;GACrB,QAAQC,0BAAa,KAAK,QAAQ,MAAM,OAAO;EAChD;CACF;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;AAgHD,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,cAAchB,GAA8B;AAC1D,QACE,OAAO,MAAM,YACb,MAAM,QACN,aAAa,KACb,OAAO,EAAE,YAAY,cACrB,EAAE,SAAS,KAAK;AAEnB;;;;AAKD,SAAgB,mBAAmBiB,GAA4C;AAC7E,QAAO,EAAE,UAAU,KAAK;AACzB"}
@@ -51,6 +51,16 @@ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure
51
51
  artifact?: any;
52
52
  constructor(fields: $InferMessageContent<TStructure, "tool"> | ToolMessageFields, tool_call_id: string, name?: string);
53
53
  constructor(fields: ToolMessageFields<TStructure>);
54
+ /**
55
+ * Type guard to check if an object is a ToolMessage.
56
+ * Preserves the MessageStructure type parameter when called with a typed BaseMessage.
57
+ * @overload When called with a typed BaseMessage, preserves the TStructure type
58
+ */
59
+ static isInstance<T extends MessageStructure>(message: BaseMessage<T>): message is ToolMessage<T>;
60
+ /**
61
+ * Type guard to check if an object is a ToolMessage.
62
+ * @overload When called with unknown, returns base ToolMessage type
63
+ */
54
64
  static isInstance(message: unknown): message is ToolMessage;
55
65
  get _printableFields(): Record<string, unknown>;
56
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.cts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","Record","DirectToolOutput","isDirectToolOutput","ToolMessage","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n metadata?: Record<string, unknown>;\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n metadata?: Record<string, unknown>;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {\n readonly type?: \"tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n}\n/**\n * A chunk of a tool call (e.g., as part of a stream).\n * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\n * all string attributes are concatenated. Chunks are only merged if their\n * values of `index` are equal and not None.\n *\n * @example\n * ```ts\n * const leftChunks = [\n * {\n * name: \"foo\",\n * args: '{\"a\":',\n * index: 0\n * }\n * ];\n *\n * const leftAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: leftChunks\n * });\n *\n * const rightChunks = [\n * {\n * name: undefined,\n * args: '1}',\n * index: 0\n * }\n * ];\n *\n * const rightAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: rightChunks\n * });\n *\n * const result = leftAIMessageChunk.concat(rightAIMessageChunk);\n * // result.tool_call_chunks is equal to:\n * // [\n * // {\n * // name: \"foo\",\n * // args: '{\"a\":1}'\n * // index: 0\n * // }\n * // ]\n * ```\n */\nexport interface ToolCallChunk<TName extends string = string> {\n readonly type?: \"tool_call_chunk\";\n /**\n * If provided, a substring of an identifier for the tool call\n */\n id?: string;\n /**\n * If provided, a substring of the name of the tool to be called\n */\n name?: TName;\n /**\n * If provided, a JSON substring of the arguments to the tool call\n */\n args?: string;\n /**\n * If provided, the index of the tool call in a sequence\n */\n index?: number;\n}\nexport interface InvalidToolCall<TName extends string = string> {\n readonly type?: \"invalid_tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n}\nexport declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n//# sourceMappingURL=tool.d.ts.map"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH,QAAA,CAAA,EAAA,GAAA;EAoBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAA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AlIpFT,MAkIoF,CAAA,MAAA,EAAA,OAAA,CAAA;AAIhH;AAIA;;;;cApIqBI,oCAAoCP,mBAAmBA,0BAA0BH,iBAAiBK;;;;;;;;;;;;;;;;sBAgB/FD,kBAAkBC;;gBAExBK,iBAAiBL;0BACPC;;UAEXK,sDAAsDL,sBAAsBA;;;;;;;;;QASnFM;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA,eAAoCV,yBAAyBK,YAAYI;;;;iBAIzEE,aAAAA,mBAAgCR;;;;iBAIhCS,kBAAAA,IAAsBlB,wBAAwBU"}
1
+ {"version":3,"file":"tool.d.cts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","Record","DirectToolOutput","isDirectToolOutput","ToolMessage","T","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n metadata?: Record<string, unknown>;\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n metadata?: Record<string, unknown>;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n /**\n * Type guard to check if an object is a ToolMessage.\n * Preserves the MessageStructure type parameter when called with a typed BaseMessage.\n * @overload When called with a typed BaseMessage, preserves the TStructure type\n */\n static isInstance<T extends MessageStructure>(message: BaseMessage<T>): message is ToolMessage<T>;\n /**\n * Type guard to check if an object is a ToolMessage.\n * @overload When called with unknown, returns base ToolMessage type\n */\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {\n readonly type?: \"tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n}\n/**\n * A chunk of a tool call (e.g., as part of a stream).\n * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\n * all string attributes are concatenated. Chunks are only merged if their\n * values of `index` are equal and not None.\n *\n * @example\n * ```ts\n * const leftChunks = [\n * {\n * name: \"foo\",\n * args: '{\"a\":',\n * index: 0\n * }\n * ];\n *\n * const leftAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: leftChunks\n * });\n *\n * const rightChunks = [\n * {\n * name: undefined,\n * args: '1}',\n * index: 0\n * }\n * ];\n *\n * const rightAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: rightChunks\n * });\n *\n * const result = leftAIMessageChunk.concat(rightAIMessageChunk);\n * // result.tool_call_chunks is equal to:\n * // [\n * // {\n * // name: \"foo\",\n * // args: '{\"a\":1}'\n * // index: 0\n * // }\n * // ]\n * ```\n */\nexport interface ToolCallChunk<TName extends string = string> {\n readonly type?: \"tool_call_chunk\";\n /**\n * If provided, a substring of an identifier for the tool call\n */\n id?: string;\n /**\n * If provided, a substring of the name of the tool to be called\n */\n name?: TName;\n /**\n * If provided, a JSON substring of the arguments to the tool call\n */\n args?: string;\n /**\n * If provided, the index of the tool call in a sequence\n */\n index?: number;\n}\nexport interface InvalidToolCall<TName extends string = string> {\n readonly type?: \"invalid_tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n}\nexport declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n//# sourceMappingURL=tool.d.ts.map"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH,QAAA,CAAA,EAAA,GAAA;EAoBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAAA,EAhBNH,MAgBiB,CAAA,MAAAD,EAAAA,OAAAA,CAAAA;;;;;;;;;AAqBUA,UA5BzBE,gBAAAA,CA4ByBF;EAAlBD,SAAAA,qBAAAA,EAAAA,IAAAA;;AAM+CM,iBA/B/CF,kBAAAA,CA+B+CE,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA/BVH,gBA+BUG;;;;AAKnBD,cAhC/BA,WAgC+BA,CAAAA,mBAhCAN,gBAgCAM,GAhCmBN,gBAgCnBM,CAAAA,SAhC6CV,WAgC7CU,CAhCyDJ,UAgCzDI,EAAAA,MAAAA,CAAAA,YAhCwFF,gBAgCxFE,CAAAA;EACxBH,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAjCqEP,IAAAA,UAAAA,CAAAA,CAAAA,EAE3EO,MAF2EP,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAA2CQ,qBAAAA,EAAAA,IAAAA;EAAgB,SAAA,IAAA,EAAA,MAAA;EAuCvII;;;;EAgBqBN,MAAAA,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAlBD,YAAAA,EAAAA,MAAAA;EAEWC,QAAAA,CAAAA,EA9CpBC,MA8CoBD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAAjBM;;;AAlBoG;AAqBtH;;;EASUE,QAAAA,CAAAA,EAAAA,GAAAA;EAIAC,WAAAA,CAAAA,MAAAA,EArDcZ,oBAqDdY,CArDmCT,UAqDnCS,EAAAA,MAAAA,CAAAA,GArDyDV,iBAqDzDU,EAAAA,YAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA;EAAK,WAAA,CAAA,MAAA,EApDSV,iBAoDT,CApD2BC,UAoD3B,CAAA;EA+CEU;AAmBjB;AAwBA;;;EAAiGC,OAAAA,UAAAA,CAAAA,UAxIjEb,gBAwIiEa,CAAAA,CAAAA,OAAAA,EAxItCjB,WAwIsCiB,CAxI1BN,CAwI0BM,CAAAA,CAAAA,EAAAA,OAAAA,IAxIVP,WAwIUO,CAxIEN,CAwIFM,CAAAA;EAAe;AAIhH;AAIA;;kDA3IoDP;0BACxBH;;;;;;cAMPK,oCAAoCR,mBAAmBA,0BAA0BH,iBAAiBK;;;;;;;;;;;;;;;;sBAgB/FD,kBAAkBC;;gBAExBM,iBAAiBN;0BACPC;;UAEXM,sDAAsDN,sBAAsBA;;;;;;;;;QASnFO;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA,eAAoCX,yBAAyBM,YAAYI;;;;iBAIzEE,aAAAA,mBAAgCT;;;;iBAIhCU,kBAAAA,IAAsBnB,wBAAwBW"}
@@ -51,6 +51,16 @@ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure
51
51
  artifact?: any;
52
52
  constructor(fields: $InferMessageContent<TStructure, "tool"> | ToolMessageFields, tool_call_id: string, name?: string);
53
53
  constructor(fields: ToolMessageFields<TStructure>);
54
+ /**
55
+ * Type guard to check if an object is a ToolMessage.
56
+ * Preserves the MessageStructure type parameter when called with a typed BaseMessage.
57
+ * @overload When called with a typed BaseMessage, preserves the TStructure type
58
+ */
59
+ static isInstance<T extends MessageStructure>(message: BaseMessage<T>): message is ToolMessage<T>;
60
+ /**
61
+ * Type guard to check if an object is a ToolMessage.
62
+ * @overload When called with unknown, returns base ToolMessage type
63
+ */
54
64
  static isInstance(message: unknown): message is ToolMessage;
55
65
  get _printableFields(): Record<string, unknown>;
56
66
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","Record","DirectToolOutput","isDirectToolOutput","ToolMessage","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n metadata?: Record<string, unknown>;\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n metadata?: Record<string, unknown>;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {\n readonly type?: \"tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n}\n/**\n * A chunk of a tool call (e.g., as part of a stream).\n * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\n * all string attributes are concatenated. Chunks are only merged if their\n * values of `index` are equal and not None.\n *\n * @example\n * ```ts\n * const leftChunks = [\n * {\n * name: \"foo\",\n * args: '{\"a\":',\n * index: 0\n * }\n * ];\n *\n * const leftAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: leftChunks\n * });\n *\n * const rightChunks = [\n * {\n * name: undefined,\n * args: '1}',\n * index: 0\n * }\n * ];\n *\n * const rightAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: rightChunks\n * });\n *\n * const result = leftAIMessageChunk.concat(rightAIMessageChunk);\n * // result.tool_call_chunks is equal to:\n * // [\n * // {\n * // name: \"foo\",\n * // args: '{\"a\":1}'\n * // index: 0\n * // }\n * // ]\n * ```\n */\nexport interface ToolCallChunk<TName extends string = string> {\n readonly type?: \"tool_call_chunk\";\n /**\n * If provided, a substring of an identifier for the tool call\n */\n id?: string;\n /**\n * If provided, a substring of the name of the tool to be called\n */\n name?: TName;\n /**\n * If provided, a JSON substring of the arguments to the tool call\n */\n args?: string;\n /**\n * If provided, the index of the tool call in a sequence\n */\n index?: number;\n}\nexport interface InvalidToolCall<TName extends string = string> {\n readonly type?: \"invalid_tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n}\nexport declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n//# sourceMappingURL=tool.d.ts.map"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH,QAAA,CAAA,EAAA,GAAA;EAoBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAAA,EAhBNH,MAgBiB,CA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,MAAA,EAAA,OAAA,CAAA;AAIhH;AAIA;;;;cApIqBI,oCAAoCP,mBAAmBA,0BAA0BH,iBAAiBK;;;;;;;;;;;;;;;;sBAgB/FD,kBAAkBC;;gBAExBK,iBAAiBL;0BACPC;;UAEXK,sDAAsDL,sBAAsBA;;;;;;;;;QASnFM;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA,eAAoCV,yBAAyBK,YAAYI;;;;iBAIzEE,aAAAA,mBAAgCR;;;;iBAIhCS,kBAAAA,IAAsBlB,wBAAwBU"}
1
+ {"version":3,"file":"tool.d.ts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","Record","DirectToolOutput","isDirectToolOutput","ToolMessage","T","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n metadata?: Record<string, unknown>;\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n metadata?: Record<string, unknown>;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n /**\n * Type guard to check if an object is a ToolMessage.\n * Preserves the MessageStructure type parameter when called with a typed BaseMessage.\n * @overload When called with a typed BaseMessage, preserves the TStructure type\n */\n static isInstance<T extends MessageStructure>(message: BaseMessage<T>): message is ToolMessage<T>;\n /**\n * Type guard to check if an object is a ToolMessage.\n * @overload When called with unknown, returns base ToolMessage type\n */\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, TArgs extends Record<string, any> = Record<string, any>> {\n readonly type?: \"tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n}\n/**\n * A chunk of a tool call (e.g., as part of a stream).\n * When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),\n * all string attributes are concatenated. Chunks are only merged if their\n * values of `index` are equal and not None.\n *\n * @example\n * ```ts\n * const leftChunks = [\n * {\n * name: \"foo\",\n * args: '{\"a\":',\n * index: 0\n * }\n * ];\n *\n * const leftAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: leftChunks\n * });\n *\n * const rightChunks = [\n * {\n * name: undefined,\n * args: '1}',\n * index: 0\n * }\n * ];\n *\n * const rightAIMessageChunk = new AIMessageChunk({\n * content: \"\",\n * tool_call_chunks: rightChunks\n * });\n *\n * const result = leftAIMessageChunk.concat(rightAIMessageChunk);\n * // result.tool_call_chunks is equal to:\n * // [\n * // {\n * // name: \"foo\",\n * // args: '{\"a\":1}'\n * // index: 0\n * // }\n * // ]\n * ```\n */\nexport interface ToolCallChunk<TName extends string = string> {\n readonly type?: \"tool_call_chunk\";\n /**\n * If provided, a substring of an identifier for the tool call\n */\n id?: string;\n /**\n * If provided, a substring of the name of the tool to be called\n */\n name?: TName;\n /**\n * If provided, a JSON substring of the arguments to the tool call\n */\n args?: string;\n /**\n * If provided, the index of the tool call in a sequence\n */\n index?: number;\n}\nexport interface InvalidToolCall<TName extends string = string> {\n readonly type?: \"invalid_tool_call\";\n /**\n * If provided, an identifier associated with the tool call\n */\n id?: string;\n /**\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n}\nexport declare function defaultToolCallParser(rawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n//# sourceMappingURL=tool.d.ts.map"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH,QAAA,CAAA,EAAA,GAAA;EAoBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAAA,EAhBNH,MAgBiB,CAAA,MAAAD,EAAAA,OAAAA,CAAAA;;;;;;;;;AAqBUA,UA5BzBE,gBAAAA,CA4ByBF;EAAlBD,SAAAA,qBAAAA,EAAAA,IAAAA;;AAM+CM,iBA/B/CF,kBAAAA,CA+B+CE,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA/BVH,gBA+BUG;;;;AAKnBD,cAhC/BA,WAgC+BA,CAAAA,mBAhCAN,gBAgCAM,GAhCmBN,gBAgCnBM,CAAAA,SAhC6CV,WAgC7CU,CAhCyDJ,UAgCzDI,EAAAA,MAAAA,CAAAA,YAhCwFF,gBAgCxFE,CAAAA;EACxBH,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAjCqEP,IAAAA,UAAAA,CAAAA,CAAAA,EAE3EO,MAF2EP,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAA2CQ,qBAAAA,EAAAA,IAAAA;EAAgB,SAAA,IAAA,EAAA,MAAA;EAuCvII;;;;EAgBqBN,MAAAA,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAlBD,YAAAA,EAAAA,MAAAA;EAEWC,QAAAA,CAAAA,EA9CpBC,MA8CoBD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAAjBM;;;AAlBoG;AAqBtH;;;EASUE,QAAAA,CAAAA,EAAAA,GAAAA;EAIAC,WAAAA,CAAAA,MAAAA,EArDcZ,oBAqDdY,CArDmCT,UAqDnCS,EAAAA,MAAAA,CAAAA,GArDyDV,iBAqDzDU,EAAAA,YAAAA,EAAAA,MAAAA,EAAAA,IAAAA,CAAAA,EAAAA,MAAAA;EAAK,WAAA,CAAA,MAAA,EApDSV,iBAoDT,CApD2BC,UAoD3B,CAAA;EA+CEU;AAmBjB;AAwBA;;;EAAiGC,OAAAA,UAAAA,CAAAA,UAxIjEb,gBAwIiEa,CAAAA,CAAAA,OAAAA,EAxItCjB,WAwIsCiB,CAxI1BN,CAwI0BM,CAAAA,CAAAA,EAAAA,OAAAA,IAxIVP,WAwIUO,CAxIEN,CAwIFM,CAAAA;EAAe;AAIhH;AAIA;;kDA3IoDP;0BACxBH;;;;;;cAMPK,oCAAoCR,mBAAmBA,0BAA0BH,iBAAiBK;;;;;;;;;;;;;;;;sBAgB/FD,kBAAkBC;;gBAExBM,iBAAiBN;0BACPC;;UAEXM,sDAAsDN,sBAAsBA;;;;;;;;;QASnFO;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA,eAAoCX,yBAAyBM,YAAYI;;;;iBAIzEE,aAAAA,mBAAgCT;;;;iBAIhCU,kBAAAA,IAAsBnB,wBAAwBW"}
@@ -1 +1 @@
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 metadata?: Record<string, unknown>;\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 metadata?: Record<string, unknown>;\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 this.metadata = toolMessageFields.metadata;\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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs extends Record<string, any> = Record<string, any>\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":";;;;;;;;;;;;;AAwCA,SAAgB,mBAAmBA,GAAmC;AACpE,QACE,KAAK,QACL,OAAO,MAAM,YACb,2BAA2B,KAC3B,EAAE,0BAA0B;AAE/B;;;;AAKD,IAAa,cAAb,cACU,YAEV;CACE,OAAO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Ac,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;AAgHD,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"}
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: BaseMessage<T> | 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 metadata?: Record<string, unknown>;\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 metadata?: Record<string, unknown>;\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 ? ({\n content: fields,\n name,\n tool_call_id: tool_call_id!,\n } as ToolMessageFields<TStructure>)\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 this.metadata = toolMessageFields.metadata;\n }\n\n /**\n * Type guard to check if an object is a ToolMessage.\n * Preserves the MessageStructure type parameter when called with a typed BaseMessage.\n * @overload When called with a typed BaseMessage, preserves the TStructure type\n */\n static isInstance<T extends MessageStructure>(\n message: BaseMessage<T>\n ): message is ToolMessage<T>;\n /**\n * Type guard to check if an object is a ToolMessage.\n * @overload When called with unknown, returns base ToolMessage type\n */\n static isInstance(message: unknown): message is ToolMessage;\n static isInstance<T extends MessageStructure = MessageStructure>(\n message: BaseMessage<T> | unknown\n ): message is ToolMessage<T> {\n return (\n super.isInstance(message) && (message as { type: string }).type === \"tool\"\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 * 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs extends Record<string, any> = Record<string, any>\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":";;;;;;;;;;;;;AAwCA,SAAgB,mBAAmB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M,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;AAgHD,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,7 +5,7 @@ import { ChatMessage, ChatMessageChunk } from "./chat.cjs";
5
5
  import { FunctionMessage, FunctionMessageChunk } from "./function.cjs";
6
6
  import { HumanMessage, HumanMessageChunk } from "./human.cjs";
7
7
  import { SystemMessage, SystemMessageChunk } from "./system.cjs";
8
- import { MessageStructure } from "./message.cjs";
8
+ import { MessageStructure, MessageToolSet } from "./message.cjs";
9
9
 
10
10
  //#region src/messages/utils.d.ts
11
11
  type $Expand<T$1> = T$1 extends infer U ? { [K in keyof U]: U[K] } : never;
@@ -90,7 +90,7 @@ declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseM
90
90
  * of the chat message history, based on the message content and role.
91
91
  */
92
92
  declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;
93
- declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<MessageStructure> | ChatMessage<MessageStructure> | FunctionMessage<MessageStructure> | HumanMessage<MessageStructure> | SystemMessage<MessageStructure> | ToolMessage<MessageStructure>;
93
+ declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<MessageStructure<MessageToolSet>> | ChatMessage<MessageStructure<MessageToolSet>> | FunctionMessage<MessageStructure<MessageToolSet>> | HumanMessage<MessageStructure<MessageToolSet>> | SystemMessage<MessageStructure<MessageToolSet>> | ToolMessage<MessageStructure<MessageToolSet>>;
94
94
  /**
95
95
  * Transforms an array of `StoredMessage` instances into an array of
96
96
  * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`
@@ -107,7 +107,7 @@ declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): Bas
107
107
  * is used to prepare chat messages for storage.
108
108
  */
109
109
  declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];
110
- declare function convertToChunk(message: BaseMessage): AIMessageChunk<MessageStructure> | ChatMessageChunk<MessageStructure> | FunctionMessageChunk<MessageStructure> | HumanMessageChunk<MessageStructure> | SystemMessageChunk<MessageStructure>;
110
+ declare function convertToChunk(message: BaseMessage): AIMessageChunk<MessageStructure<MessageToolSet>> | ChatMessageChunk<MessageStructure<MessageToolSet>> | FunctionMessageChunk<MessageStructure<MessageToolSet>> | HumanMessageChunk<MessageStructure<MessageToolSet>> | SystemMessageChunk<MessageStructure<MessageToolSet>>;
111
111
  /**
112
112
  * Collapses an array of tool call chunks into complete tool calls.
113
113
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.cts","names":["AIMessage","AIMessageChunk","BaseMessageLike","BaseMessage","StoredMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","SystemMessage","SystemMessageChunk","InvalidToolCall","ToolCall","ToolCallChunk","ToolMessage","$Expand","T","U","K","$KnownKeys","$HasIndexSignature","$OnlyIndexSignatures","$MergeObjects","Record","$MergeDiscriminatedUnion","A","B","Key","PropertyKey","Extract","Constructor","iife","coerceMessageLikeToMessage","getBufferString","mapStoredMessageToChatMessage","__message_js0","MessageStructure","mapStoredMessagesToChatMessages","mapChatMessagesToStoredMessages","convertToChunk","collapseToolCallChunks"],"sources":["../../src/messages/utils.d.ts"],"sourcesContent":["import { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessageLike, BaseMessage, StoredMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage } from \"./tool.js\";\nexport type $Expand<T> = T extends infer U ? {\n [K in keyof U]: U[K];\n} : never;\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : symbol extends K ? never : K;\n}[keyof T];\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T ? true : number extends keyof T ? true : symbol extends keyof T ? true : false;\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> = $HasIndexSignature<T> extends true ? [$KnownKeys<T>] extends [never] ? true : false : false;\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> = $OnlyIndexSignatures<U> extends true ? U : $OnlyIndexSignatures<T> extends true ? U : {\n [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] extends Record<string, unknown> ? U[K] extends Record<string, unknown> ? $MergeObjects<T[K], U[K]> : U[K] : U[K] : T[K] : K extends keyof U ? U[K] : never;\n};\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = \"type\"> = {\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [\n Extract<A, Record<Key, T>>\n ] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n}[A[Key] | B[Key]];\nexport type Constructor<T> = new (...args: unknown[]) => T;\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseMessage;\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n */\nexport declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;\nexport declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<import(\"./message.js\").MessageStructure> | ChatMessage<import(\"./message.js\").MessageStructure> | FunctionMessage<import(\"./message.js\").MessageStructure> | HumanMessage<import(\"./message.js\").MessageStructure> | SystemMessage<import(\"./message.js\").MessageStructure> | ToolMessage<import(\"./message.js\").MessageStructure>;\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): BaseMessage[];\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];\nexport declare function convertToChunk(message: BaseMessage): AIMessageChunk<import(\"./message.js\").MessageStructure> | ChatMessageChunk<import(\"./message.js\").MessageStructure> | FunctionMessageChunk<import(\"./message.js\").MessageStructure> | HumanMessageChunk<import(\"./message.js\").MessageStructure> | SystemMessageChunk<import(\"./message.js\").MessageStructure>;\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport declare function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n};\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;KAOYiB,eAAaC,oCACTC,IAAIA,EAAEC;AADtB;;;;;AACuB;AACb,KAOLC,UAAAA,CAAAA,GAAU,CAAA,GAAA,QACCH,MAAAA,GAAAA,GAAAA,MAAAA,SAAmBE,CAAnBF,GAAAA,KAAAA,GAAAA,MAAAA,SAA8CE,CAA9CF,GAAAA,KAAAA,GAAAA,MAAAA,SAAyEE,CAAzEF,GAAAA,KAAAA,GAAqFE,CAArFF,EAAmBE,CAAAA,MAC3BF,GAD2BE,CAAAA;;;;;AAC1B;AAAA;KAOJE,kBAA6CJ,CAAAA,GAAAA,CAAAA,GAAAA,MAAAA,SAAAA,MAAAA,GAAAA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgCA,GAAhCA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgEA,GAAhEA,GAAAA,IAAAA,GAAAA,KAAAA;;;AAAiE;AAAA;;;KAO9GK,oBAA2EL,CAAAA,GAAAA,CAAAA,GAAjDI,kBAAiDJ,CAA9BA,GAA8BA,CAAAA,SAAAA,IAAAA,GAAAA,CAAXG,UAAWH,CAAAA,GAAAA,CAAAA,CAAAA,SAAAA,CAAAA,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EAAAA,MAAAA,CAAAA,EAAAA,MAAAA;AAAKX,iBAgBvBkB,6BAAAA,CAhBuBlB,OAAAA,EAgBgBd,aAhBhBc,CAAAA,EAgBgClB,SAhBhCkB,kBAAAA,GAgBqFb,WAhBrFa,kBAAAA,GAgB4IX,eAhB5IW,kBAAAA,GAgBuMT,YAhBvMS,kBAAAA,GAgB+PP,aAhB/PO,kBAAAA,GAgBwTF,WAhBxTE,kBAAAA;;;;;;;;;AAAkEW,iBAyBzFU,+BAAAA,CAzByFV,QAAAA,EAyB/CzB,aAzB+CyB,EAAAA,CAAAA,EAyB7B1B,WAzB6B0B,EAAAA;;;;;;;AACtGD,iBA+BaY,+BAAAA,CA/BbZ,QAAAA,EA+BuDzB,WA/BvDyB,EAAAA,CAAAA,EA+BuExB,aA/BvEwB,EAAAA;AAAEC,iBAgCWY,cAAAA,CAhCXZ,OAAAA,EAgCmC1B,WAhCnC0B,CAAAA,EAgCiD5B,cAhCjD4B,kBAAAA,GAgC2GvB,gBAhC3GuB,kBAAAA,GAgCuKrB,oBAhCvKqB,kBAAAA,GAgCuOnB,iBAhCvOmB,kBAAAA,GAgCoSjB,kBAhCpSiB,kBAAAA;AAAG;AAChB;AAOA;AACA;AAKA;AACA;;;;;;;;;;;;;;AAAkX;AASlX;AAOA;AACA;;;;iBA2BwBa,sBAAAA,SAA+B3B;EA3BiET,gBAAAA,EA4BlGS,aA5BkGT,EAAAA;cA6BxGQ;EA7BoKN,kBAAAA,EA8B5JK,eA9B4JL,EAAAA"}
1
+ {"version":3,"file":"utils.d.cts","names":["AIMessage","AIMessageChunk","BaseMessageLike","BaseMessage","StoredMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","SystemMessage","SystemMessageChunk","InvalidToolCall","ToolCall","ToolCallChunk","ToolMessage","$Expand","T","U","K","$KnownKeys","$HasIndexSignature","$OnlyIndexSignatures","$MergeObjects","Record","$MergeDiscriminatedUnion","A","B","Key","PropertyKey","Extract","Constructor","iife","coerceMessageLikeToMessage","getBufferString","mapStoredMessageToChatMessage","__message_js0","MessageToolSet","MessageStructure","mapStoredMessagesToChatMessages","mapChatMessagesToStoredMessages","convertToChunk","collapseToolCallChunks"],"sources":["../../src/messages/utils.d.ts"],"sourcesContent":["import { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessageLike, BaseMessage, StoredMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage } from \"./tool.js\";\nexport type $Expand<T> = T extends infer U ? {\n [K in keyof U]: U[K];\n} : never;\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : symbol extends K ? never : K;\n}[keyof T];\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T ? true : number extends keyof T ? true : symbol extends keyof T ? true : false;\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> = $HasIndexSignature<T> extends true ? [$KnownKeys<T>] extends [never] ? true : false : false;\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> = $OnlyIndexSignatures<U> extends true ? U : $OnlyIndexSignatures<T> extends true ? U : {\n [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] extends Record<string, unknown> ? U[K] extends Record<string, unknown> ? $MergeObjects<T[K], U[K]> : U[K] : U[K] : T[K] : K extends keyof U ? U[K] : never;\n};\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = \"type\"> = {\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [\n Extract<A, Record<Key, T>>\n ] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n}[A[Key] | B[Key]];\nexport type Constructor<T> = new (...args: unknown[]) => T;\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseMessage;\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n */\nexport declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;\nexport declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ChatMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | FunctionMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | HumanMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | SystemMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ToolMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>>;\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): BaseMessage[];\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];\nexport declare function convertToChunk(message: BaseMessage): AIMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ChatMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | FunctionMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | HumanMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | SystemMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>>;\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport declare function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n};\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;KAOYiB,eAAaC,oCACTC,IAAIA,EAAEC;AADtB;;;;;AACuB;AACb,KAOLC,UAAAA,CAAAA,GAAU,CAAA,GAAA,QACCH,MAAAA,GAAAA,GAAAA,MAAAA,SAAmBE,CAAnBF,GAAAA,KAAAA,GAAAA,MAAAA,SAA8CE,CAA9CF,GAAAA,KAAAA,GAAAA,MAAAA,SAAyEE,CAAzEF,GAAAA,KAAAA,GAAqFE,CAArFF,EAAmBE,CAAAA,MAC3BF,GAD2BE,CAAAA;;;;;AAC1B;AAAA;KAOJE,kBAA6CJ,CAAAA,GAAAA,CAAAA,GAAAA,MAAAA,SAAAA,MAAAA,GAAAA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgCA,GAAhCA,GAAAA,IAAAA,GAAAA,MAAAA,SAAAA,MAAgEA,GAAhEA,GAAAA,IAAAA,GAAAA,KAAAA;;;AAAiE;AAAA;;;KAO9GK,oBAA2EL,CAAAA,GAAAA,CAAAA,GAAjDI,kB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,QA7BsB,EAAA;EAAUX,kBAAAA,EA8BxBU,eA9BwBV,EAAAA"}
@@ -5,7 +5,7 @@ import { ChatMessage, ChatMessageChunk } from "./chat.js";
5
5
  import { FunctionMessage, FunctionMessageChunk } from "./function.js";
6
6
  import { HumanMessage, HumanMessageChunk } from "./human.js";
7
7
  import { SystemMessage, SystemMessageChunk } from "./system.js";
8
- import { MessageStructure } from "./message.js";
8
+ import { MessageStructure, MessageToolSet } from "./message.js";
9
9
 
10
10
  //#region src/messages/utils.d.ts
11
11
  type $Expand<T$1> = T$1 extends infer U ? { [K in keyof U]: U[K] } : never;
@@ -90,7 +90,7 @@ declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseM
90
90
  * of the chat message history, based on the message content and role.
91
91
  */
92
92
  declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;
93
- declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<MessageStructure> | ChatMessage<MessageStructure> | FunctionMessage<MessageStructure> | HumanMessage<MessageStructure> | SystemMessage<MessageStructure> | ToolMessage<MessageStructure>;
93
+ declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<MessageStructure<MessageToolSet>> | ChatMessage<MessageStructure<MessageToolSet>> | FunctionMessage<MessageStructure<MessageToolSet>> | HumanMessage<MessageStructure<MessageToolSet>> | SystemMessage<MessageStructure<MessageToolSet>> | ToolMessage<MessageStructure<MessageToolSet>>;
94
94
  /**
95
95
  * Transforms an array of `StoredMessage` instances into an array of
96
96
  * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`
@@ -107,7 +107,7 @@ declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): Bas
107
107
  * is used to prepare chat messages for storage.
108
108
  */
109
109
  declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];
110
- declare function convertToChunk(message: BaseMessage): AIMessageChunk<MessageStructure> | ChatMessageChunk<MessageStructure> | FunctionMessageChunk<MessageStructure> | HumanMessageChunk<MessageStructure> | SystemMessageChunk<MessageStructure>;
110
+ declare function convertToChunk(message: BaseMessage): AIMessageChunk<MessageStructure<MessageToolSet>> | ChatMessageChunk<MessageStructure<MessageToolSet>> | FunctionMessageChunk<MessageStructure<MessageToolSet>> | HumanMessageChunk<MessageStructure<MessageToolSet>> | SystemMessageChunk<MessageStructure<MessageToolSet>>;
111
111
  /**
112
112
  * Collapses an array of tool call chunks into complete tool calls.
113
113
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","names":["AIMessage","AIMessageChunk","BaseMessageLike","BaseMessage","StoredMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","SystemMessage","SystemMessageChunk","InvalidToolCall","ToolCall","ToolCallChunk","ToolMessage","$Expand","T","U","K","$KnownKeys","$HasIndexSignature","$OnlyIndexSignatures","$MergeObjects","Record","$MergeDiscriminatedUnion","A","B","Key","PropertyKey","Extract","Constructor","iife","coerceMessageLikeToMessage","getBufferString","mapStoredMessageToChatMessage","__message_js0","MessageStructure","mapStoredMessagesToChatMessages","mapChatMessagesToStoredMessages","convertToChunk","collapseToolCallChunks"],"sources":["../../src/messages/utils.d.ts"],"sourcesContent":["import { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessageLike, BaseMessage, StoredMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage } from \"./tool.js\";\nexport type $Expand<T> = T extends infer U ? {\n [K in keyof U]: U[K];\n} : never;\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : symbol extends K ? never : K;\n}[keyof T];\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T ? true : number extends keyof T ? true : symbol extends keyof T ? true : false;\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> = $HasIndexSignature<T> extends true ? [$KnownKeys<T>] extends [never] ? true : false : false;\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> = $OnlyIndexSignatures<U> extends true ? U : $OnlyIndexSignatures<T> extends true ? U : {\n [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] extends Record<string, unknown> ? U[K] extends Record<string, unknown> ? $MergeObjects<T[K], U[K]> : U[K] : U[K] : T[K] : K extends keyof U ? U[K] : never;\n};\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = \"type\"> = {\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [\n Extract<A, Record<Key, T>>\n ] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n}[A[Key] | B[Key]];\nexport type Constructor<T> = new (...args: unknown[]) => T;\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseMessage;\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n */\nexport declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;\nexport declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<import(\"./message.js\").MessageStructure> | ChatMessage<import(\"./message.js\").MessageStructure> | FunctionMessage<import(\"./message.js\").MessageStructure> | HumanMessage<import(\"./message.js\").MessageStructure> | SystemMessage<import(\"./message.js\").MessageStructure> | ToolMessage<import(\"./message.js\").MessageStructure>;\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): BaseMessage[];\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];\nexport declare function convertToChunk(message: BaseMessage): AIMessageChunk<import(\"./message.js\").MessageStructure> | ChatMessageChunk<import(\"./message.js\").MessageStructure> | FunctionMessageChunk<import(\"./message.js\").MessageStructure> | HumanMessageChunk<import(\"./message.js\").MessageStructure> | SystemMessageChunk<import(\"./message.js\").MessageStructure>;\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport declare function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n};\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;KAOYiB,eAAaC,oCACTC,IAAIA,EAAEC;AADtB;;;;;AACuB;AACb,KAOLC,UAAAA,CAAAA,GAAU,CAAA,GAAA,QACCH,MAAAA,GAAAA,GAAAA,MAAAA,SAAmBE,CAAnBF,GAAAA,KAAAA,GAAAA,MAAAA,SAA8CE,CAA9CF,GAAAA,KAAAA,GAAAA,MAAAA,SAAyEE,CAAzEF,GAAAA,KAAAA,GAAqFE,CAArFF,EAAmBE,CAAAA,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;AACA;;;;iBA2BwBa,sBAAAA,SAA+B3B;EA3BiET,gBAAAA,EA4BlGS,aA5BkGT,EAAAA;cA6BxGQ;EA7BoKN,kBAAAA,EA8B5JK,eA9B4JL,EAAAA"}
1
+ {"version":3,"file":"utils.d.ts","names":["AIMessage","AIMessageChunk","BaseMessageLike","BaseMessage","StoredMessage","ChatMessage","ChatMessageChunk","FunctionMessage","FunctionMessageChunk","HumanMessage","HumanMessageChunk","SystemMessage","SystemMessageChunk","InvalidToolCall","ToolCall","ToolCallChunk","ToolMessage","$Expand","T","U","K","$KnownKeys","$HasIndexSignature","$OnlyIndexSignatures","$MergeObjects","Record","$MergeDiscriminatedUnion","A","B","Key","PropertyKey","Extract","Constructor","iife","coerceMessageLikeToMessage","getBufferString","mapStoredMessageToChatMessage","__message_js0","MessageToolSet","MessageStructure","mapStoredMessagesToChatMessages","mapChatMessagesToStoredMessages","convertToChunk","collapseToolCallChunks"],"sources":["../../src/messages/utils.d.ts"],"sourcesContent":["import { AIMessage, AIMessageChunk } from \"./ai.js\";\nimport { BaseMessageLike, BaseMessage, StoredMessage } from \"./base.js\";\nimport { ChatMessage, ChatMessageChunk } from \"./chat.js\";\nimport { FunctionMessage, FunctionMessageChunk } from \"./function.js\";\nimport { HumanMessage, HumanMessageChunk } from \"./human.js\";\nimport { SystemMessage, SystemMessageChunk } from \"./system.js\";\nimport { InvalidToolCall, ToolCall, ToolCallChunk, ToolMessage } from \"./tool.js\";\nexport type $Expand<T> = T extends infer U ? {\n [K in keyof U]: U[K];\n} : never;\n/**\n * Extracts the explicitly declared keys from a type T.\n *\n * @template T - The type to extract keys from\n * @returns A union of keys that are not string, number, or symbol\n */\ntype $KnownKeys<T> = {\n [K in keyof T]: string extends K ? never : number extends K ? never : symbol extends K ? never : K;\n}[keyof T];\n/**\n * Detects if T has an index signature.\n *\n * @template T - The type to check for index signatures\n * @returns True if T has an index signature, false otherwise\n */\ntype $HasIndexSignature<T> = string extends keyof T ? true : number extends keyof T ? true : symbol extends keyof T ? true : false;\n/**\n * Detects if T has an index signature and no known keys.\n *\n * @template T - The type to check for index signatures and no known keys\n * @returns True if T has an index signature and no known keys, false otherwise\n */\ntype $OnlyIndexSignatures<T> = $HasIndexSignature<T> extends true ? [$KnownKeys<T>] extends [never] ? true : false : false;\n/**\n * Recursively merges two object types T and U, with U taking precedence over T.\n *\n * This utility type performs a deep merge of two object types:\n * - For keys that exist in both T and U:\n * - If both values are objects (Record<string, unknown>), recursively merge them\n * - Otherwise, U's value takes precedence\n * - For keys that exist only in T, use T's value\n * - For keys that exist only in U, use U's value\n *\n * @template T - The first object type to merge\n * @template U - The second object type to merge (takes precedence over T)\n *\n * @example\n * ```ts\n * type ObjectA = {\n * shared: { a: string; b: number };\n * onlyInA: boolean;\n * };\n *\n * type ObjectB = {\n * shared: { b: string; c: Date };\n * onlyInB: symbol;\n * };\n *\n * type Merged = $MergeObjects<ObjectA, ObjectB>;\n * // Result: {\n * // shared: { a: string; b: string; c: Date };\n * // onlyInA: boolean;\n * // onlyInB: symbol;\n * // }\n * ```\n */\nexport type $MergeObjects<T, U> = $OnlyIndexSignatures<U> extends true ? U : $OnlyIndexSignatures<T> extends true ? U : {\n [K in keyof T | keyof U]: K extends keyof T ? K extends keyof U ? T[K] extends Record<string, unknown> ? U[K] extends Record<string, unknown> ? $MergeObjects<T[K], U[K]> : U[K] : U[K] : T[K] : K extends keyof U ? U[K] : never;\n};\n/**\n * Merges two discriminated unions A and B based on a discriminator key (defaults to \"type\").\n * For each possible value of the discriminator across both unions:\n * - If B has a member with that discriminator value, use B's member\n * - Otherwise use A's member with that discriminator value\n * This effectively merges the unions while giving B's members precedence over A's members.\n *\n * @template A - First discriminated union type that extends Record<Key, PropertyKey>\n * @template B - Second discriminated union type that extends Record<Key, PropertyKey>\n * @template Key - The discriminator key property, defaults to \"type\"\n */\nexport type $MergeDiscriminatedUnion<A extends Record<Key, PropertyKey>, B extends Record<Key, PropertyKey>, Key extends PropertyKey = \"type\"> = {\n [T in A[Key] | B[Key]]: [Extract<B, Record<Key, T>>] extends [never] ? Extract<A, Record<Key, T>> : [\n Extract<A, Record<Key, T>>\n ] extends [never] ? Extract<B, Record<Key, T>> : $MergeObjects<Extract<A, Record<Key, T>>, Extract<B, Record<Key, T>>>;\n}[A[Key] | B[Key]];\nexport type Constructor<T> = new (...args: unknown[]) => T;\n/**\n * Immediately-invoked function expression.\n *\n * @param fn - The function to execute\n * @returns The result of the function\n */\nexport declare const iife: <T>(fn: () => T) => T;\nexport declare function coerceMessageLikeToMessage(messageLike: BaseMessageLike): BaseMessage;\n/**\n * This function is used by memory classes to get a string representation\n * of the chat message history, based on the message content and role.\n */\nexport declare function getBufferString(messages: BaseMessage[], humanPrefix?: string, aiPrefix?: string): string;\nexport declare function mapStoredMessageToChatMessage(message: StoredMessage): AIMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ChatMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | FunctionMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | HumanMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | SystemMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ToolMessage<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>>;\n/**\n * Transforms an array of `StoredMessage` instances into an array of\n * `BaseMessage` instances. It uses the `mapV1MessageToStoredMessage`\n * function to ensure all messages are in the `StoredMessage` format, then\n * creates new instances of the appropriate `BaseMessage` subclass based\n * on the type of each message. This function is used to prepare stored\n * messages for use in a chat context.\n */\nexport declare function mapStoredMessagesToChatMessages(messages: StoredMessage[]): BaseMessage[];\n/**\n * Transforms an array of `BaseMessage` instances into an array of\n * `StoredMessage` instances. It does this by calling the `toDict` method\n * on each `BaseMessage`, which returns a `StoredMessage`. This function\n * is used to prepare chat messages for storage.\n */\nexport declare function mapChatMessagesToStoredMessages(messages: BaseMessage[]): StoredMessage[];\nexport declare function convertToChunk(message: BaseMessage): AIMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | ChatMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | FunctionMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | HumanMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>> | SystemMessageChunk<import(\"./message.js\").MessageStructure<import(\"./message.js\").MessageToolSet>>;\n/**\n * Collapses an array of tool call chunks into complete tool calls.\n *\n * This function groups tool call chunks by their id and/or index, then attempts to\n * parse and validate the accumulated arguments for each group. Successfully parsed\n * tool calls are returned as valid `ToolCall` objects, while malformed ones are\n * returned as `InvalidToolCall` objects.\n *\n * @param chunks - An array of `ToolCallChunk` objects to collapse\n * @returns An object containing:\n * - `tool_call_chunks`: The original input chunks\n * - `tool_calls`: An array of successfully parsed and validated tool calls\n * - `invalid_tool_calls`: An array of tool calls that failed parsing or validation\n *\n * @remarks\n * Chunks are grouped using the following matching logic:\n * - If a chunk has both an id and index, it matches chunks with the same id and index\n * - If a chunk has only an id, it matches chunks with the same id\n * - If a chunk has only an index, it matches chunks with the same index\n *\n * For each group, the function:\n * 1. Concatenates all `args` strings from the chunks\n * 2. Attempts to parse the concatenated string as JSON\n * 3. Validates that the result is a non-null object with a valid id\n * 4. Creates either a `ToolCall` (if valid) or `InvalidToolCall` (if invalid)\n */\nexport declare function collapseToolCallChunks(chunks: ToolCallChunk[]): {\n tool_call_chunks: ToolCallChunk[];\n tool_calls: ToolCall[];\n invalid_tool_calls: InvalidToolCall[];\n};\nexport {};\n//# sourceMappingURL=utils.d.ts.map"],"mappings":";;;;;;;;;;KAOYiB,eAAaC,oCACTC,IAAIA,EAAEC;AADtB;;;;;AACuB;AACb,KAOLC,UAAAA,CAAAA,GAAU,CAAA,GAAA,QACCH,MAAAA,GAAAA,GAAAA,MAAAA,SAAmBE,CAAnBF,GAAAA,KAAAA,GAAAA,MAA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hCjD4B,iBAAAA,gBAAAA,CAAAA,GAgCkJvB,gBAhClJuB,iBAAAA,gBAAAA,CAAAA,GAgCqPrB,oBAhCrPqB,iBAAAA,gBAAAA,CAAAA,GAgC4VnB,iBAhC5VmB,iBAAAA,gBAAAA,CAAAA,GAgCgcjB,kBAhChciB,iBAAAA,gBAAAA,CAAAA;AAAG;AAChB;AAOA;AACA;AAKA;AACA;;;;;;;;;;;;;;;;;;;;AAAqjB;AAS7hBW,iBAmCAG,sBAAAA,CAnC+B,MAAWvC,EAmCXW,aAnC6BZ,EAAAA,CAAAA,EAAAA;EAO5DsC,gBAAAA,EA6BF1B,aA7BE0B,EAAAA;EACAC,UAAAA,EA6BR5B,QA7BsB,EAAA;EAAUX,kBAAAA,EA8BxBU,eA9BwBV,EAAAA"}
@@ -1,7 +1,7 @@
1
1
  import { Serializable } from "./load/serializable.cjs";
2
2
  import { BaseMessage } from "./messages/base.cjs";
3
3
  import { HumanMessage } from "./messages/human.cjs";
4
- import { MessageStructure, MessageType } from "./messages/message.cjs";
4
+ import { MessageStructure, MessageToolSet, MessageType } from "./messages/message.cjs";
5
5
 
6
6
  //#region src/prompt_values.d.ts
7
7
  interface BasePromptValueInterface extends Serializable {
@@ -32,7 +32,7 @@ declare class StringPromptValue extends BasePromptValue implements StringPromptV
32
32
  value: string;
33
33
  constructor(value: string);
34
34
  toString(): string;
35
- toChatMessages(): HumanMessage<MessageStructure>[];
35
+ toChatMessages(): HumanMessage<MessageStructure<MessageToolSet>>[];
36
36
  }
37
37
  /**
38
38
  * Interface for the fields of a ChatPromptValue.
@@ -52,7 +52,7 @@ declare class ChatPromptValue extends BasePromptValue implements ChatPromptValue
52
52
  constructor(messages: BaseMessage[]);
53
53
  constructor(fields: ChatPromptValueFields);
54
54
  toString(): string;
55
- toChatMessages(): BaseMessage<MessageStructure, MessageType>[];
55
+ toChatMessages(): BaseMessage<MessageStructure<MessageToolSet>, MessageType>[];
56
56
  }
57
57
  type ImageContent = {
58
58
  /** Specifies the detail level of the image. */
@@ -77,7 +77,7 @@ declare class ImagePromptValue extends BasePromptValue {
77
77
  constructor(fields: ImagePromptValueFields);
78
78
  constructor(fields: ImageContent);
79
79
  toString(): string;
80
- toChatMessages(): HumanMessage<MessageStructure>[];
80
+ toChatMessages(): HumanMessage<MessageStructure<MessageToolSet>>[];
81
81
  }
82
82
  //#endregion
83
83
  export { BasePromptValue, BasePromptValueInterface, ChatPromptValue, ChatPromptValueFields, ChatPromptValueInterface, ImageContent, ImagePromptValue, ImagePromptValueFields, StringPromptValue, StringPromptValueInterface };
@@ -1 +1 @@
1
- {"version":3,"file":"prompt_values.d.cts","names":["Serializable","BaseMessage","HumanMessage","BasePromptValueInterface","StringPromptValueInterface","ChatPromptValueInterface","BasePromptValue","StringPromptValue","__messages_message_js0","MessageStructure","ChatPromptValueFields","ChatPromptValue","MessageType","ImageContent","ImagePromptValueFields","ImagePromptValue"],"sources":["../src/prompt_values.d.ts"],"sourcesContent":["import { Serializable } from \"./load/serializable.js\";\nimport { type BaseMessage } from \"./messages/base.js\";\nimport { HumanMessage } from \"./messages/human.js\";\nexport interface BasePromptValueInterface extends Serializable {\n toString(): string;\n toChatMessages(): BaseMessage[];\n}\nexport interface StringPromptValueInterface extends BasePromptValueInterface {\n value: string;\n}\nexport interface ChatPromptValueInterface extends BasePromptValueInterface {\n messages: BaseMessage[];\n}\n/**\n * Base PromptValue class. All prompt values should extend this class.\n */\nexport declare abstract class BasePromptValue extends Serializable implements BasePromptValueInterface {\n abstract toString(): string;\n abstract toChatMessages(): BaseMessage[];\n}\n/**\n * Represents a prompt value as a string. It extends the BasePromptValue\n * class and overrides the toString and toChatMessages methods.\n */\nexport declare class StringPromptValue extends BasePromptValue implements StringPromptValueInterface {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n value: string;\n constructor(value: string);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure>[];\n}\n/**\n * Interface for the fields of a ChatPromptValue.\n */\nexport interface ChatPromptValueFields {\n messages: BaseMessage[];\n}\n/**\n * Class that represents a chat prompt value. It extends the\n * BasePromptValue and includes an array of BaseMessage instances.\n */\nexport declare class ChatPromptValue extends BasePromptValue implements ChatPromptValueInterface {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n messages: BaseMessage[];\n constructor(messages: BaseMessage[]);\n constructor(fields: ChatPromptValueFields);\n toString(): string;\n toChatMessages(): BaseMessage<import(\"./messages/message.js\").MessageStructure, import(\"./messages/message.js\").MessageType>[];\n}\nexport type ImageContent = {\n /** Specifies the detail level of the image. */\n detail?: \"auto\" | \"low\" | \"high\";\n /** Either a URL of the image or the base64 encoded image data. */\n url: string;\n};\nexport interface ImagePromptValueFields {\n imageUrl: ImageContent;\n}\n/**\n * Class that represents an image prompt value. It extends the\n * BasePromptValue and includes an ImageURL instance.\n */\nexport declare class ImagePromptValue extends BasePromptValue {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n imageUrl: ImageContent;\n /** @ignore */\n value: string;\n constructor(fields: ImagePromptValueFields);\n constructor(fields: ImageContent);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure>[];\n}\n//# sourceMappingURL=prompt_values.d.ts.map"],"mappings":";;;;;;UAGiBG,wBAAAA,SAAiCH;;oBAE5BC;AAFtB;AAIiBG,UAAAA,0BAAAA,SAAmCD,wBAAwB,CAAA;EAG3DE,KAAAA,EAAAA,MAAAA;AAMjB;AAE+BJ,UARdI,wBAAAA,SAAiCF,wBAQnBF,CAAAA;EAFuBD,QAAAA,EALxCC,WAKwCD,EAAAA;;AAAgD;AAQtG;;AAOsBE,uBAfQI,eAAAA,SAAwBN,YAAAA,YAAwBG,wBAexDD,CAAAA;EAPyBI,SAAAA,QAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAA2BF,SAAAA,cAAAA,CAAAA,CAAAA,EAN3CH,WAM2CG,EAAAA;AAA0B;AAYpG;AAOA;;;AAMwBM,cAzBHH,iBAAAA,SAA0BD,eAAAA,YAA2BF,0BAyBlDM,CAAAA;;;EAEFT,eAAAA,EAAAA,OAAAA;EARuBK,KAAAA,EAAAA,MAAAA;EAA2BD,WAAAA,CAAAA,KAAAA,EAAAA,MAAAA;EAAwB,QAAA,CAAA,CAAA,EAAA,MAAA;EAUpFQ,cAAAA,CAAAA,CAAY,EAtBFX,YAsBE,kBAAA,EAAA;AAMxB;AAOA;;;AAQwBW,UAtCPH,qBAAAA,CAsCOG;YArCVZ;;;AA6B+C;;;cAvBxCU,eAAAA,SAAwBL,eAAAA,YAA2BD;;;;YAI1DJ;wBACYA;sBACFS;;oBAEFT;;KAEVY,YAAAA;;;;;;UAMKC,sBAAAA;YACHD;;;;;;cAMOE,gBAAAA,SAAyBT,eAAAA;;;;YAIhCO;;;sBAGUC;sBACAD;;oBAEFX"}
1
+ {"version":3,"file":"prompt_values.d.cts","names":["Serializable","BaseMessage","HumanMessage","BasePromptValueInterface","StringPromptValueInterface","ChatPromptValueInterface","BasePromptValue","StringPromptValue","__messages_message_js0","MessageToolSet","MessageStructure","ChatPromptValueFields","ChatPromptValue","MessageType","ImageContent","ImagePromptValueFields","ImagePromptValue"],"sources":["../src/prompt_values.d.ts"],"sourcesContent":["import { Serializable } from \"./load/serializable.js\";\nimport { type BaseMessage } from \"./messages/base.js\";\nimport { HumanMessage } from \"./messages/human.js\";\nexport interface BasePromptValueInterface extends Serializable {\n toString(): string;\n toChatMessages(): BaseMessage[];\n}\nexport interface StringPromptValueInterface extends BasePromptValueInterface {\n value: string;\n}\nexport interface ChatPromptValueInterface extends BasePromptValueInterface {\n messages: BaseMessage[];\n}\n/**\n * Base PromptValue class. All prompt values should extend this class.\n */\nexport declare abstract class BasePromptValue extends Serializable implements BasePromptValueInterface {\n abstract toString(): string;\n abstract toChatMessages(): BaseMessage[];\n}\n/**\n * Represents a prompt value as a string. It extends the BasePromptValue\n * class and overrides the toString and toChatMessages methods.\n */\nexport declare class StringPromptValue extends BasePromptValue implements StringPromptValueInterface {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n value: string;\n constructor(value: string);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure<import(\"./messages/message.js\").MessageToolSet>>[];\n}\n/**\n * Interface for the fields of a ChatPromptValue.\n */\nexport interface ChatPromptValueFields {\n messages: BaseMessage[];\n}\n/**\n * Class that represents a chat prompt value. It extends the\n * BasePromptValue and includes an array of BaseMessage instances.\n */\nexport declare class ChatPromptValue extends BasePromptValue implements ChatPromptValueInterface {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n messages: BaseMessage[];\n constructor(messages: BaseMessage[]);\n constructor(fields: ChatPromptValueFields);\n toString(): string;\n toChatMessages(): BaseMessage<import(\"./messages/message.js\").MessageStructure<import(\"./messages/message.js\").MessageToolSet>, import(\"./messages/message.js\").MessageType>[];\n}\nexport type ImageContent = {\n /** Specifies the detail level of the image. */\n detail?: \"auto\" | \"low\" | \"high\";\n /** Either a URL of the image or the base64 encoded image data. */\n url: string;\n};\nexport interface ImagePromptValueFields {\n imageUrl: ImageContent;\n}\n/**\n * Class that represents an image prompt value. It extends the\n * BasePromptValue and includes an ImageURL instance.\n */\nexport declare class ImagePromptValue extends BasePromptValue {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n imageUrl: ImageContent;\n /** @ignore */\n value: string;\n constructor(fields: ImagePromptValueFields);\n constructor(fields: ImageContent);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure<import(\"./messages/message.js\").MessageToolSet>>[];\n}\n//# sourceMappingURL=prompt_values.d.ts.map"],"mappings":";;;;;;UAGiBG,wBAAAA,SAAiCH;;oBAE5BC;AAFtB;AAIiBG,UAAAA,0BAAAA,SAAmCD,wBAAwB,CAAA;EAG3DE,KAAAA,EAAAA,MAAAA;AAMjB;AAE+BJ,UARdI,wBAAAA,SAAiCF,wBAQnBF,CAAAA;EAFuBD,QAAAA,EALxCC,WAKwCD,EAAAA;;AAAgD;AAQtG;;uBAR8BM,eAAAA,SAAwBN,YAAAA,YAAwBG;EAexDD,SAAAA,QAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAPyBI,SAAAA,cAAAA,CAAAA,CAAAA,EANhBL,WAMgBK,EAAAA;;AAAqD;AAYpG;AAOA;;AAK0BL,cAxBLM,iBAAAA,SAA0BD,eAAAA,YAA2BF,0BAwBhDH,CAAAA;EACFU,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;;EAEFV,WAAAA,CAAAA,KAAAA,EAAAA,MAAAA;EARuBK,QAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAA2BD,cAAAA,CAAAA,CAAAA,EAZlDH,YAYkDG,iBAAAA,gBAAAA,CAAAA,EAAAA;AAAwB;AAUhG;AAMA;AAOA;AAIcS,UAlCGH,qBAAAA,CAkCHG;EAGUC,QAAAA,EApCVd,WAoCUc,EAAAA;;;;;;AAPqC,cAvBxCH,eAAAA,SAAwBN,eAAAA,YAA2BD,wBAuBX,CAAA;;;;YAnB/CJ;wBACYA;sBACFU;;oBAEFV;;KAEVa,YAAAA;;;;;;UAMKC,sBAAAA;YACHD;;;;;;cAMOE,gBAAAA,SAAyBV,eAAAA;;;;YAIhCQ;;;sBAGUC;sBACAD;;oBAEFZ"}
@@ -1,7 +1,7 @@
1
1
  import { Serializable } from "./load/serializable.js";
2
2
  import { BaseMessage } from "./messages/base.js";
3
3
  import { HumanMessage } from "./messages/human.js";
4
- import { MessageStructure, MessageType } from "./messages/message.js";
4
+ import { MessageStructure, MessageToolSet, MessageType } from "./messages/message.js";
5
5
 
6
6
  //#region src/prompt_values.d.ts
7
7
  interface BasePromptValueInterface extends Serializable {
@@ -32,7 +32,7 @@ declare class StringPromptValue extends BasePromptValue implements StringPromptV
32
32
  value: string;
33
33
  constructor(value: string);
34
34
  toString(): string;
35
- toChatMessages(): HumanMessage<MessageStructure>[];
35
+ toChatMessages(): HumanMessage<MessageStructure<MessageToolSet>>[];
36
36
  }
37
37
  /**
38
38
  * Interface for the fields of a ChatPromptValue.
@@ -52,7 +52,7 @@ declare class ChatPromptValue extends BasePromptValue implements ChatPromptValue
52
52
  constructor(messages: BaseMessage[]);
53
53
  constructor(fields: ChatPromptValueFields);
54
54
  toString(): string;
55
- toChatMessages(): BaseMessage<MessageStructure, MessageType>[];
55
+ toChatMessages(): BaseMessage<MessageStructure<MessageToolSet>, MessageType>[];
56
56
  }
57
57
  type ImageContent = {
58
58
  /** Specifies the detail level of the image. */
@@ -77,7 +77,7 @@ declare class ImagePromptValue extends BasePromptValue {
77
77
  constructor(fields: ImagePromptValueFields);
78
78
  constructor(fields: ImageContent);
79
79
  toString(): string;
80
- toChatMessages(): HumanMessage<MessageStructure>[];
80
+ toChatMessages(): HumanMessage<MessageStructure<MessageToolSet>>[];
81
81
  }
82
82
  //#endregion
83
83
  export { BasePromptValue, BasePromptValueInterface, ChatPromptValue, ChatPromptValueFields, ChatPromptValueInterface, ImageContent, ImagePromptValue, ImagePromptValueFields, StringPromptValue, StringPromptValueInterface };
@@ -1 +1 @@
1
- {"version":3,"file":"prompt_values.d.ts","names":["Serializable","BaseMessage","HumanMessage","BasePromptValueInterface","StringPromptValueInterface","ChatPromptValueInterface","BasePromptValue","StringPromptValue","__messages_message_js0","MessageStructure","ChatPromptValueFields","ChatPromptValue","MessageType","ImageContent","ImagePromptValueFields","ImagePromptValue"],"sources":["../src/prompt_values.d.ts"],"sourcesContent":["import { Serializable } from \"./load/serializable.js\";\nimport { type BaseMessage } from \"./messages/base.js\";\nimport { HumanMessage } from \"./messages/human.js\";\nexport interface BasePromptValueInterface extends Serializable {\n toString(): string;\n toChatMessages(): BaseMessage[];\n}\nexport interface StringPromptValueInterface extends BasePromptValueInterface {\n value: string;\n}\nexport interface ChatPromptValueInterface extends BasePromptValueInterface {\n messages: BaseMessage[];\n}\n/**\n * Base PromptValue class. All prompt values should extend this class.\n */\nexport declare abstract class BasePromptValue extends Serializable implements BasePromptValueInterface {\n abstract toString(): string;\n abstract toChatMessages(): BaseMessage[];\n}\n/**\n * Represents a prompt value as a string. It extends the BasePromptValue\n * class and overrides the toString and toChatMessages methods.\n */\nexport declare class StringPromptValue extends BasePromptValue implements StringPromptValueInterface {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n value: string;\n constructor(value: string);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure>[];\n}\n/**\n * Interface for the fields of a ChatPromptValue.\n */\nexport interface ChatPromptValueFields {\n messages: BaseMessage[];\n}\n/**\n * Class that represents a chat prompt value. It extends the\n * BasePromptValue and includes an array of BaseMessage instances.\n */\nexport declare class ChatPromptValue extends BasePromptValue implements ChatPromptValueInterface {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n messages: BaseMessage[];\n constructor(messages: BaseMessage[]);\n constructor(fields: ChatPromptValueFields);\n toString(): string;\n toChatMessages(): BaseMessage<import(\"./messages/message.js\").MessageStructure, import(\"./messages/message.js\").MessageType>[];\n}\nexport type ImageContent = {\n /** Specifies the detail level of the image. */\n detail?: \"auto\" | \"low\" | \"high\";\n /** Either a URL of the image or the base64 encoded image data. */\n url: string;\n};\nexport interface ImagePromptValueFields {\n imageUrl: ImageContent;\n}\n/**\n * Class that represents an image prompt value. It extends the\n * BasePromptValue and includes an ImageURL instance.\n */\nexport declare class ImagePromptValue extends BasePromptValue {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n imageUrl: ImageContent;\n /** @ignore */\n value: string;\n constructor(fields: ImagePromptValueFields);\n constructor(fields: ImageContent);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure>[];\n}\n//# sourceMappingURL=prompt_values.d.ts.map"],"mappings":";;;;;;UAGiBG,wBAAAA,SAAiCH;;oBAE5BC;AAFtB;AAIiBG,UAAAA,0BAAAA,SAAmCD,wBAAwB,CAAA;EAG3DE,KAAAA,EAAAA,MAAAA;AAMjB;AAE+BJ,UARdI,wBAAAA,SAAiCF,wBAQnBF,CAAAA;EAFuBD,QAAAA,EALxCC,WAKwCD,EAAAA;;AAAgD;AAQtG;;AAOsBE,uBAfQI,eAAAA,SAAwBN,YAAAA,YAAwBG,wBAexDD,CAAAA;EAPyBI,SAAAA,QAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAA2BF,SAAAA,cAAAA,CAAAA,CAAAA,EAN3CH,WAM2CG,EAAAA;AAA0B;AAYpG;AAOA;;;AAMwBM,cAzBHH,iBAAAA,SAA0BD,eAAAA,YAA2BF,0BAyBlDM,CAAAA;;;EAEFT,eAAAA,EAAAA,OAAAA;EARuBK,KAAAA,EAAAA,MAAAA;EAA2BD,WAAAA,CAAAA,KAAAA,EAAAA,MAAAA;EAAwB,QAAA,CAAA,CAAA,EAAA,MAAA;EAUpFQ,cAAAA,CAAAA,CAAY,EAtBFX,YAsBE,kBAAA,EAAA;AAMxB;AAOA;;;AAQwBW,UAtCPH,qBAAAA,CAsCOG;YArCVZ;;;AA6B+C;;;cAvBxCU,eAAAA,SAAwBL,eAAAA,YAA2BD;;;;YAI1DJ;wBACYA;sBACFS;;oBAEFT;;KAEVY,YAAAA;;;;;;UAMKC,sBAAAA;YACHD;;;;;;cAMOE,gBAAAA,SAAyBT,eAAAA;;;;YAIhCO;;;sBAGUC;sBACAD;;oBAEFX"}
1
+ {"version":3,"file":"prompt_values.d.ts","names":["Serializable","BaseMessage","HumanMessage","BasePromptValueInterface","StringPromptValueInterface","ChatPromptValueInterface","BasePromptValue","StringPromptValue","__messages_message_js0","MessageToolSet","MessageStructure","ChatPromptValueFields","ChatPromptValue","MessageType","ImageContent","ImagePromptValueFields","ImagePromptValue"],"sources":["../src/prompt_values.d.ts"],"sourcesContent":["import { Serializable } from \"./load/serializable.js\";\nimport { type BaseMessage } from \"./messages/base.js\";\nimport { HumanMessage } from \"./messages/human.js\";\nexport interface BasePromptValueInterface extends Serializable {\n toString(): string;\n toChatMessages(): BaseMessage[];\n}\nexport interface StringPromptValueInterface extends BasePromptValueInterface {\n value: string;\n}\nexport interface ChatPromptValueInterface extends BasePromptValueInterface {\n messages: BaseMessage[];\n}\n/**\n * Base PromptValue class. All prompt values should extend this class.\n */\nexport declare abstract class BasePromptValue extends Serializable implements BasePromptValueInterface {\n abstract toString(): string;\n abstract toChatMessages(): BaseMessage[];\n}\n/**\n * Represents a prompt value as a string. It extends the BasePromptValue\n * class and overrides the toString and toChatMessages methods.\n */\nexport declare class StringPromptValue extends BasePromptValue implements StringPromptValueInterface {\n static lc_name(): string;\n lc_namespace: string[];\n lc_serializable: boolean;\n value: string;\n constructor(value: string);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure<import(\"./messages/message.js\").MessageToolSet>>[];\n}\n/**\n * Interface for the fields of a ChatPromptValue.\n */\nexport interface ChatPromptValueFields {\n messages: BaseMessage[];\n}\n/**\n * Class that represents a chat prompt value. It extends the\n * BasePromptValue and includes an array of BaseMessage instances.\n */\nexport declare class ChatPromptValue extends BasePromptValue implements ChatPromptValueInterface {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n messages: BaseMessage[];\n constructor(messages: BaseMessage[]);\n constructor(fields: ChatPromptValueFields);\n toString(): string;\n toChatMessages(): BaseMessage<import(\"./messages/message.js\").MessageStructure<import(\"./messages/message.js\").MessageToolSet>, import(\"./messages/message.js\").MessageType>[];\n}\nexport type ImageContent = {\n /** Specifies the detail level of the image. */\n detail?: \"auto\" | \"low\" | \"high\";\n /** Either a URL of the image or the base64 encoded image data. */\n url: string;\n};\nexport interface ImagePromptValueFields {\n imageUrl: ImageContent;\n}\n/**\n * Class that represents an image prompt value. It extends the\n * BasePromptValue and includes an ImageURL instance.\n */\nexport declare class ImagePromptValue extends BasePromptValue {\n lc_namespace: string[];\n lc_serializable: boolean;\n static lc_name(): string;\n imageUrl: ImageContent;\n /** @ignore */\n value: string;\n constructor(fields: ImagePromptValueFields);\n constructor(fields: ImageContent);\n toString(): string;\n toChatMessages(): HumanMessage<import(\"./messages/message.js\").MessageStructure<import(\"./messages/message.js\").MessageToolSet>>[];\n}\n//# sourceMappingURL=prompt_values.d.ts.map"],"mappings":";;;;;;UAGiBG,wBAAAA,SAAiCH;;oBAE5BC;AAFtB;AAIiBG,UAAAA,0BAAAA,SAAmCD,wBAAwB,CAAA;EAG3DE,KAAAA,EAAAA,MAAAA;AAMjB;AAE+BJ,UARdI,wBAAAA,SAAiCF,wBAQnBF,CAAAA;EAFuBD,QAAAA,EALxCC,WAKwCD,EAAAA;;AAAgD;AAQtG;;uBAR8BM,eAAAA,SAAwBN,YAAAA,YAAwBG;EAexDD,SAAAA,QAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAPyBI,SAAAA,cAAAA,CAAAA,CAAAA,EANhBL,WAMgBK,EAAAA;;AAAqD;AAYpG;AAOA;;AAK0BL,cAxBLM,iBAAAA,SAA0BD,eAAAA,YAA2BF,0BAwBhDH,CAAAA;EACFU,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;;EAEFV,WAAAA,CAAAA,KAAAA,EAAAA,MAAAA;EARuBK,QAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAA2BD,cAAAA,CAAAA,CAAAA,EAZlDH,YAYkDG,iBAAAA,gBAAAA,CAAAA,EAAAA;AAAwB;AAUhG;AAMA;AAOA;AAIcS,UAlCGH,qBAAAA,CAkCHG;EAGUC,QAAAA,EApCVd,WAoCUc,EAAAA;;;;;;AAPqC,cAvBxCH,eAAAA,SAAwBN,eAAAA,YAA2BD,wBAuBX,CAAA;;;;YAnB/CJ;wBACYA;sBACFU;;oBAEFV;;KAEVa,YAAAA;;;;;;UAMKC,sBAAAA;YACHD;;;;;;cAMOE,gBAAAA,SAAyBV,eAAAA;;;;YAIhCQ;;;sBAGUC;sBACAD;;oBAEFZ"}