@langchain/core 1.0.0-alpha.6 → 1.0.0

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 (245) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/LICENSE +6 -6
  3. package/README.md +2 -23
  4. package/dist/agents.d.ts.map +1 -1
  5. package/dist/caches/base.d.cts.map +1 -1
  6. package/dist/callbacks/base.d.cts.map +1 -1
  7. package/dist/callbacks/base.d.ts.map +1 -1
  8. package/dist/callbacks/manager.cjs +9 -64
  9. package/dist/callbacks/manager.cjs.map +1 -1
  10. package/dist/callbacks/manager.d.cts +1 -23
  11. package/dist/callbacks/manager.d.cts.map +1 -1
  12. package/dist/callbacks/manager.d.ts +1 -23
  13. package/dist/callbacks/manager.d.ts.map +1 -1
  14. package/dist/callbacks/manager.js +10 -63
  15. package/dist/callbacks/manager.js.map +1 -1
  16. package/dist/chat_history.cjs +0 -4
  17. package/dist/chat_history.cjs.map +1 -1
  18. package/dist/chat_history.d.cts +1 -3
  19. package/dist/chat_history.d.cts.map +1 -1
  20. package/dist/chat_history.d.ts +1 -3
  21. package/dist/chat_history.d.ts.map +1 -1
  22. package/dist/chat_history.js +0 -4
  23. package/dist/chat_history.js.map +1 -1
  24. package/dist/document_loaders/base.cjs +1 -13
  25. package/dist/document_loaders/base.cjs.map +1 -1
  26. package/dist/document_loaders/base.d.cts +0 -9
  27. package/dist/document_loaders/base.d.cts.map +1 -1
  28. package/dist/document_loaders/base.d.ts +0 -9
  29. package/dist/document_loaders/base.d.ts.map +1 -1
  30. package/dist/document_loaders/base.js +1 -13
  31. package/dist/document_loaders/base.js.map +1 -1
  32. package/dist/document_loaders/langsmith.d.cts +1 -1
  33. package/dist/language_models/base.cjs.map +1 -1
  34. package/dist/language_models/base.d.cts +0 -16
  35. package/dist/language_models/base.d.cts.map +1 -1
  36. package/dist/language_models/base.d.ts +0 -16
  37. package/dist/language_models/base.d.ts.map +1 -1
  38. package/dist/language_models/base.js.map +1 -1
  39. package/dist/language_models/chat_models.cjs +10 -83
  40. package/dist/language_models/chat_models.cjs.map +1 -1
  41. package/dist/language_models/chat_models.d.cts +21 -55
  42. package/dist/language_models/chat_models.d.cts.map +1 -1
  43. package/dist/language_models/chat_models.d.ts +21 -55
  44. package/dist/language_models/chat_models.d.ts.map +1 -1
  45. package/dist/language_models/chat_models.js +11 -83
  46. package/dist/language_models/chat_models.js.map +1 -1
  47. package/dist/language_models/llms.cjs +0 -56
  48. package/dist/language_models/llms.cjs.map +1 -1
  49. package/dist/language_models/llms.d.cts +1 -43
  50. package/dist/language_models/llms.d.cts.map +1 -1
  51. package/dist/language_models/llms.d.ts +1 -43
  52. package/dist/language_models/llms.d.ts.map +1 -1
  53. package/dist/language_models/llms.js +0 -56
  54. package/dist/language_models/llms.js.map +1 -1
  55. package/dist/load/import_map.cjs +1 -7
  56. package/dist/load/import_map.cjs.map +1 -1
  57. package/dist/load/import_map.js +1 -7
  58. package/dist/load/import_map.js.map +1 -1
  59. package/dist/messages/ai.cjs +4 -0
  60. package/dist/messages/ai.cjs.map +1 -1
  61. package/dist/messages/ai.js +4 -0
  62. package/dist/messages/ai.js.map +1 -1
  63. package/dist/messages/block_translators/anthropic.cjs +191 -144
  64. package/dist/messages/block_translators/anthropic.cjs.map +1 -1
  65. package/dist/messages/block_translators/anthropic.js +191 -144
  66. package/dist/messages/block_translators/anthropic.js.map +1 -1
  67. package/dist/messages/block_translators/index.cjs +2 -2
  68. package/dist/messages/block_translators/index.cjs.map +1 -1
  69. package/dist/messages/block_translators/index.js +4 -4
  70. package/dist/messages/block_translators/index.js.map +1 -1
  71. package/dist/messages/block_translators/openai.cjs +78 -22
  72. package/dist/messages/block_translators/openai.cjs.map +1 -1
  73. package/dist/messages/block_translators/openai.js +78 -22
  74. package/dist/messages/block_translators/openai.js.map +1 -1
  75. package/dist/messages/content/tools.cjs +1 -5
  76. package/dist/messages/content/tools.cjs.map +1 -1
  77. package/dist/messages/content/tools.d.cts +1 -85
  78. package/dist/messages/content/tools.d.cts.map +1 -1
  79. package/dist/messages/content/tools.d.ts +1 -85
  80. package/dist/messages/content/tools.d.ts.map +1 -1
  81. package/dist/messages/content/tools.js +1 -5
  82. package/dist/messages/content/tools.js.map +1 -1
  83. package/dist/messages/metadata.cjs.map +1 -1
  84. package/dist/messages/metadata.d.cts +3 -0
  85. package/dist/messages/metadata.d.cts.map +1 -1
  86. package/dist/messages/metadata.d.ts +3 -0
  87. package/dist/messages/metadata.d.ts.map +1 -1
  88. package/dist/messages/metadata.js.map +1 -1
  89. package/dist/messages/tool.cjs +2 -0
  90. package/dist/messages/tool.cjs.map +1 -1
  91. package/dist/messages/tool.d.cts +2 -0
  92. package/dist/messages/tool.d.cts.map +1 -1
  93. package/dist/messages/tool.d.ts +2 -0
  94. package/dist/messages/tool.d.ts.map +1 -1
  95. package/dist/messages/tool.js +2 -0
  96. package/dist/messages/tool.js.map +1 -1
  97. package/dist/output_parsers/json.cjs +5 -0
  98. package/dist/output_parsers/json.cjs.map +1 -1
  99. package/dist/output_parsers/json.d.cts +2 -0
  100. package/dist/output_parsers/json.d.cts.map +1 -1
  101. package/dist/output_parsers/json.d.ts +2 -0
  102. package/dist/output_parsers/json.d.ts.map +1 -1
  103. package/dist/output_parsers/json.js +5 -0
  104. package/dist/output_parsers/json.js.map +1 -1
  105. package/dist/prompts/base.cjs +0 -36
  106. package/dist/prompts/base.cjs.map +1 -1
  107. package/dist/prompts/base.d.cts +0 -16
  108. package/dist/prompts/base.d.cts.map +1 -1
  109. package/dist/prompts/base.d.ts +0 -16
  110. package/dist/prompts/base.d.ts.map +1 -1
  111. package/dist/prompts/base.js +0 -36
  112. package/dist/prompts/base.js.map +1 -1
  113. package/dist/prompts/chat.cjs +1 -5
  114. package/dist/prompts/chat.cjs.map +1 -1
  115. package/dist/prompts/chat.d.cts +1 -4
  116. package/dist/prompts/chat.d.cts.map +1 -1
  117. package/dist/prompts/chat.d.ts +1 -4
  118. package/dist/prompts/chat.d.ts.map +1 -1
  119. package/dist/prompts/chat.js +1 -5
  120. package/dist/prompts/chat.js.map +1 -1
  121. package/dist/prompts/dict.d.cts +1 -1
  122. package/dist/prompts/dict.d.ts +1 -1
  123. package/dist/prompts/few_shot.d.cts +2 -2
  124. package/dist/prompts/few_shot.d.ts +2 -2
  125. package/dist/prompts/image.d.cts +1 -1
  126. package/dist/prompts/image.d.ts +1 -1
  127. package/dist/prompts/index.d.cts +2 -2
  128. package/dist/prompts/index.d.ts +2 -2
  129. package/dist/prompts/pipeline.d.cts +1 -1
  130. package/dist/prompts/pipeline.d.ts +1 -1
  131. package/dist/prompts/prompt.d.cts +2 -2
  132. package/dist/prompts/prompt.d.ts +2 -2
  133. package/dist/retrievers/index.cjs +3 -18
  134. package/dist/retrievers/index.cjs.map +1 -1
  135. package/dist/retrievers/index.d.cts +2 -27
  136. package/dist/retrievers/index.d.cts.map +1 -1
  137. package/dist/retrievers/index.d.ts +2 -27
  138. package/dist/retrievers/index.d.ts.map +1 -1
  139. package/dist/retrievers/index.js +3 -18
  140. package/dist/retrievers/index.js.map +1 -1
  141. package/dist/runnables/base.cjs +24 -63
  142. package/dist/runnables/base.cjs.map +1 -1
  143. package/dist/runnables/base.d.cts +10 -39
  144. package/dist/runnables/base.d.cts.map +1 -1
  145. package/dist/runnables/base.d.ts +10 -39
  146. package/dist/runnables/base.d.ts.map +1 -1
  147. package/dist/runnables/base.js +24 -63
  148. package/dist/runnables/base.js.map +1 -1
  149. package/dist/runnables/graph.cjs +1 -1
  150. package/dist/runnables/graph.cjs.map +1 -1
  151. package/dist/runnables/graph.js +2 -2
  152. package/dist/runnables/graph.js.map +1 -1
  153. package/dist/runnables/graph_mermaid.cjs +1 -10
  154. package/dist/runnables/graph_mermaid.cjs.map +1 -1
  155. package/dist/runnables/graph_mermaid.js +1 -10
  156. package/dist/runnables/graph_mermaid.js.map +1 -1
  157. package/dist/runnables/history.cjs +1 -1
  158. package/dist/runnables/history.cjs.map +1 -1
  159. package/dist/runnables/history.d.cts +2 -2
  160. package/dist/runnables/history.d.cts.map +1 -1
  161. package/dist/runnables/history.d.ts +2 -2
  162. package/dist/runnables/history.d.ts.map +1 -1
  163. package/dist/runnables/history.js +1 -1
  164. package/dist/runnables/history.js.map +1 -1
  165. package/dist/stores.cjs.map +1 -1
  166. package/dist/stores.d.cts +3 -29
  167. package/dist/stores.d.cts.map +1 -1
  168. package/dist/stores.d.ts +3 -29
  169. package/dist/stores.d.ts.map +1 -1
  170. package/dist/stores.js.map +1 -1
  171. package/dist/tools/index.cjs +12 -4
  172. package/dist/tools/index.cjs.map +1 -1
  173. package/dist/tools/index.js +12 -4
  174. package/dist/tools/index.js.map +1 -1
  175. package/dist/tools/types.cjs.map +1 -1
  176. package/dist/tools/types.d.cts +4 -0
  177. package/dist/tools/types.d.cts.map +1 -1
  178. package/dist/tools/types.d.ts +4 -0
  179. package/dist/tools/types.d.ts.map +1 -1
  180. package/dist/tools/types.js.map +1 -1
  181. package/dist/tracers/base.cjs +1 -1
  182. package/dist/tracers/base.cjs.map +1 -1
  183. package/dist/tracers/base.d.cts +1 -1
  184. package/dist/tracers/base.js +2 -2
  185. package/dist/tracers/base.js.map +1 -1
  186. package/dist/tracers/log_stream.d.cts +1 -1
  187. package/dist/tracers/log_stream.d.ts +1 -1
  188. package/dist/tracers/tracer_langchain.cjs +1 -0
  189. package/dist/tracers/tracer_langchain.cjs.map +1 -1
  190. package/dist/tracers/tracer_langchain.d.cts +2 -2
  191. package/dist/tracers/tracer_langchain.js +1 -0
  192. package/dist/tracers/tracer_langchain.js.map +1 -1
  193. package/dist/utils/env.cjs +1 -9
  194. package/dist/utils/env.cjs.map +1 -1
  195. package/dist/utils/env.d.cts +2 -6
  196. package/dist/utils/env.d.cts.map +1 -1
  197. package/dist/utils/env.d.ts +2 -6
  198. package/dist/utils/env.d.ts.map +1 -1
  199. package/dist/utils/env.js +2 -9
  200. package/dist/utils/env.js.map +1 -1
  201. package/dist/utils/testing/message_history.cjs +1 -1
  202. package/dist/utils/testing/message_history.cjs.map +1 -1
  203. package/dist/utils/testing/message_history.d.cts +1 -1
  204. package/dist/utils/testing/message_history.d.cts.map +1 -1
  205. package/dist/utils/testing/message_history.d.ts +1 -1
  206. package/dist/utils/testing/message_history.d.ts.map +1 -1
  207. package/dist/utils/testing/message_history.js +1 -1
  208. package/dist/utils/testing/message_history.js.map +1 -1
  209. package/dist/utils/types/index.cjs +6 -0
  210. package/dist/utils/types/index.d.cts +2 -2
  211. package/dist/utils/types/index.d.ts +2 -2
  212. package/dist/utils/types/index.js +5 -2
  213. package/dist/utils/types/zod.cjs +23 -0
  214. package/dist/utils/types/zod.cjs.map +1 -1
  215. package/dist/utils/types/zod.d.cts +11 -1
  216. package/dist/utils/types/zod.d.cts.map +1 -1
  217. package/dist/utils/types/zod.d.ts +11 -1
  218. package/dist/utils/types/zod.d.ts.map +1 -1
  219. package/dist/utils/types/zod.js +21 -1
  220. package/dist/utils/types/zod.js.map +1 -1
  221. package/package.json +121 -154
  222. package/dist/runnables/remote.cjs +0 -399
  223. package/dist/runnables/remote.cjs.map +0 -1
  224. package/dist/runnables/remote.d.cts +0 -73
  225. package/dist/runnables/remote.d.cts.map +0 -1
  226. package/dist/runnables/remote.d.ts +0 -73
  227. package/dist/runnables/remote.d.ts.map +0 -1
  228. package/dist/runnables/remote.js +0 -393
  229. package/dist/runnables/remote.js.map +0 -1
  230. package/dist/tracers/initialize.cjs +0 -46
  231. package/dist/tracers/initialize.cjs.map +0 -1
  232. package/dist/tracers/initialize.d.cts +0 -26
  233. package/dist/tracers/initialize.d.cts.map +0 -1
  234. package/dist/tracers/initialize.d.ts +0 -26
  235. package/dist/tracers/initialize.d.ts.map +0 -1
  236. package/dist/tracers/initialize.js +0 -39
  237. package/dist/tracers/initialize.js.map +0 -1
  238. package/dist/tracers/tracer_langchain_v1.cjs +0 -168
  239. package/dist/tracers/tracer_langchain_v1.cjs.map +0 -1
  240. package/dist/tracers/tracer_langchain_v1.d.cts +0 -64
  241. package/dist/tracers/tracer_langchain_v1.d.cts.map +0 -1
  242. package/dist/tracers/tracer_langchain_v1.d.ts +0 -64
  243. package/dist/tracers/tracer_langchain_v1.d.ts.map +0 -1
  244. package/dist/tracers/tracer_langchain_v1.js +0 -162
  245. package/dist/tracers/tracer_langchain_v1.js.map +0 -1
@@ -121,91 +121,7 @@ declare namespace Tools {
121
121
  */
122
122
  output: TOutput;
123
123
  }
124
- /**
125
- * Content block for a built-in web search tool call.
126
- * @deprecated Use ServerToolCall instead
127
- */
128
- interface WebSearchCall extends BaseContentBlock {
129
- /**
130
- * Type of the content block
131
- */
132
- readonly type: "web_search_call";
133
- /**
134
- * The search query used in the web search tool call
135
- */
136
- query?: string;
137
- }
138
- /**
139
- * Content block for the result of a built-in search tool call
140
- * @deprecated Use ServerToolCallResult instead
141
- */
142
- interface WebSearchResult extends BaseContentBlock {
143
- /**
144
- * Type of the content block
145
- */
146
- readonly type: "web_search_result";
147
- /**
148
- * List of URLs returned by the web search tool call
149
- */
150
- urls?: string[];
151
- }
152
- /**
153
- * Content block for a built-in code interpreter tool call.
154
- * @deprecated Use ServerToolCall instead
155
- */
156
- interface CodeInterpreterCall extends BaseContentBlock {
157
- /**
158
- * Type of the content block
159
- */
160
- readonly type: "code_interpreter_call";
161
- /**
162
- * The language of the code executed by the code interpreter tool call
163
- */
164
- language?: string;
165
- /**
166
- * The code to be executed by the code interpreter
167
- */
168
- code?: string;
169
- }
170
- /**
171
- * Content block for the output of a singular code interpreter tool call
172
- * @deprecated Use ServerToolCallResult instead
173
- */
174
- interface CodeInterpreterOutput {
175
- readonly type: "code_interpreter_output";
176
- /**
177
- * The return code of the code interpreter tool call
178
- * Example: 0 for success, non-zero for failure
179
- */
180
- returnCode?: number;
181
- /**
182
- * Standard error output of the executed code
183
- */
184
- stderr?: string;
185
- /**
186
- * Standard output of the executed code
187
- */
188
- stdout?: string;
189
- /**
190
- * File IDs of the files created by the code interpreter tool call
191
- */
192
- fileIds?: string[];
193
- }
194
- /**
195
- * Content block for the result of a code interpreter tool call
196
- * @deprecated Use ServerToolCallResult instead
197
- */
198
- interface CodeInterpreterResult extends BaseContentBlock {
199
- /**
200
- * Type of the content block
201
- */
202
- readonly type: "code_interpreter_result";
203
- /**
204
- * The result of the code interpreter tool call
205
- */
206
- output: CodeInterpreterOutput[];
207
- }
208
- type Standard = ToolCall | ToolCallChunk | InvalidToolCall | ServerToolCall | ServerToolCallChunk | ServerToolCallResult | WebSearchCall | WebSearchResult | CodeInterpreterCall | CodeInterpreterResult;
124
+ type Standard = ToolCall | ToolCallChunk | InvalidToolCall | ServerToolCall | ServerToolCallChunk | ServerToolCallResult;
209
125
  }
210
126
  //#endregion
211
127
  export { Tools };
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","names":["BaseContentBlock","Tools","KNOWN_BLOCK_TYPES","TName","TArgs","Record","TOutput","CodeInterpreterOutput","ToolCall","ToolCallChunk","InvalidToolCall","ServerToolCall","ServerToolCallChunk","ServerToolCallResult","WebSearchCall","WebSearchResult","CodeInterpreterCall","CodeInterpreterResult"],"sources":["../../../src/messages/content/tools.d.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\nexport type Tools = never;\nexport declare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace Tools {\n /**\n * Represents a request to call a tool.\n *\n * @example\n * ```ts\n * const toolCall: ToolCall = {\n * type: \"tool_call\",\n * name: \"foo\",\n * args: { a: 1 },\n * callId: \"123\"\n * };\n * ```\n * This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n * and an identifier of \"123\".\n */\n interface ToolCall<TName extends string = string, TArgs = unknown> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call\";\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 /** Content block to represent partial data of a tool call */\n interface ToolCallChunk<TName extends string = string> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call_chunk\";\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 * The index of the tool call chunk\n */\n index?: number;\n }\n /** Content block to represent an invalid tool call */\n interface InvalidToolCall<TName extends string = string> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"invalid_tool_call\";\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 interface ServerToolCall<TName extends string = string, TArgs = unknown> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call\";\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 interface ServerToolCallChunk<TName extends string = string> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_chunk\";\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 interface ServerToolCallResult<TOutput = Record<string, unknown>> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_result\";\n /**\n * The unique identifier of the tool call that this result corresponds to\n */\n toolCallId: string;\n /**\n * The status of the server tool call\n */\n status: \"success\" | \"error\";\n /**\n * The output of the server tool call\n */\n output: TOutput;\n }\n /**\n * Content block for a built-in web search tool call.\n * @deprecated Use ServerToolCall instead\n */\n interface WebSearchCall extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"web_search_call\";\n /**\n * The search query used in the web search tool call\n */\n query?: string;\n }\n /**\n * Content block for the result of a built-in search tool call\n * @deprecated Use ServerToolCallResult instead\n */\n interface WebSearchResult extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"web_search_result\";\n /**\n * List of URLs returned by the web search tool call\n */\n urls?: string[];\n }\n /**\n * Content block for a built-in code interpreter tool call.\n * @deprecated Use ServerToolCall instead\n */\n interface CodeInterpreterCall extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"code_interpreter_call\";\n /**\n * The language of the code executed by the code interpreter tool call\n */\n language?: string;\n /**\n * The code to be executed by the code interpreter\n */\n code?: string;\n }\n /**\n * Content block for the output of a singular code interpreter tool call\n * @deprecated Use ServerToolCallResult instead\n */\n interface CodeInterpreterOutput {\n readonly type: \"code_interpreter_output\";\n /**\n * The return code of the code interpreter tool call\n * Example: 0 for success, non-zero for failure\n */\n returnCode?: number;\n /**\n * Standard error output of the executed code\n */\n stderr?: string;\n /**\n * Standard output of the executed code\n */\n stdout?: string;\n /**\n * File IDs of the files created by the code interpreter tool call\n */\n fileIds?: string[];\n }\n /**\n * Content block for the result of a code interpreter tool call\n * @deprecated Use ServerToolCallResult instead\n */\n interface CodeInterpreterResult extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"code_interpreter_result\";\n /**\n * The result of the code interpreter tool call\n */\n output: CodeInterpreterOutput[];\n }\n type Standard = ToolCall | ToolCallChunk | InvalidToolCall | ServerToolCall | ServerToolCallChunk | ServerToolCallResult | WebSearchCall | WebSearchResult | CodeInterpreterCall | CodeInterpreterResult;\n}\n"],"mappings":";;;KACYC,KAAAA;AAAZ;AAGyBA,kBAAAA,KAAAA,CAAK;EAAA;;;;;;;;;;;;;;;EAoHP,UAhBuDD,QAAAA,CAAAA,cAAAA,MAAAA,GAAAA,MAAAA,EAAAA,QAAAA,OAAAA,CAAAA,SApFCA,gBAoFDA,CAAAA;IAsB1CA;;;IA8EpBO,SAAAA,IAAAA,EAAAA,WAAAA;IAR4BP;;;IAUGU,IAAAA,EAlLjCP,KAkLiCO;IAAkBC;;;IAA8DG,IAAAA,EA9KjHV,KA8KiHU;EAAa;EAAkB;EAAsB,UAAGG,aAAAA,CAAAA,cAAAA,MAAAA,GAAAA,MAAAA,CAAAA,SA3KpHjB,gBA2KoHiB,CAAAA;IAAqB;;;;;;;WAnK7Ld;;;;;;;;;;;mEAWsDH;;;;;;;;WAQtDG;;;;;;;;;;;;;;mFAcsEH;;;;;;;;UAQvEG;;;;UAIAC;;uEAE2DJ;;;;;;;;WAQ1DG;;;;;;2CAM8BE,iCAAiCL;;;;;;;;;;;;;;;;YAgB9DM;;;;;;kCAMoBN;;;;;;;;;;;;;;oCAcEA;;;;;;;;;;;;;;wCAcIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CA0CEA;;;;;;;;YAQ5BO;;kBAEIC,WAAWC,gBAAgBC,kBAAkBC,iBAAiBC,sBAAsBC,uBAAuBC,gBAAgBC,kBAAkBC,sBAAsBC"}
1
+ {"version":3,"file":"tools.d.ts","names":["BaseContentBlock","Tools","KNOWN_BLOCK_TYPES","TName","TArgs","Record","TOutput","ToolCall","ToolCallChunk","InvalidToolCall","ServerToolCall","ServerToolCallChunk","ServerToolCallResult"],"sources":["../../../src/messages/content/tools.d.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\nexport type Tools = never;\nexport declare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace Tools {\n /**\n * Represents a request to call a tool.\n *\n * @example\n * ```ts\n * const toolCall: ToolCall = {\n * type: \"tool_call\",\n * name: \"foo\",\n * args: { a: 1 },\n * callId: \"123\"\n * };\n * ```\n * This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n * and an identifier of \"123\".\n */\n interface ToolCall<TName extends string = string, TArgs = unknown> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call\";\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 /** Content block to represent partial data of a tool call */\n interface ToolCallChunk<TName extends string = string> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call_chunk\";\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 * The index of the tool call chunk\n */\n index?: number;\n }\n /** Content block to represent an invalid tool call */\n interface InvalidToolCall<TName extends string = string> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"invalid_tool_call\";\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 interface ServerToolCall<TName extends string = string, TArgs = unknown> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call\";\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 interface ServerToolCallChunk<TName extends string = string> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_chunk\";\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 interface ServerToolCallResult<TOutput = Record<string, unknown>> extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_result\";\n /**\n * The unique identifier of the tool call that this result corresponds to\n */\n toolCallId: string;\n /**\n * The status of the server tool call\n */\n status: \"success\" | \"error\";\n /**\n * The output of the server tool call\n */\n output: TOutput;\n }\n type Standard = ToolCall | ToolCallChunk | InvalidToolCall | ServerToolCall | ServerToolCallChunk | ServerToolCallResult;\n}\n"],"mappings":";;;KACYC,KAAAA;AAAZ;AAGyBA,kBAAAA,KAAAA,CAAK;EAAA;;;;;;;;;;;;;;;EAoHP,UAhBuDD,QAAAA,CAAAA,cAAAA,MAAAA,GAAAA,MAAAA,EAAAA,QAAAA,OAAAA,CAAAA,SApFCA,gBAoFDA,CAAAA;IAkB1DO;;;IAA6CG,SAAAA,IAAAA,EAAAA,WAAAA;IAAiBC;;AAA0C;UA9F9GR;;;;UAIAC;;;iEAGqDJ;;;;;;;;WAQpDG;;;;;;;;;;;mEAWsDH;;;;;;;;WAQtDG;;;;;;;;;;;;;;mFAcsEH;;;;;;;;UAQvEG;;;;UAIAC;;uEAE2DJ;;;;;;;;WAQ1DG;;;;;;2CAM8BE,iCAAiCL;;;;;;;;;;;;;;;;YAgB9DM;;kBAEIC,WAAWC,gBAAgBC,kBAAkBC,iBAAiBC,sBAAsBC"}
@@ -5,11 +5,7 @@ const KNOWN_BLOCK_TYPES = [
5
5
  "invalid_tool_call",
6
6
  "server_tool_call",
7
7
  "server_tool_call_chunk",
8
- "server_tool_call_result",
9
- "web_search_call",
10
- "web_search_result",
11
- "code_interpreter",
12
- "code_interpreter_result"
8
+ "server_tool_call_result"
13
9
  ];
14
10
 
15
11
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"tools.js","names":[],"sources":["../../../src/messages/content/tools.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\n\nexport type Tools = never;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"tool_call\",\n \"tool_call_chunk\",\n \"invalid_tool_call\",\n \"server_tool_call\",\n \"server_tool_call_chunk\",\n \"server_tool_call_result\",\n \"web_search_call\",\n \"web_search_result\",\n \"code_interpreter\",\n \"code_interpreter_result\",\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace Tools {\n /**\n * Represents a request to call a tool.\n *\n * @example\n * ```ts\n * const toolCall: ToolCall = {\n * type: \"tool_call\",\n * name: \"foo\",\n * args: { a: 1 },\n * callId: \"123\"\n * };\n * ```\n * This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n * and an identifier of \"123\".\n */\n export interface ToolCall<TName extends string = string, TArgs = unknown>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call\";\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 /** Content block to represent partial data of a tool call */\n export interface ToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call_chunk\";\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 * The index of the tool call chunk\n */\n index?: number;\n }\n\n /** Content block to represent an invalid tool call */\n export interface InvalidToolCall<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"invalid_tool_call\";\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\n export interface ServerToolCall<\n TName extends string = string,\n TArgs = unknown\n > extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call\";\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 export interface ServerToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_chunk\";\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\n export interface ServerToolCallResult<TOutput = Record<string, unknown>>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_result\";\n /**\n * The unique identifier of the tool call that this result corresponds to\n */\n toolCallId: string;\n /**\n * The status of the server tool call\n */\n status: \"success\" | \"error\";\n /**\n * The output of the server tool call\n */\n output: TOutput;\n }\n\n /**\n * Content block for a built-in web search tool call.\n * @deprecated Use ServerToolCall instead\n */\n export interface WebSearchCall extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"web_search_call\";\n /**\n * The search query used in the web search tool call\n */\n query?: string;\n }\n\n /**\n * Content block for the result of a built-in search tool call\n * @deprecated Use ServerToolCallResult instead\n */\n export interface WebSearchResult extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"web_search_result\";\n /**\n * List of URLs returned by the web search tool call\n */\n urls?: string[];\n }\n\n /**\n * Content block for a built-in code interpreter tool call.\n * @deprecated Use ServerToolCall instead\n */\n export interface CodeInterpreterCall extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"code_interpreter_call\";\n /**\n * The language of the code executed by the code interpreter tool call\n */\n language?: string;\n /**\n * The code to be executed by the code interpreter\n */\n code?: string;\n }\n\n /**\n * Content block for the output of a singular code interpreter tool call\n * @deprecated Use ServerToolCallResult instead\n */\n export interface CodeInterpreterOutput {\n readonly type: \"code_interpreter_output\";\n /**\n * The return code of the code interpreter tool call\n * Example: 0 for success, non-zero for failure\n */\n returnCode?: number;\n /**\n * Standard error output of the executed code\n */\n stderr?: string;\n /**\n * Standard output of the executed code\n */\n stdout?: string;\n /**\n * File IDs of the files created by the code interpreter tool call\n */\n fileIds?: string[];\n }\n\n /**\n * Content block for the result of a code interpreter tool call\n * @deprecated Use ServerToolCallResult instead\n */\n export interface CodeInterpreterResult extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"code_interpreter_result\";\n /**\n * The result of the code interpreter tool call\n */\n output: CodeInterpreterOutput[];\n }\n\n export type Standard =\n | ToolCall\n | ToolCallChunk\n | InvalidToolCall\n | ServerToolCall\n | ServerToolCallChunk\n | ServerToolCallResult\n | WebSearchCall\n | WebSearchResult\n | CodeInterpreterCall\n | CodeInterpreterResult;\n}\n"],"mappings":";AAIA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD"}
1
+ {"version":3,"file":"tools.js","names":[],"sources":["../../../src/messages/content/tools.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\n\nexport type Tools = never;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"tool_call\",\n \"tool_call_chunk\",\n \"invalid_tool_call\",\n \"server_tool_call\",\n \"server_tool_call_chunk\",\n \"server_tool_call_result\",\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace Tools {\n /**\n * Represents a request to call a tool.\n *\n * @example\n * ```ts\n * const toolCall: ToolCall = {\n * type: \"tool_call\",\n * name: \"foo\",\n * args: { a: 1 },\n * callId: \"123\"\n * };\n * ```\n * This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n * and an identifier of \"123\".\n */\n export interface ToolCall<TName extends string = string, TArgs = unknown>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call\";\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 /** Content block to represent partial data of a tool call */\n export interface ToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call_chunk\";\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 * The index of the tool call chunk\n */\n index?: number;\n }\n\n /** Content block to represent an invalid tool call */\n export interface InvalidToolCall<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"invalid_tool_call\";\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\n export interface ServerToolCall<\n TName extends string = string,\n TArgs = unknown\n > extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call\";\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 export interface ServerToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_chunk\";\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\n export interface ServerToolCallResult<TOutput = Record<string, unknown>>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_result\";\n /**\n * The unique identifier of the tool call that this result corresponds to\n */\n toolCallId: string;\n /**\n * The status of the server tool call\n */\n status: \"success\" | \"error\";\n /**\n * The output of the server tool call\n */\n output: TOutput;\n }\n\n export type Standard =\n | ToolCall\n | ToolCallChunk\n | InvalidToolCall\n | ServerToolCall\n | ServerToolCallChunk\n | ServerToolCallResult;\n}\n"],"mappings":";AAIA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.cjs","names":["a?: ResponseMetadata","b?: ResponseMetadata","output: ResponseMetadata","_mergeDicts","a?: ModalitiesTokenDetails","b?: ModalitiesTokenDetails","output: ModalitiesTokenDetails","a?: InputTokenDetails","b?: InputTokenDetails","output: InputTokenDetails","a?: OutputTokenDetails","b?: OutputTokenDetails","output: OutputTokenDetails","a?: UsageMetadata","b?: UsageMetadata"],"sources":["../../src/messages/metadata.ts"],"sourcesContent":["import { _mergeDicts } from \"./base.js\";\n\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n [key: string]: unknown;\n};\n\nexport function mergeResponseMetadata(\n a?: ResponseMetadata,\n b?: ResponseMetadata\n): ResponseMetadata {\n const output: ResponseMetadata = _mergeDicts(a ?? {}, b ?? {});\n return output;\n}\n\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n\n /**\n * Audio tokens.\n */\n audio?: number;\n\n /**\n * Video tokens.\n */\n video?: number;\n\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n\nfunction mergeModalitiesTokenDetails(\n a?: ModalitiesTokenDetails,\n b?: ModalitiesTokenDetails\n): ModalitiesTokenDetails {\n const output: ModalitiesTokenDetails = {};\n if (a?.audio !== undefined || b?.audio !== undefined) {\n output.audio = (a?.audio ?? 0) + (b?.audio ?? 0);\n }\n if (a?.image !== undefined || b?.image !== undefined) {\n output.image = (a?.image ?? 0) + (b?.image ?? 0);\n }\n if (a?.video !== undefined || b?.video !== undefined) {\n output.video = (a?.video ?? 0) + (b?.video ?? 0);\n }\n if (a?.document !== undefined || b?.document !== undefined) {\n output.document = (a?.document ?? 0) + (b?.document ?? 0);\n }\n if (a?.text !== undefined || b?.text !== undefined) {\n output.text = (a?.text ?? 0) + (b?.text ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n\nfunction mergeInputTokenDetails(\n a?: InputTokenDetails,\n b?: InputTokenDetails\n): InputTokenDetails {\n const output: InputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.cache_read !== undefined || b?.cache_read !== undefined) {\n output.cache_read = (a?.cache_read ?? 0) + (b?.cache_read ?? 0);\n }\n if (a?.cache_creation !== undefined || b?.cache_creation !== undefined) {\n output.cache_creation = (a?.cache_creation ?? 0) + (b?.cache_creation ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n\nfunction mergeOutputTokenDetails(\n a?: OutputTokenDetails,\n b?: OutputTokenDetails\n): OutputTokenDetails {\n const output: OutputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.reasoning !== undefined || b?.reasoning !== undefined) {\n output.reasoning = (a?.reasoning ?? 0) + (b?.reasoning ?? 0);\n }\n return output;\n}\n\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\n\nexport function mergeUsageMetadata(\n a?: UsageMetadata,\n b?: UsageMetadata\n): UsageMetadata {\n return {\n input_tokens: (a?.input_tokens ?? 0) + (b?.input_tokens ?? 0),\n output_tokens: (a?.output_tokens ?? 0) + (b?.output_tokens ?? 0),\n total_tokens: (a?.total_tokens ?? 0) + (b?.total_tokens ?? 0),\n input_token_details: mergeInputTokenDetails(\n a?.input_token_details,\n b?.input_token_details\n ),\n output_token_details: mergeOutputTokenDetails(\n a?.output_token_details,\n b?.output_token_details\n ),\n };\n}\n"],"mappings":";;;AAQA,SAAgB,sBACdA,GACAC,GACkB;CAClB,MAAMC,SAA2BC,yBAAY,KAAK,CAAE,GAAE,KAAK,CAAE,EAAC;AAC9D,QAAO;AACR;AA+BD,SAAS,4BACPC,GACAC,GACwB;CACxB,MAAMC,SAAiC,CAAE;AACzC,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,aAAa,UAAa,GAAG,aAAa,QAC/C,OAAO,YAAY,GAAG,YAAY,MAAM,GAAG,YAAY;AAEzD,KAAI,GAAG,SAAS,UAAa,GAAG,SAAS,QACvC,OAAO,QAAQ,GAAG,QAAQ,MAAM,GAAG,QAAQ;AAE7C,QAAO;AACR;AAwBD,SAAS,uBACPC,GACAC,GACmB;CACnB,MAAMC,SAA4B,EAChC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,eAAe,UAAa,GAAG,eAAe,QACnD,OAAO,cAAc,GAAG,cAAc,MAAM,GAAG,cAAc;AAE/D,KAAI,GAAG,mBAAmB,UAAa,GAAG,mBAAmB,QAC3D,OAAO,kBAAkB,GAAG,kBAAkB,MAAM,GAAG,kBAAkB;AAE3E,QAAO;AACR;AAiBD,SAAS,wBACPC,GACAC,GACoB;CACpB,MAAMC,SAA6B,EACjC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,cAAc,UAAa,GAAG,cAAc,QACjD,OAAO,aAAa,GAAG,aAAa,MAAM,GAAG,aAAa;AAE5D,QAAO;AACR;AAkCD,SAAgB,mBACdC,GACAC,GACe;AACf,QAAO;EACL,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,gBAAgB,GAAG,iBAAiB,MAAM,GAAG,iBAAiB;EAC9D,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,qBAAqB,uBACnB,GAAG,qBACH,GAAG,oBACJ;EACD,sBAAsB,wBACpB,GAAG,sBACH,GAAG,qBACJ;CACF;AACF"}
1
+ {"version":3,"file":"metadata.cjs","names":["a?: ResponseMetadata","b?: ResponseMetadata","output: ResponseMetadata","_mergeDicts","a?: ModalitiesTokenDetails","b?: ModalitiesTokenDetails","output: ModalitiesTokenDetails","a?: InputTokenDetails","b?: InputTokenDetails","output: InputTokenDetails","a?: OutputTokenDetails","b?: OutputTokenDetails","output: OutputTokenDetails","a?: UsageMetadata","b?: UsageMetadata"],"sources":["../../src/messages/metadata.ts"],"sourcesContent":["import { _mergeDicts } from \"./base.js\";\nimport type { MessageOutputVersion } from \"./message.js\";\n\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n output_version?: MessageOutputVersion;\n [key: string]: unknown;\n};\n\nexport function mergeResponseMetadata(\n a?: ResponseMetadata,\n b?: ResponseMetadata\n): ResponseMetadata {\n const output: ResponseMetadata = _mergeDicts(a ?? {}, b ?? {});\n return output;\n}\n\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n\n /**\n * Audio tokens.\n */\n audio?: number;\n\n /**\n * Video tokens.\n */\n video?: number;\n\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n\nfunction mergeModalitiesTokenDetails(\n a?: ModalitiesTokenDetails,\n b?: ModalitiesTokenDetails\n): ModalitiesTokenDetails {\n const output: ModalitiesTokenDetails = {};\n if (a?.audio !== undefined || b?.audio !== undefined) {\n output.audio = (a?.audio ?? 0) + (b?.audio ?? 0);\n }\n if (a?.image !== undefined || b?.image !== undefined) {\n output.image = (a?.image ?? 0) + (b?.image ?? 0);\n }\n if (a?.video !== undefined || b?.video !== undefined) {\n output.video = (a?.video ?? 0) + (b?.video ?? 0);\n }\n if (a?.document !== undefined || b?.document !== undefined) {\n output.document = (a?.document ?? 0) + (b?.document ?? 0);\n }\n if (a?.text !== undefined || b?.text !== undefined) {\n output.text = (a?.text ?? 0) + (b?.text ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n\nfunction mergeInputTokenDetails(\n a?: InputTokenDetails,\n b?: InputTokenDetails\n): InputTokenDetails {\n const output: InputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.cache_read !== undefined || b?.cache_read !== undefined) {\n output.cache_read = (a?.cache_read ?? 0) + (b?.cache_read ?? 0);\n }\n if (a?.cache_creation !== undefined || b?.cache_creation !== undefined) {\n output.cache_creation = (a?.cache_creation ?? 0) + (b?.cache_creation ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n\nfunction mergeOutputTokenDetails(\n a?: OutputTokenDetails,\n b?: OutputTokenDetails\n): OutputTokenDetails {\n const output: OutputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.reasoning !== undefined || b?.reasoning !== undefined) {\n output.reasoning = (a?.reasoning ?? 0) + (b?.reasoning ?? 0);\n }\n return output;\n}\n\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\n\nexport function mergeUsageMetadata(\n a?: UsageMetadata,\n b?: UsageMetadata\n): UsageMetadata {\n return {\n input_tokens: (a?.input_tokens ?? 0) + (b?.input_tokens ?? 0),\n output_tokens: (a?.output_tokens ?? 0) + (b?.output_tokens ?? 0),\n total_tokens: (a?.total_tokens ?? 0) + (b?.total_tokens ?? 0),\n input_token_details: mergeInputTokenDetails(\n a?.input_token_details,\n b?.input_token_details\n ),\n output_token_details: mergeOutputTokenDetails(\n a?.output_token_details,\n b?.output_token_details\n ),\n };\n}\n"],"mappings":";;;AAUA,SAAgB,sBACdA,GACAC,GACkB;CAClB,MAAMC,SAA2BC,yBAAY,KAAK,CAAE,GAAE,KAAK,CAAE,EAAC;AAC9D,QAAO;AACR;AA+BD,SAAS,4BACPC,GACAC,GACwB;CACxB,MAAMC,SAAiC,CAAE;AACzC,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,aAAa,UAAa,GAAG,aAAa,QAC/C,OAAO,YAAY,GAAG,YAAY,MAAM,GAAG,YAAY;AAEzD,KAAI,GAAG,SAAS,UAAa,GAAG,SAAS,QACvC,OAAO,QAAQ,GAAG,QAAQ,MAAM,GAAG,QAAQ;AAE7C,QAAO;AACR;AAwBD,SAAS,uBACPC,GACAC,GACmB;CACnB,MAAMC,SAA4B,EAChC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,eAAe,UAAa,GAAG,eAAe,QACnD,OAAO,cAAc,GAAG,cAAc,MAAM,GAAG,cAAc;AAE/D,KAAI,GAAG,mBAAmB,UAAa,GAAG,mBAAmB,QAC3D,OAAO,kBAAkB,GAAG,kBAAkB,MAAM,GAAG,kBAAkB;AAE3E,QAAO;AACR;AAiBD,SAAS,wBACPC,GACAC,GACoB;CACpB,MAAMC,SAA6B,EACjC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,cAAc,UAAa,GAAG,cAAc,QACjD,OAAO,aAAa,GAAG,aAAa,MAAM,GAAG,aAAa;AAE5D,QAAO;AACR;AAkCD,SAAgB,mBACdC,GACAC,GACe;AACf,QAAO;EACL,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,gBAAgB,GAAG,iBAAiB,MAAM,GAAG,iBAAiB;EAC9D,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,qBAAqB,uBACnB,GAAG,qBACH,GAAG,oBACJ;EACD,sBAAsB,wBACpB,GAAG,sBACH,GAAG,qBACJ;CACF;AACF"}
@@ -1,7 +1,10 @@
1
+ import { MessageOutputVersion } from "./message.cjs";
2
+
1
3
  //#region src/messages/metadata.d.ts
2
4
  type ResponseMetadata = {
3
5
  model_provider?: string;
4
6
  model_name?: string;
7
+ output_version?: MessageOutputVersion;
5
8
  [key: string]: unknown;
6
9
  };
7
10
  declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.cts","names":["ResponseMetadata","mergeResponseMetadata","ModalitiesTokenDetails","InputTokenDetails","OutputTokenDetails","UsageMetadata","mergeUsageMetadata"],"sources":["../../src/messages/metadata.d.ts"],"sourcesContent":["export type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n [key: string]: unknown;\n};\nexport declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n /**\n * Audio tokens.\n */\n audio?: number;\n /**\n * Video tokens.\n */\n video?: number;\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\nexport declare function mergeUsageMetadata(a?: UsageMetadata, b?: UsageMetadata): UsageMetadata;\n"],"mappings":";KAAYA,gBAAAA;EAAAA,cAAAA,CAAAA,EAAAA,MAAgB;EAKJC,UAAAA,CAAAA,EAAAA,MAAAA;EAAqB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;CAAA;AAA2BD,iBAAhDC,qBAAAA,CAAgDD,CAAAA,CAAAA,EAAtBA,gBAAsBA,EAAAA,CAAAA,CAAAA,EAAAA,gBAAAA,CAAAA,EAAmBA,gBAAnBA;AAAmBA,KAC/EE,sBAAAA,GAD+EF;EAAgB;AAC3G;AA6BA;AAoBA;EAYYK,IAAAA,CAAAA,EAAAA,MAAAA;EAAa;;;EAwBoB,KAAA,CAAA,EAAA,MAAA;EAErBC;;;EAAoC,KAAMD,CAAAA,EAAAA,MAAAA;EAAa;AAAgB;;;;;;;;;;;;;;KA1DnFF,iBAAAA,GAAoBD;;;;;;;;;;;;;;;;;;;;KAoBpBE,kBAAAA,GAAqBF;;;;;;;;;;;;KAYrBG,aAAAA;;;;;;;;;;;;;;;;;;wBAkBcF;;;;;;yBAMCC;;iBAEHE,kBAAAA,KAAuBD,mBAAmBA,gBAAgBA"}
1
+ {"version":3,"file":"metadata.d.cts","names":["MessageOutputVersion","ResponseMetadata","mergeResponseMetadata","ModalitiesTokenDetails","InputTokenDetails","OutputTokenDetails","UsageMetadata","mergeUsageMetadata"],"sources":["../../src/messages/metadata.d.ts"],"sourcesContent":["import type { MessageOutputVersion } from \"./message.js\";\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n output_version?: MessageOutputVersion;\n [key: string]: unknown;\n};\nexport declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n /**\n * Audio tokens.\n */\n audio?: number;\n /**\n * Video tokens.\n */\n video?: number;\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\nexport declare function mergeUsageMetadata(a?: UsageMetadata, b?: UsageMetadata): UsageMetadata;\n"],"mappings":";;;KACYC,gBAAAA;;EAAAA,UAAAA,CAAAA,EAAAA,MAAgB;EAMJC,cAAAA,CAAAA,EAHHF,oBAGwB;EAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;CAAA;AAA2BC,iBAAhDC,qBAAAA,CAAgDD,CAAAA,CAAAA,EAAtBA,gBAAsBA,EAAAA,CAAAA,CAAAA,EAAAA,gBAAAA,CAAAA,EAAmBA,gBAAnBA;AAAmBA,KAC/EE,sBAAAA,GAD+EF;EAAgB;AAC3G;AA6BA;AAoBA;EAYYK,IAAAA,CAAAA,EAAAA,MAAAA;EAAa;;;EAwBoB,KAAA,CAAA,EAAA,MAAA;EAErBC;;;EAAoC,KAAMD,CAAAA,EAAAA,MAAAA;EAAa;AAAgB;;;;;;;;;;;;;;KA1DnFF,iBAAAA,GAAoBD;;;;;;;;;;;;;;;;;;;;KAoBpBE,kBAAAA,GAAqBF;;;;;;;;;;;;KAYrBG,aAAAA;;;;;;;;;;;;;;;;;;wBAkBcF;;;;;;yBAMCC;;iBAEHE,kBAAAA,KAAuBD,mBAAmBA,gBAAgBA"}
@@ -1,7 +1,10 @@
1
+ import { MessageOutputVersion } from "./message.js";
2
+
1
3
  //#region src/messages/metadata.d.ts
2
4
  type ResponseMetadata = {
3
5
  model_provider?: string;
4
6
  model_name?: string;
7
+ output_version?: MessageOutputVersion;
5
8
  [key: string]: unknown;
6
9
  };
7
10
  declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.d.ts","names":["ResponseMetadata","mergeResponseMetadata","ModalitiesTokenDetails","InputTokenDetails","OutputTokenDetails","UsageMetadata","mergeUsageMetadata"],"sources":["../../src/messages/metadata.d.ts"],"sourcesContent":["export type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n [key: string]: unknown;\n};\nexport declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n /**\n * Audio tokens.\n */\n audio?: number;\n /**\n * Video tokens.\n */\n video?: number;\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\nexport declare function mergeUsageMetadata(a?: UsageMetadata, b?: UsageMetadata): UsageMetadata;\n"],"mappings":";KAAYA,gBAAAA;EAAAA,cAAAA,CAAAA,EAAAA,MAAgB;EAKJC,UAAAA,CAAAA,EAAAA,MAAAA;EAAqB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;CAAA;AAA2BD,iBAAhDC,qBAAAA,CAAgDD,CAAAA,CAAAA,EAAtBA,gBAAsBA,EAAAA,CAAAA,CAAAA,EAAAA,gBAAAA,CAAAA,EAAmBA,gBAAnBA;AAAmBA,KAC/EE,sBAAAA,GAD+EF;EAAgB;AAC3G;AA6BA;AAoBA;EAYYK,IAAAA,CAAAA,EAAAA,MAAAA;EAAa;;;EAwBoB,KAAA,CAAA,EAAA,MAAA;EAErBC;;;EAAoC,KAAMD,CAAAA,EAAAA,MAAAA;EAAa;AAAgB;;;;;;;;;;;;;;KA1DnFF,iBAAAA,GAAoBD;;;;;;;;;;;;;;;;;;;;KAoBpBE,kBAAAA,GAAqBF;;;;;;;;;;;;KAYrBG,aAAAA;;;;;;;;;;;;;;;;;;wBAkBcF;;;;;;yBAMCC;;iBAEHE,kBAAAA,KAAuBD,mBAAmBA,gBAAgBA"}
1
+ {"version":3,"file":"metadata.d.ts","names":["MessageOutputVersion","ResponseMetadata","mergeResponseMetadata","ModalitiesTokenDetails","InputTokenDetails","OutputTokenDetails","UsageMetadata","mergeUsageMetadata"],"sources":["../../src/messages/metadata.d.ts"],"sourcesContent":["import type { MessageOutputVersion } from \"./message.js\";\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n output_version?: MessageOutputVersion;\n [key: string]: unknown;\n};\nexport declare function mergeResponseMetadata(a?: ResponseMetadata, b?: ResponseMetadata): ResponseMetadata;\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n /**\n * Audio tokens.\n */\n audio?: number;\n /**\n * Video tokens.\n */\n video?: number;\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\nexport declare function mergeUsageMetadata(a?: UsageMetadata, b?: UsageMetadata): UsageMetadata;\n"],"mappings":";;;KACYC,gBAAAA;;EAAAA,UAAAA,CAAAA,EAAAA,MAAgB;EAMJC,cAAAA,CAAAA,EAHHF,oBAGwB;EAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;CAAA;AAA2BC,iBAAhDC,qBAAAA,CAAgDD,CAAAA,CAAAA,EAAtBA,gBAAsBA,EAAAA,CAAAA,CAAAA,EAAAA,gBAAAA,CAAAA,EAAmBA,gBAAnBA;AAAmBA,KAC/EE,sBAAAA,GAD+EF;EAAgB;AAC3G;AA6BA;AAoBA;EAYYK,IAAAA,CAAAA,EAAAA,MAAAA;EAAa;;;EAwBoB,KAAA,CAAA,EAAA,MAAA;EAErBC;;;EAAoC,KAAMD,CAAAA,EAAAA,MAAAA;EAAa;AAAgB;;;;;;;;;;;;;;KA1DnFF,iBAAAA,GAAoBD;;;;;;;;;;;;;;;;;;;;KAoBpBE,kBAAAA,GAAqBF;;;;;;;;;;;;KAYrBG,aAAAA;;;;;;;;;;;;;;;;;;wBAkBcF;;;;;;yBAMCC;;iBAEHE,kBAAAA,KAAuBD,mBAAmBA,gBAAgBA"}
@@ -1 +1 @@
1
- {"version":3,"file":"metadata.js","names":["a?: ResponseMetadata","b?: ResponseMetadata","output: ResponseMetadata","a?: ModalitiesTokenDetails","b?: ModalitiesTokenDetails","output: ModalitiesTokenDetails","a?: InputTokenDetails","b?: InputTokenDetails","output: InputTokenDetails","a?: OutputTokenDetails","b?: OutputTokenDetails","output: OutputTokenDetails","a?: UsageMetadata","b?: UsageMetadata"],"sources":["../../src/messages/metadata.ts"],"sourcesContent":["import { _mergeDicts } from \"./base.js\";\n\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n [key: string]: unknown;\n};\n\nexport function mergeResponseMetadata(\n a?: ResponseMetadata,\n b?: ResponseMetadata\n): ResponseMetadata {\n const output: ResponseMetadata = _mergeDicts(a ?? {}, b ?? {});\n return output;\n}\n\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n\n /**\n * Audio tokens.\n */\n audio?: number;\n\n /**\n * Video tokens.\n */\n video?: number;\n\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n\nfunction mergeModalitiesTokenDetails(\n a?: ModalitiesTokenDetails,\n b?: ModalitiesTokenDetails\n): ModalitiesTokenDetails {\n const output: ModalitiesTokenDetails = {};\n if (a?.audio !== undefined || b?.audio !== undefined) {\n output.audio = (a?.audio ?? 0) + (b?.audio ?? 0);\n }\n if (a?.image !== undefined || b?.image !== undefined) {\n output.image = (a?.image ?? 0) + (b?.image ?? 0);\n }\n if (a?.video !== undefined || b?.video !== undefined) {\n output.video = (a?.video ?? 0) + (b?.video ?? 0);\n }\n if (a?.document !== undefined || b?.document !== undefined) {\n output.document = (a?.document ?? 0) + (b?.document ?? 0);\n }\n if (a?.text !== undefined || b?.text !== undefined) {\n output.text = (a?.text ?? 0) + (b?.text ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n\nfunction mergeInputTokenDetails(\n a?: InputTokenDetails,\n b?: InputTokenDetails\n): InputTokenDetails {\n const output: InputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.cache_read !== undefined || b?.cache_read !== undefined) {\n output.cache_read = (a?.cache_read ?? 0) + (b?.cache_read ?? 0);\n }\n if (a?.cache_creation !== undefined || b?.cache_creation !== undefined) {\n output.cache_creation = (a?.cache_creation ?? 0) + (b?.cache_creation ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n\nfunction mergeOutputTokenDetails(\n a?: OutputTokenDetails,\n b?: OutputTokenDetails\n): OutputTokenDetails {\n const output: OutputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.reasoning !== undefined || b?.reasoning !== undefined) {\n output.reasoning = (a?.reasoning ?? 0) + (b?.reasoning ?? 0);\n }\n return output;\n}\n\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\n\nexport function mergeUsageMetadata(\n a?: UsageMetadata,\n b?: UsageMetadata\n): UsageMetadata {\n return {\n input_tokens: (a?.input_tokens ?? 0) + (b?.input_tokens ?? 0),\n output_tokens: (a?.output_tokens ?? 0) + (b?.output_tokens ?? 0),\n total_tokens: (a?.total_tokens ?? 0) + (b?.total_tokens ?? 0),\n input_token_details: mergeInputTokenDetails(\n a?.input_token_details,\n b?.input_token_details\n ),\n output_token_details: mergeOutputTokenDetails(\n a?.output_token_details,\n b?.output_token_details\n ),\n };\n}\n"],"mappings":";;;AAQA,SAAgB,sBACdA,GACAC,GACkB;CAClB,MAAMC,SAA2B,YAAY,KAAK,CAAE,GAAE,KAAK,CAAE,EAAC;AAC9D,QAAO;AACR;AA+BD,SAAS,4BACPC,GACAC,GACwB;CACxB,MAAMC,SAAiC,CAAE;AACzC,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,aAAa,UAAa,GAAG,aAAa,QAC/C,OAAO,YAAY,GAAG,YAAY,MAAM,GAAG,YAAY;AAEzD,KAAI,GAAG,SAAS,UAAa,GAAG,SAAS,QACvC,OAAO,QAAQ,GAAG,QAAQ,MAAM,GAAG,QAAQ;AAE7C,QAAO;AACR;AAwBD,SAAS,uBACPC,GACAC,GACmB;CACnB,MAAMC,SAA4B,EAChC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,eAAe,UAAa,GAAG,eAAe,QACnD,OAAO,cAAc,GAAG,cAAc,MAAM,GAAG,cAAc;AAE/D,KAAI,GAAG,mBAAmB,UAAa,GAAG,mBAAmB,QAC3D,OAAO,kBAAkB,GAAG,kBAAkB,MAAM,GAAG,kBAAkB;AAE3E,QAAO;AACR;AAiBD,SAAS,wBACPC,GACAC,GACoB;CACpB,MAAMC,SAA6B,EACjC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,cAAc,UAAa,GAAG,cAAc,QACjD,OAAO,aAAa,GAAG,aAAa,MAAM,GAAG,aAAa;AAE5D,QAAO;AACR;AAkCD,SAAgB,mBACdC,GACAC,GACe;AACf,QAAO;EACL,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,gBAAgB,GAAG,iBAAiB,MAAM,GAAG,iBAAiB;EAC9D,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,qBAAqB,uBACnB,GAAG,qBACH,GAAG,oBACJ;EACD,sBAAsB,wBACpB,GAAG,sBACH,GAAG,qBACJ;CACF;AACF"}
1
+ {"version":3,"file":"metadata.js","names":["a?: ResponseMetadata","b?: ResponseMetadata","output: ResponseMetadata","a?: ModalitiesTokenDetails","b?: ModalitiesTokenDetails","output: ModalitiesTokenDetails","a?: InputTokenDetails","b?: InputTokenDetails","output: InputTokenDetails","a?: OutputTokenDetails","b?: OutputTokenDetails","output: OutputTokenDetails","a?: UsageMetadata","b?: UsageMetadata"],"sources":["../../src/messages/metadata.ts"],"sourcesContent":["import { _mergeDicts } from \"./base.js\";\nimport type { MessageOutputVersion } from \"./message.js\";\n\nexport type ResponseMetadata = {\n model_provider?: string;\n model_name?: string;\n output_version?: MessageOutputVersion;\n [key: string]: unknown;\n};\n\nexport function mergeResponseMetadata(\n a?: ResponseMetadata,\n b?: ResponseMetadata\n): ResponseMetadata {\n const output: ResponseMetadata = _mergeDicts(a ?? {}, b ?? {});\n return output;\n}\n\nexport type ModalitiesTokenDetails = {\n /**\n * Text tokens.\n * Does not need to be reported, but some models will do so.\n */\n text?: number;\n\n /**\n * Image (non-video) tokens.\n */\n image?: number;\n\n /**\n * Audio tokens.\n */\n audio?: number;\n\n /**\n * Video tokens.\n */\n video?: number;\n\n /**\n * Document tokens.\n * e.g. PDF\n */\n document?: number;\n};\n\nfunction mergeModalitiesTokenDetails(\n a?: ModalitiesTokenDetails,\n b?: ModalitiesTokenDetails\n): ModalitiesTokenDetails {\n const output: ModalitiesTokenDetails = {};\n if (a?.audio !== undefined || b?.audio !== undefined) {\n output.audio = (a?.audio ?? 0) + (b?.audio ?? 0);\n }\n if (a?.image !== undefined || b?.image !== undefined) {\n output.image = (a?.image ?? 0) + (b?.image ?? 0);\n }\n if (a?.video !== undefined || b?.video !== undefined) {\n output.video = (a?.video ?? 0) + (b?.video ?? 0);\n }\n if (a?.document !== undefined || b?.document !== undefined) {\n output.document = (a?.document ?? 0) + (b?.document ?? 0);\n }\n if (a?.text !== undefined || b?.text !== undefined) {\n output.text = (a?.text ?? 0) + (b?.text ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of input token counts.\n *\n * Does not *need* to sum to full input token count. Does *not* need to have all keys.\n */\nexport type InputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Input tokens that were cached and there was a cache hit.\n *\n * Since there was a cache hit, the tokens were read from the cache.\n * More precisely, the model state given these tokens was read from the cache.\n */\n cache_read?: number;\n\n /**\n * Input tokens that were cached and there was a cache miss.\n *\n * Since there was a cache miss, the cache was created from these tokens.\n */\n cache_creation?: number;\n};\n\nfunction mergeInputTokenDetails(\n a?: InputTokenDetails,\n b?: InputTokenDetails\n): InputTokenDetails {\n const output: InputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.cache_read !== undefined || b?.cache_read !== undefined) {\n output.cache_read = (a?.cache_read ?? 0) + (b?.cache_read ?? 0);\n }\n if (a?.cache_creation !== undefined || b?.cache_creation !== undefined) {\n output.cache_creation = (a?.cache_creation ?? 0) + (b?.cache_creation ?? 0);\n }\n return output;\n}\n\n/**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\nexport type OutputTokenDetails = ModalitiesTokenDetails & {\n /**\n * Reasoning output tokens.\n *\n * Tokens generated by the model in a chain of thought process (i.e. by\n * OpenAI's o1 models) that are not returned as part of model output.\n */\n reasoning?: number;\n};\n\nfunction mergeOutputTokenDetails(\n a?: OutputTokenDetails,\n b?: OutputTokenDetails\n): OutputTokenDetails {\n const output: OutputTokenDetails = {\n ...mergeModalitiesTokenDetails(a, b),\n };\n if (a?.reasoning !== undefined || b?.reasoning !== undefined) {\n output.reasoning = (a?.reasoning ?? 0) + (b?.reasoning ?? 0);\n }\n return output;\n}\n\n/**\n * Usage metadata for a message, such as token counts.\n */\nexport type UsageMetadata = {\n /**\n * Count of input (or prompt) tokens. Sum of all input token types.\n */\n input_tokens: number;\n /**\n * Count of output (or completion) tokens. Sum of all output token types.\n */\n output_tokens: number;\n /**\n * Total token count. Sum of input_tokens + output_tokens.\n */\n total_tokens: number;\n\n /**\n * Breakdown of input token counts.\n *\n * Does *not* need to sum to full input token count. Does *not* need to have all keys.\n */\n input_token_details?: InputTokenDetails;\n\n /**\n * Breakdown of output token counts.\n *\n * Does *not* need to sum to full output token count. Does *not* need to have all keys.\n */\n output_token_details?: OutputTokenDetails;\n};\n\nexport function mergeUsageMetadata(\n a?: UsageMetadata,\n b?: UsageMetadata\n): UsageMetadata {\n return {\n input_tokens: (a?.input_tokens ?? 0) + (b?.input_tokens ?? 0),\n output_tokens: (a?.output_tokens ?? 0) + (b?.output_tokens ?? 0),\n total_tokens: (a?.total_tokens ?? 0) + (b?.total_tokens ?? 0),\n input_token_details: mergeInputTokenDetails(\n a?.input_token_details,\n b?.input_token_details\n ),\n output_token_details: mergeOutputTokenDetails(\n a?.output_token_details,\n b?.output_token_details\n ),\n };\n}\n"],"mappings":";;;AAUA,SAAgB,sBACdA,GACAC,GACkB;CAClB,MAAMC,SAA2B,YAAY,KAAK,CAAE,GAAE,KAAK,CAAE,EAAC;AAC9D,QAAO;AACR;AA+BD,SAAS,4BACPC,GACAC,GACwB;CACxB,MAAMC,SAAiC,CAAE;AACzC,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,UAAU,UAAa,GAAG,UAAU,QACzC,OAAO,SAAS,GAAG,SAAS,MAAM,GAAG,SAAS;AAEhD,KAAI,GAAG,aAAa,UAAa,GAAG,aAAa,QAC/C,OAAO,YAAY,GAAG,YAAY,MAAM,GAAG,YAAY;AAEzD,KAAI,GAAG,SAAS,UAAa,GAAG,SAAS,QACvC,OAAO,QAAQ,GAAG,QAAQ,MAAM,GAAG,QAAQ;AAE7C,QAAO;AACR;AAwBD,SAAS,uBACPC,GACAC,GACmB;CACnB,MAAMC,SAA4B,EAChC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,eAAe,UAAa,GAAG,eAAe,QACnD,OAAO,cAAc,GAAG,cAAc,MAAM,GAAG,cAAc;AAE/D,KAAI,GAAG,mBAAmB,UAAa,GAAG,mBAAmB,QAC3D,OAAO,kBAAkB,GAAG,kBAAkB,MAAM,GAAG,kBAAkB;AAE3E,QAAO;AACR;AAiBD,SAAS,wBACPC,GACAC,GACoB;CACpB,MAAMC,SAA6B,EACjC,GAAG,4BAA4B,GAAG,EAAE,CACrC;AACD,KAAI,GAAG,cAAc,UAAa,GAAG,cAAc,QACjD,OAAO,aAAa,GAAG,aAAa,MAAM,GAAG,aAAa;AAE5D,QAAO;AACR;AAkCD,SAAgB,mBACdC,GACAC,GACe;AACf,QAAO;EACL,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,gBAAgB,GAAG,iBAAiB,MAAM,GAAG,iBAAiB;EAC9D,eAAe,GAAG,gBAAgB,MAAM,GAAG,gBAAgB;EAC3D,qBAAqB,uBACnB,GAAG,qBACH,GAAG,oBACJ;EACD,sBAAsB,wBACpB,GAAG,sBACH,GAAG,qBACJ;CACF;AACF"}
@@ -32,6 +32,7 @@ var ToolMessage = class extends require_base.BaseMessage {
32
32
  */
33
33
  status;
34
34
  tool_call_id;
35
+ metadata;
35
36
  /**
36
37
  * Artifact of the Tool execution which is not meant to be sent to the model.
37
38
  *
@@ -50,6 +51,7 @@ var ToolMessage = class extends require_base.BaseMessage {
50
51
  this.tool_call_id = toolMessageFields.tool_call_id;
51
52
  this.artifact = toolMessageFields.artifact;
52
53
  this.status = toolMessageFields.status;
54
+ this.metadata = toolMessageFields.metadata;
53
55
  }
54
56
  static isInstance(message) {
55
57
  return super.isInstance(message) && message.type === "tool";
@@ -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}\n\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\n\nexport function isDirectToolOutput(x: unknown): x is DirectToolOutput {\n return (\n x != null &&\n typeof x === \"object\" &&\n \"lc_direct_tool_output\" in x &&\n x.lc_direct_tool_output === true\n );\n}\n\n/**\n * Represents a tool message in a conversation.\n */\nexport class ToolMessage<TStructure extends MessageStructure = MessageStructure>\n extends BaseMessage<TStructure, \"tool\">\n implements DirectToolOutput\n{\n static lc_name() {\n return \"ToolMessage\";\n }\n\n get lc_aliases(): Record<string, string> {\n // exclude snake case conversion to pascal case\n return { tool_call_id: \"tool_call_id\" };\n }\n\n lc_direct_tool_output = true as const;\n\n readonly type = \"tool\" as const;\n\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n\n tool_call_id: string;\n\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n\n constructor(\n fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields,\n tool_call_id: string,\n name?: string\n );\n\n constructor(fields: ToolMessageFields<TStructure>);\n\n constructor(\n fields:\n | $InferMessageContent<TStructure, \"tool\">\n | ToolMessageFields<TStructure>,\n tool_call_id?: string,\n name?: string\n ) {\n const toolMessageFields: ToolMessageFields<TStructure> =\n typeof fields === \"string\" || Array.isArray(fields)\n ? { content: fields, name, tool_call_id: tool_call_id! }\n : fields;\n super(toolMessageFields);\n this.tool_call_id = toolMessageFields.tool_call_id;\n this.artifact = toolMessageFields.artifact;\n this.status = toolMessageFields.status;\n }\n\n static isInstance(message: unknown): message is ToolMessage {\n return super.isInstance(message) && message.type === \"tool\";\n }\n\n override get _printableFields(): Record<string, unknown> {\n return {\n ...super._printableFields,\n tool_call_id: this.tool_call_id,\n artifact: this.artifact,\n };\n }\n}\n\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport class ToolMessageChunk<\n TStructure extends MessageStructure = MessageStructure\n> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type = \"tool\" as const;\n\n tool_call_id: string;\n\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n\n constructor(fields: ToolMessageFields<TStructure>) {\n super(fields);\n this.tool_call_id = fields.tool_call_id;\n this.artifact = fields.artifact;\n this.status = fields.status;\n }\n\n static lc_name() {\n return \"ToolMessageChunk\";\n }\n\n concat(chunk: ToolMessageChunk<TStructure>) {\n const Cls = this.constructor as Constructor<this>;\n return new Cls({\n content: mergeContent(this.content, chunk.content),\n additional_kwargs: _mergeDicts(\n this.additional_kwargs,\n chunk.additional_kwargs\n ),\n response_metadata: _mergeDicts(\n this.response_metadata,\n chunk.response_metadata\n ),\n artifact: _mergeObj(this.artifact, chunk.artifact),\n tool_call_id: this.tool_call_id,\n id: this.id ?? chunk.id,\n status: _mergeStatus(this.status, chunk.status),\n });\n }\n\n override get _printableFields(): Record<string, unknown> {\n return {\n ...super._printableFields,\n tool_call_id: this.tool_call_id,\n artifact: this.artifact,\n };\n }\n}\n\nexport interface ToolCall<\n TName extends string = string,\n // 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":";;;;;;;;;;;;;AAuCA,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;;;;;;;;CAUA;CAUA,YACEC,QAGAC,cACAC,MACA;EACA,MAAMC,oBACJ,OAAO,WAAW,YAAY,MAAM,QAAQ,OAAO,GAC/C;GAAE,SAAS;GAAQ;GAAoB;EAAe,IACtD;EACN,MAAM,kBAAkB;EACxB,KAAK,eAAe,kBAAkB;EACtC,KAAK,WAAW,kBAAkB;EAClC,KAAK,SAAS,kBAAkB;CACjC;CAED,OAAO,WAAWC,SAA0C;AAC1D,SAAO,MAAM,WAAW,QAAQ,IAAI,QAAQ,SAAS;CACtD;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;;;;;AAMD,IAAa,mBAAb,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"}
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;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,GAC/C;GAAE,SAAS;GAAQ;GAAoB;EAAe,IACtD;EACN,MAAM,kBAAkB;EACxB,KAAK,eAAe,kBAAkB;EACtC,KAAK,WAAW,kBAAkB;EAClC,KAAK,SAAS,kBAAkB;EAChC,KAAK,WAAW,kBAAkB;CACnC;CAED,OAAO,WAAWC,SAA0C;AAC1D,SAAO,MAAM,WAAW,QAAQ,IAAI,QAAQ,SAAS;CACtD;CAED,IAAa,mBAA4C;AACvD,SAAO;GACL,GAAG,MAAM;GACT,cAAc,KAAK;GACnB,UAAU,KAAK;EAChB;CACF;AACF;;;;;AAMD,IAAa,mBAAb,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"}
@@ -14,6 +14,7 @@ interface ToolMessageFields<TStructure extends MessageStructure = MessageStructu
14
14
  artifact?: any;
15
15
  tool_call_id: string;
16
16
  status?: "success" | "error";
17
+ metadata?: Record<string, unknown>;
17
18
  }
18
19
  /**
19
20
  * Marker parameter for objects that tools can return directly.
@@ -40,6 +41,7 @@ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure
40
41
  */
41
42
  status?: "success" | "error";
42
43
  tool_call_id: string;
44
+ metadata?: Record<string, unknown>;
43
45
  /**
44
46
  * Artifact of the Tool execution which is not meant to be sent to the model.
45
47
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.cts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","DirectToolOutput","isDirectToolOutput","ToolMessage","Record","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nTArgs 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(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH;EAoBnGC,QAAAA,CAAAA,EAAAA,GAAAA;EAGOC,YAAAA,EAAAA,MAAAA;EAIHC,MAAAA,CAAAA,EAAAA,SAAW,GAAA,OAAA;;;;;;;;;AAqBUH,UA5BzBC,gBAAAA,CA4ByBD;EAAU,SAA5BD,qBAAAA,EAAAA,IAAAA;;AAEIK,iBA3BJF,kBAAAA,CA2BIE,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BiCH,gBA2BjCG;;;AAvBgI;AA6BvIC,cA7BAF,WA6BgB,CAAA,mBA7BeL,gBA6Bf,GA7BkCA,gBA6BlC,CAAA,SA7B4DJ,WA6B5D,CA7BwEM,UA6BxE,EAAA,MAAA,CAAA,YA7BuGC,gBA6BvG,CAAA;EAAA,OAAA,OAAA,CAAA,CAAA,EAAA,MAAA;EAAA,IAAoBH,UAAAA,CAAAA,CAAAA,EA3BnCM,MA2BmCN,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAgB,qBAAGA,EAAAA,IAAAA;EAAgB,SAA2BE,IAAAA,EAAAA,MAAAA;EAAU;;;;EAmB/F,MACNI,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAM,YApBoET,EAAAA,MAAAA;EAAgB;AAsBtH;;;;;;EAee;EA+CEc,QAAAA,CAAAA,EAAAA,GAAAA;EAmBAC,WAAAA,CAAAA,MAAe,EAhHRb,oBA0HR,CA1H6BG,UA0H7B,EAAA,MAAA,CAAA,GA1HmDD,iBA0HnD,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAAA,MAAA;EAcQY,WAAAA,CAAAA,MAAAA,EAvIAZ,iBAuIqB,CAvIHC,UAuIG,CAAA;EAAA,OAAA,UAAA,CAAA,OAAA,EAAA,OAAA,CAAA,EAAA,OAAA,IAtIOG,WAsIP;EAAA,IAE/BC,gBAAAA,CAAAA,CAAAA,EAvIcA,MAuIdA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;AAAoD;AAIlE;AAIA;AAA0C,cAzIrBC,gBAyIqB,CAAA,mBAzIeP,gBAyIf,GAzIkCA,gBAyIlC,CAAA,SAzI4DH,gBAyI5D,CAzI6EK,UAyI7E,EAAA,MAAA,CAAA,CAAA;EAAA,SAAIL,IAAAA,EAAAA,MAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;;;;;;sBAxH9DN,kBAAkBC;;gBAExBK,iBAAiBL;0BACPI;;UAEXE;;cAEHF,sBAAsBA;;;;;;;;;QAS1BG;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA;;cAEVP,yBAAyBE,YAAYI;;;;iBAI3BE,aAAAA,mBAAgCT;;;;iBAIhCU,kBAAAA,IAAsBlB,wBAAwBU"}
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 // 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 * 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nTArgs 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(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAYqB;EAZ+F,QAAA,CAAA,EAAA,GAAA;EAqBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAAA,EAhBNH,MAgBiB,CAAA,MAAA,EAAA,OAAA,CAAA;;;;;;;;;AAqBmCF,UA5BlDG,gBAAAA,CA4BkDH;EAAiB,SAC1CC,qBAAAA,EAAAA,IAAAA;;AACUI,iBA3B5BD,kBAAAA,CA2B4BC,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BSF,gBA2BTE;;;;AAvBwG,cAAvIA,WAAuI,CAAA,mBAAxGN,gBAAwG,GAArFA,gBAAqF,CAAA,SAA3DJ,WAA2D,CAA/CM,UAA+C,EAAA,MAAA,CAAA,YAAhBE,gBAAgB,CAAA;EA8BvIG,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAgB;EAAA,IAAA,UAAA,CAAA,CAAA,EA5BfJ,MA4Be,CAAA,MAAA,EAAA,MAAA,CAAA;EAAA,qBAAoBH,EAAAA,IAAAA;EAAgB,SAAGA,IAAAA,EAAAA,MAAAA;EAAgB;;;;EAmB/C,MAA3BO,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAgB,YACNJ,EAAAA,MAAAA;EAAM,QApBoEN,CAAAA,EAnBvFM,MAmBuFN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAAgB;AAsBtH;;;;;;EAee;EA+CEc,QAAAA,CAAAA,EAAAA,GAAAA;EAmBAC,WAAAA,CAAAA,MAAe,EAhHRb,oBA0HR,CA1H6BG,UA0H7B,EAAA,MAAA,CAAA,GA1HmDD,iBA0HnD,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAAA,MAAA;EAcQY,WAAAA,CAAAA,MAAAA,EAvIAZ,iBAuIqB,CAvIHC,UAuIG,CAAA;EAAA,OAAA,UAAA,CAAA,OAAA,EAAA,OAAA,CAAA,EAAA,OAAA,IAtIOI,WAsIP;EAAA,IAE/BH,gBAAAA,CAAAA,CAAAA,EAvIcA,MAuIdA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;AAAoD;AAIlE;AAIA;AAA0C,cAzIrBI,gBAyIqB,CAAA,mBAzIeP,gBAyIf,GAzIkCA,gBAyIlC,CAAA,SAzI4DH,gBAyI5D,CAzI6EK,UAyI7E,EAAA,MAAA,CAAA,CAAA;EAAA,SAAIL,IAAAA,EAAAA,MAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;;;;;;sBAxH9DN,kBAAkBC;;gBAExBK,iBAAiBL;0BACPC;;UAEXK;;cAEHL,sBAAsBA;;;;;;;;;QAS1BM;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA;;cAEVV,yBAAyBK,YAAYI;;;;iBAI3BE,aAAAA,mBAAgCR;;;;iBAIhCS,kBAAAA,IAAsBlB,wBAAwBU"}
@@ -14,6 +14,7 @@ interface ToolMessageFields<TStructure extends MessageStructure = MessageStructu
14
14
  artifact?: any;
15
15
  tool_call_id: string;
16
16
  status?: "success" | "error";
17
+ metadata?: Record<string, unknown>;
17
18
  }
18
19
  /**
19
20
  * Marker parameter for objects that tools can return directly.
@@ -40,6 +41,7 @@ declare class ToolMessage<TStructure extends MessageStructure = MessageStructure
40
41
  */
41
42
  status?: "success" | "error";
42
43
  tool_call_id: string;
44
+ metadata?: Record<string, unknown>;
43
45
  /**
44
46
  * Artifact of the Tool execution which is not meant to be sent to the model.
45
47
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","names":["BaseMessage","BaseMessageChunk","BaseMessageFields","$InferMessageContent","MessageStructure","ToolMessageFields","TStructure","DirectToolOutput","isDirectToolOutput","ToolMessage","Record","ToolMessageChunk","ToolCall","TName","TArgs","ToolCallChunk","InvalidToolCall","defaultToolCallParser","isToolMessage","isToolMessageChunk"],"sources":["../../src/messages/tool.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, type BaseMessageFields } from \"./base.js\";\nimport { $InferMessageContent, MessageStructure } from \"./message.js\";\nexport interface ToolMessageFields<TStructure extends MessageStructure = MessageStructure> extends BaseMessageFields<TStructure, \"tool\"> {\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n tool_call_id: string;\n status?: \"success\" | \"error\";\n}\n/**\n * Marker parameter for objects that tools can return directly.\n *\n * If a custom BaseTool is invoked with a ToolCall and the output of custom code is\n * not an instance of DirectToolOutput, the output will automatically be coerced to\n * a string and wrapped in a ToolMessage.\n */\nexport interface DirectToolOutput {\n readonly lc_direct_tool_output: true;\n}\nexport declare function isDirectToolOutput(x: unknown): x is DirectToolOutput;\n/**\n * Represents a tool message in a conversation.\n */\nexport declare class ToolMessage<TStructure extends MessageStructure = MessageStructure> extends BaseMessage<TStructure, \"tool\"> implements DirectToolOutput {\n static lc_name(): string;\n get lc_aliases(): Record<string, string>;\n lc_direct_tool_output: true;\n readonly type: \"tool\";\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n tool_call_id: string;\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nTArgs 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(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAAoH;EAoBnGC,QAAAA,CAAAA,EAAAA,GAAAA;EAGOC,YAAAA,EAAAA,MAAAA;EAIHC,MAAAA,CAAAA,EAAAA,SAAW,GAAA,OAAA;;;;;;;;;AAqBUH,UA5BzBC,gBAAAA,CA4ByBD;EAAU,SAA5BD,qBAAAA,EAAAA,IAAAA;;AAEIK,iBA3BJF,kBAAAA,CA2BIE,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BiCH,gBA2BjCG;;;AAvBgI;AA6BvIC,cA7BAF,WA6BgB,CAAA,mBA7BeL,gBA6Bf,GA7BkCA,gBA6BlC,CAAA,SA7B4DJ,WA6B5D,CA7BwEM,UA6BxE,EAAA,MAAA,CAAA,YA7BuGC,gBA6BvG,CAAA;EAAA,OAAA,OAAA,CAAA,CAAA,EAAA,MAAA;EAAA,IAAoBH,UAAAA,CAAAA,CAAAA,EA3BnCM,MA2BmCN,CAAAA,MAAAA,EAAAA,MAAAA,CAAAA;EAAgB,qBAAGA,EAAAA,IAAAA;EAAgB,SAA2BE,IAAAA,EAAAA,MAAAA;EAAU;;;;EAmB/F,MACNI,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAM,YApBoET,EAAAA,MAAAA;EAAgB;AAsBtH;;;;;;EAee;EA+CEc,QAAAA,CAAAA,EAAAA,GAAAA;EAmBAC,WAAAA,CAAAA,MAAe,EAhHRb,oBA0HR,CA1H6BG,UA0H7B,EAAA,MAAA,CAAA,GA1HmDD,iBA0HnD,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAAA,MAAA;EAcQY,WAAAA,CAAAA,MAAAA,EAvIAZ,iBAuIqB,CAvIHC,UAuIG,CAAA;EAAA,OAAA,UAAA,CAAA,OAAA,EAAA,OAAA,CAAA,EAAA,OAAA,IAtIOG,WAsIP;EAAA,IAE/BC,gBAAAA,CAAAA,CAAAA,EAvIcA,MAuIdA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;AAAoD;AAIlE;AAIA;AAA0C,cAzIrBC,gBAyIqB,CAAA,mBAzIeP,gBAyIf,GAzIkCA,gBAyIlC,CAAA,SAzI4DH,gBAyI5D,CAzI6EK,UAyI7E,EAAA,MAAA,CAAA,CAAA;EAAA,SAAIL,IAAAA,EAAAA,MAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;;;;;;sBAxH9DN,kBAAkBC;;gBAExBK,iBAAiBL;0BACPI;;UAEXE;;cAEHF,sBAAsBA;;;;;;;;;QAS1BG;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA;;cAEVP,yBAAyBE,YAAYI;;;;iBAI3BE,aAAAA,mBAAgCT;;;;iBAIhCU,kBAAAA,IAAsBlB,wBAAwBU"}
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 // 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 * 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 // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: $InferMessageContent<TStructure, \"tool\"> | ToolMessageFields, tool_call_id: string, name?: string);\n constructor(fields: ToolMessageFields<TStructure>);\n static isInstance(message: unknown): message is ToolMessage;\n get _printableFields(): Record<string, unknown>;\n}\n/**\n * Represents a chunk of a tool message, which can be concatenated\n * with other tool message chunks.\n */\nexport declare class ToolMessageChunk<TStructure extends MessageStructure = MessageStructure> extends BaseMessageChunk<TStructure, \"tool\"> {\n readonly type: \"tool\";\n tool_call_id: string;\n /**\n * Status of the tool invocation.\n * @version 0.2.19\n */\n status?: \"success\" | \"error\";\n /**\n * Artifact of the Tool execution which is not meant to be sent to the model.\n *\n * Should only be specified if it is different from the message content, e.g. if only\n * a subset of the full tool output is being passed as message content but the full\n * output is needed in other parts of the code.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n artifact?: any;\n constructor(fields: ToolMessageFields<TStructure>);\n static lc_name(): string;\n concat(chunk: ToolMessageChunk<TStructure>): this;\n get _printableFields(): Record<string, unknown>;\n}\nexport interface ToolCall<TName extends string = string, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nTArgs 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(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nrawToolCalls: Record<string, any>[]): [ToolCall[], InvalidToolCall[]];\n/**\n * @deprecated Use {@link ToolMessage.isInstance} instead\n */\nexport declare function isToolMessage(x: unknown): x is ToolMessage;\n/**\n * @deprecated Use {@link ToolMessageChunk.isInstance} instead\n */\nexport declare function isToolMessageChunk(x: BaseMessageChunk): x is ToolMessageChunk;\n"],"mappings":";;;;UAEiBK,qCAAqCD,mBAAmBA,0BAA0BF,kBAAkBI;;AAArH;;;;;;EAYqB;EAZ+F,QAAA,CAAA,EAAA,GAAA;EAqBnGE,YAAAA,EAAAA,MAAgB;EAGTC,MAAAA,CAAAA,EAAAA,SAAAA,GAAkB,OAAA;EAIrBC,QAAAA,CAAAA,EAhBNH,MAgBiB,CAAA,MAAA,EAAA,OAAA,CAAA;;;;;;;;;AAqBmCF,UA5BlDG,gBAAAA,CA4BkDH;EAAiB,SAC1CC,qBAAAA,EAAAA,IAAAA;;AACUI,iBA3B5BD,kBAAAA,CA2B4BC,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IA3BSF,gBA2BTE;;;;AAvBwG,cAAvIA,WAAuI,CAAA,mBAAxGN,gBAAwG,GAArFA,gBAAqF,CAAA,SAA3DJ,WAA2D,CAA/CM,UAA+C,EAAA,MAAA,CAAA,YAAhBE,gBAAgB,CAAA;EA8BvIG,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAgB;EAAA,IAAA,UAAA,CAAA,CAAA,EA5BfJ,MA4Be,CAAA,MAAA,EAAA,MAAA,CAAA;EAAA,qBAAoBH,EAAAA,IAAAA;EAAgB,SAAGA,IAAAA,EAAAA,MAAAA;EAAgB;;;;EAmB/C,MAA3BO,CAAAA,EAAAA,SAAAA,GAAAA,OAAAA;EAAgB,YACNJ,EAAAA,MAAAA;EAAM,QApBoEN,CAAAA,EAnBvFM,MAmBuFN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;EAAgB;AAsBtH;;;;;;EAee;EA+CEc,QAAAA,CAAAA,EAAAA,GAAAA;EAmBAC,WAAAA,CAAAA,MAAe,EAhHRb,oBA0HR,CA1H6BG,UA0H7B,EAAA,MAAA,CAAA,GA1HmDD,iBA0HnD,EAAA,YAAA,EAAA,MAAA,EAAA,IAAA,CAAA,EAAA,MAAA;EAcQY,WAAAA,CAAAA,MAAAA,EAvIAZ,iBAuIqB,CAvIHC,UAuIG,CAAA;EAAA,OAAA,UAAA,CAAA,OAAA,EAAA,OAAA,CAAA,EAAA,OAAA,IAtIOI,WAsIP;EAAA,IAE/BH,gBAAAA,CAAAA,CAAAA,EAvIcA,MAuIdA,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;AAAoD;AAIlE;AAIA;AAA0C,cAzIrBI,gBAyIqB,CAAA,mBAzIeP,gBAyIf,GAzIkCA,gBAyIlC,CAAA,SAzI4DH,gBAyI5D,CAzI6EK,UAyI7E,EAAA,MAAA,CAAA,CAAA;EAAA,SAAIL,IAAAA,EAAAA,MAAAA;EAAgB,YAAQU,EAAAA,MAAAA;EAAgB;;;;;;;;;;;;;;sBAxH9DN,kBAAkBC;;gBAExBK,iBAAiBL;0BACPC;;UAEXK;;cAEHL,sBAAsBA;;;;;;;;;QAS1BM;;;;QAIAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+COC;;;;;;;;;SASNF;;;;;;;;;;UAUMG;;;;;;;;;;SAUNH;;;;;;;;;;;;;;iBAcaI,qBAAAA;;cAEVV,yBAAyBK,YAAYI;;;;iBAI3BE,aAAAA,mBAAgCR;;;;iBAIhCS,kBAAAA,IAAsBlB,wBAAwBU"}
@@ -32,6 +32,7 @@ var ToolMessage = class extends BaseMessage {
32
32
  */
33
33
  status;
34
34
  tool_call_id;
35
+ metadata;
35
36
  /**
36
37
  * Artifact of the Tool execution which is not meant to be sent to the model.
37
38
  *
@@ -50,6 +51,7 @@ var ToolMessage = class extends BaseMessage {
50
51
  this.tool_call_id = toolMessageFields.tool_call_id;
51
52
  this.artifact = toolMessageFields.artifact;
52
53
  this.status = toolMessageFields.status;
54
+ this.metadata = toolMessageFields.metadata;
53
55
  }
54
56
  static isInstance(message) {
55
57
  return super.isInstance(message) && message.type === "tool";