langchain 1.0.0-alpha.6 → 1.0.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/agents/ReactAgent.cjs.map +1 -1
  2. package/dist/agents/ReactAgent.d.cts +1 -2
  3. package/dist/agents/ReactAgent.d.cts.map +1 -1
  4. package/dist/agents/ReactAgent.d.ts +1 -2
  5. package/dist/agents/ReactAgent.d.ts.map +1 -1
  6. package/dist/agents/ReactAgent.js.map +1 -1
  7. package/dist/agents/annotation.cjs.map +1 -1
  8. package/dist/agents/annotation.d.cts +12 -5
  9. package/dist/agents/annotation.d.cts.map +1 -1
  10. package/dist/agents/annotation.d.ts +12 -5
  11. package/dist/agents/annotation.d.ts.map +1 -1
  12. package/dist/agents/annotation.js.map +1 -1
  13. package/dist/agents/createAgent.cjs.map +1 -1
  14. package/dist/agents/createAgent.js.map +1 -1
  15. package/dist/agents/index.cjs.map +1 -1
  16. package/dist/agents/index.d.cts +3 -3
  17. package/dist/agents/index.d.cts.map +1 -1
  18. package/dist/agents/index.d.ts +3 -3
  19. package/dist/agents/index.d.ts.map +1 -1
  20. package/dist/agents/index.js.map +1 -1
  21. package/dist/agents/interrupt.d.cts +14 -1
  22. package/dist/agents/interrupt.d.cts.map +1 -1
  23. package/dist/agents/interrupt.d.ts +14 -1
  24. package/dist/agents/interrupt.d.ts.map +1 -1
  25. package/dist/agents/middlewareAgent/ReactAgent.cjs +262 -55
  26. package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
  27. package/dist/agents/middlewareAgent/ReactAgent.d.cts +97 -10
  28. package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
  29. package/dist/agents/middlewareAgent/ReactAgent.d.ts +97 -10
  30. package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
  31. package/dist/agents/middlewareAgent/ReactAgent.js +264 -57
  32. package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
  33. package/dist/agents/middlewareAgent/annotation.cjs +10 -4
  34. package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
  35. package/dist/agents/middlewareAgent/annotation.js +10 -4
  36. package/dist/agents/middlewareAgent/annotation.js.map +1 -1
  37. package/dist/agents/middlewareAgent/constants.d.cts +5 -0
  38. package/dist/agents/middlewareAgent/constants.d.cts.map +1 -0
  39. package/dist/agents/middlewareAgent/constants.d.ts +5 -0
  40. package/dist/agents/middlewareAgent/constants.d.ts.map +1 -0
  41. package/dist/agents/middlewareAgent/index.cjs.map +1 -1
  42. package/dist/agents/middlewareAgent/index.js.map +1 -1
  43. package/dist/agents/middlewareAgent/middleware/bigTool.cjs +162 -0
  44. package/dist/agents/middlewareAgent/middleware/bigTool.cjs.map +1 -0
  45. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts +113 -0
  46. package/dist/agents/middlewareAgent/middleware/bigTool.d.cts.map +1 -0
  47. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts +113 -0
  48. package/dist/agents/middlewareAgent/middleware/bigTool.d.ts.map +1 -0
  49. package/dist/agents/middlewareAgent/middleware/bigTool.js +161 -0
  50. package/dist/agents/middlewareAgent/middleware/bigTool.js.map +1 -0
  51. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs +58 -0
  52. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs.map +1 -0
  53. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts +46 -0
  54. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts.map +1 -0
  55. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts +46 -0
  56. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts.map +1 -0
  57. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js +58 -0
  58. package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js.map +1 -0
  59. package/dist/agents/middlewareAgent/middleware/hitl.cjs +160 -84
  60. package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -1
  61. package/dist/agents/middlewareAgent/middleware/hitl.d.cts +271 -51
  62. package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -1
  63. package/dist/agents/middlewareAgent/middleware/hitl.d.ts +271 -51
  64. package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -1
  65. package/dist/agents/middlewareAgent/middleware/hitl.js +161 -85
  66. package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -1
  67. package/dist/agents/middlewareAgent/middleware/index.cjs +6 -0
  68. package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -1
  69. package/dist/agents/middlewareAgent/middleware/index.d.cts +6 -4
  70. package/dist/agents/middlewareAgent/middleware/index.d.ts +6 -4
  71. package/dist/agents/middlewareAgent/middleware/index.js +5 -1
  72. package/dist/agents/middlewareAgent/middleware/index.js.map +1 -1
  73. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs +24 -8
  74. package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -1
  75. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts +51 -6
  76. package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -1
  77. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts +51 -6
  78. package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -1
  79. package/dist/agents/middlewareAgent/middleware/promptCaching.js +24 -8
  80. package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -1
  81. package/dist/agents/middlewareAgent/middleware/summarization.cjs +24 -12
  82. package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -1
  83. package/dist/agents/middlewareAgent/middleware/summarization.d.cts +5 -3
  84. package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -1
  85. package/dist/agents/middlewareAgent/middleware/summarization.d.ts +11 -9
  86. package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +1 -1
  87. package/dist/agents/middlewareAgent/middleware/summarization.js +25 -13
  88. package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -1
  89. package/dist/agents/middlewareAgent/middleware.cjs +8 -5
  90. package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
  91. package/dist/agents/middlewareAgent/middleware.d.cts +67 -7
  92. package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
  93. package/dist/agents/middlewareAgent/middleware.d.ts +67 -7
  94. package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
  95. package/dist/agents/middlewareAgent/middleware.js +8 -5
  96. package/dist/agents/middlewareAgent/middleware.js.map +1 -1
  97. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +2 -2
  98. package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
  99. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +2 -2
  100. package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
  101. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +117 -68
  102. package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
  103. package/dist/agents/middlewareAgent/nodes/AgentNode.js +121 -72
  104. package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
  105. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +2 -2
  106. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
  107. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +2 -2
  108. package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
  109. package/dist/agents/middlewareAgent/nodes/middleware.cjs +42 -17
  110. package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
  111. package/dist/agents/middlewareAgent/nodes/middleware.js +42 -18
  112. package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
  113. package/dist/agents/middlewareAgent/nodes/utils.cjs +25 -11
  114. package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
  115. package/dist/agents/middlewareAgent/nodes/utils.js +26 -12
  116. package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
  117. package/dist/agents/middlewareAgent/types.d.cts +153 -66
  118. package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
  119. package/dist/agents/middlewareAgent/types.d.ts +153 -66
  120. package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
  121. package/dist/agents/model.cjs +13 -0
  122. package/dist/agents/model.cjs.map +1 -0
  123. package/dist/agents/model.js +11 -0
  124. package/dist/agents/model.js.map +1 -0
  125. package/dist/agents/nodes/AgentNode.cjs +56 -28
  126. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  127. package/dist/agents/nodes/AgentNode.js +57 -29
  128. package/dist/agents/nodes/AgentNode.js.map +1 -1
  129. package/dist/agents/nodes/ToolNode.cjs +1 -1
  130. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  131. package/dist/agents/nodes/ToolNode.d.cts +1 -1
  132. package/dist/agents/nodes/ToolNode.js +1 -1
  133. package/dist/agents/nodes/ToolNode.js.map +1 -1
  134. package/dist/agents/responses.cjs +52 -10
  135. package/dist/agents/responses.cjs.map +1 -1
  136. package/dist/agents/responses.d.cts +12 -20
  137. package/dist/agents/responses.d.cts.map +1 -1
  138. package/dist/agents/responses.d.ts +12 -20
  139. package/dist/agents/responses.d.ts.map +1 -1
  140. package/dist/agents/responses.js +52 -11
  141. package/dist/agents/responses.js.map +1 -1
  142. package/dist/agents/types.d.cts +2 -3
  143. package/dist/agents/types.d.cts.map +1 -1
  144. package/dist/agents/types.d.ts +2 -3
  145. package/dist/agents/types.d.ts.map +1 -1
  146. package/dist/agents/utils.cjs +5 -23
  147. package/dist/agents/utils.cjs.map +1 -1
  148. package/dist/agents/utils.js +2 -19
  149. package/dist/agents/utils.js.map +1 -1
  150. package/dist/chains/query_constructor/index.d.cts +1 -1
  151. package/dist/chains/summarization/load.d.ts +2 -2
  152. package/dist/chains/summarization/load.d.ts.map +1 -1
  153. package/dist/embeddings/cache_backed.d.ts +1 -1
  154. package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
  155. package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
  156. package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
  157. package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
  158. package/dist/index.cjs +38 -6
  159. package/dist/index.cjs.map +1 -1
  160. package/dist/index.d.cts +11 -4
  161. package/dist/index.d.ts +11 -4
  162. package/dist/index.js +18 -4
  163. package/dist/index.js.map +1 -1
  164. package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
  165. package/dist/langchain-core/dist/messages/content/index.d.cts +20 -1
  166. package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
  167. package/dist/langchain-core/dist/messages/content/tools.d.cts +67 -6
  168. package/dist/langchain-core/dist/messages/content/tools.d.cts.map +1 -1
  169. package/dist/langchain-core/dist/messages/message.d.cts +6 -6
  170. package/dist/langchain-core/dist/messages/message.d.cts.map +1 -1
  171. package/dist/langchain-core/dist/utils/types/index.d.cts.map +1 -1
  172. package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
  173. package/dist/libs/langchain-core/dist/messages/content/index.d.ts +20 -1
  174. package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
  175. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts +67 -6
  176. package/dist/libs/langchain-core/dist/messages/content/tools.d.ts.map +1 -1
  177. package/dist/libs/langchain-core/dist/messages/message.d.ts +6 -6
  178. package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -1
  179. package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
  180. package/dist/load/import_map.cjs +1 -1
  181. package/dist/load/import_map.js +1 -1
  182. package/dist/output_parsers/structured.d.cts +1 -1
  183. package/dist/tools/fs.d.cts +1 -1
  184. package/dist/tools/retriever.d.cts +1 -1
  185. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"base.d.ts","names":["ContentBlock","Serializable","SerializedConstructor","$InferMessageContent","$InferResponseMetadata","Message","MessageStructure","MessageType","MESSAGE_SYMBOL","StoredMessageData","Record","StoredMessage","StoredGeneration","StoredMessageV1","MessageContent","Array","FunctionCall","BaseMessageFields","TStructure","TRole","Standard","OpenAIToolCall","Partial","mergeContent","_mergeStatus","BaseMessage","NonNullable","Symbol","toStringTag","isOpenAIToolCallArray","_mergeDicts","_mergeLists","Content","_mergeObj","T","BaseMessageChunk","MessageFieldWithRole","_isMessageFieldWithRole","BaseMessageLike","isBaseMessage","isBaseMessageChunk"],"sources":["../../../../../../langchain-core/dist/messages/base.d.ts"],"sourcesContent":["import { ContentBlock } from \"./content/index.js\";\nimport { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { $InferMessageContent, $InferResponseMetadata, Message, MessageStructure, MessageType } from \"./message.js\";\n\n//#region src/messages/base.d.ts\n/** @internal */\ndeclare const MESSAGE_SYMBOL: unique symbol;\ninterface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n response_metadata?: Record<string, any>;\n id?: string;\n}\ninterface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\ninterface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\ninterface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\ntype MessageContent = string | Array<ContentBlock>;\ninterface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n /**\n * The name of the function to call.\n */\n name: string;\n}\ntype BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = {\n id?: string;\n name?: string;\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\ndeclare function mergeContent(firstContent: MessageContent, secondContent: MessageContent): MessageContent;\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\ndeclare function _mergeStatus(left?: \"success\" | \"error\", right?: \"success\" | \"error\"): \"success\" | \"error\" | undefined;\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\ndeclare abstract class BaseMessage<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends Serializable implements Message<TStructure, TRole> {\n lc_namespace: string[];\n lc_serializable: boolean;\n get lc_aliases(): Record<string, string>;\n readonly [MESSAGE_SYMBOL]: true;\n abstract readonly type: TRole;\n id?: string;\n name?: string;\n content: $InferMessageContent<TStructure, TRole>;\n additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]>;\n response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>[\"response_metadata\"]>;\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType;\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType;\n constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);\n /** Get text content of the message. */\n get text(): string;\n get contentBlocks(): Array<ContentBlock.Standard>;\n toDict(): StoredMessage;\n static lc_name(): string;\n // Can't be protected for silly reasons\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is BaseMessage;\n // this private method is used to update the ID for the runtime\n // value as well as in lc_kwargs for serialisation\n _updateId(value: string | undefined): void;\n get [Symbol.toStringTag](): any;\n}\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\ntype OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n index?: number;\n};\ndeclare function isOpenAIToolCallArray(value?: unknown): value is OpenAIToolCall[];\ndeclare function _mergeDicts(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nleft: Record<string, any>,\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nright: Record<string, any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any>;\ndeclare function _mergeLists<Content extends ContentBlock>(left?: Content[], right?: Content[]): Content[] | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare function _mergeObj<T = any>(left: T | undefined, right: T | undefined): T;\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\ndeclare abstract class BaseMessageChunk<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n static isInstance(obj: unknown): obj is BaseMessageChunk;\n}\ntype MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\ndeclare function _isMessageFieldWithRole(x: BaseMessageLike): x is MessageFieldWithRole;\ntype BaseMessageLike = BaseMessage | MessageFieldWithRole | [MessageType, MessageContent] | string\n/**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */ | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n} & BaseMessageFields & Record<string, unknown>) | SerializedConstructor;\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\ndeclare function isBaseMessage(messageLike?: unknown): messageLike is BaseMessage;\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\ndeclare function isBaseMessageChunk(messageLike?: unknown): messageLike is BaseMessageChunk;\n//#endregion\nexport { BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, FunctionCall, MessageContent, MessageFieldWithRole, OpenAIToolCall, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, isBaseMessage, isBaseMessageChunk, isOpenAIToolCallArray, mergeContent };\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;AAEoH;AAIzE,cAA7BQ,cACa,EAAA,OAAA,MAAA;UAAjBC,iBAAAA,CAAiB;EAAA,OAMLC,EAAAA,MAAAA;EAAM,IAAA,EAGNA,MAAAA,GAAAA,SAAAA;EAAM,IAAA,EAAA,MAAA,GAAA,SAAA;EAAA,YAGlBC,EAAAA,MAAa,GAAA,SAEfF;EAW4B;EACd,iBAajBQ,CAAAA,EAjCiBP,MAiCA,CAAA,MAAA,EAAA,GAAA,CAAA;EAAA;EAAA;EAAoC,iBAAGJ,CAAAA,EA9BvCI,MA8BuCJ,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAAgB,EAAA,CAAA,EAAgBC,MAAAA;;UA3BnFI,aAAAA,CA8BuBO;EAAU,IAAA,EAAEC,MAAAA;EAAK,IAAA,EA5B1CV,iBA4BIN;;UAhBFa,YAAAA,CA+C4CV;EAAgB;;;;;;EAG5C,SACdE,EAAAA,MAA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structor","$InferMessageContent","$InferResponseMetadata","Message","MessageStructure","MessageType","MESSAGE_SYMBOL","StoredMessageData","Record","StoredMessage","StoredGeneration","StoredMessageV1","MessageContent","Array","FunctionCall","BaseMessageFields","TStructure","TRole","Standard","OpenAIToolCall","Partial","mergeContent","_mergeStatus","BaseMessage","NonNullable","Symbol","toStringTag","isOpenAIToolCallArray","_mergeDicts","_mergeLists","Content","_mergeObj","T","BaseMessageChunk","MessageFieldWithRole","_isMessageFieldWithRole","BaseMessageLike","isBaseMessage","isBaseMessageChunk"],"sources":["../../../../../../langchain-core/dist/messages/base.d.ts"],"sourcesContent":["import { ContentBlock } from \"./content/index.js\";\nimport { Serializable, SerializedConstructor } from \"../load/serializable.js\";\nimport { $InferMessageContent, $InferResponseMetadata, Message, MessageStructure, MessageType } from \"./message.js\";\n\n//#region src/messages/base.d.ts\n/** @internal */\ndeclare const MESSAGE_SYMBOL: unique symbol;\ninterface StoredMessageData {\n content: string;\n role: string | undefined;\n name: string | undefined;\n tool_call_id: string | undefined;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additional_kwargs?: Record<string, any>;\n /** Response metadata. For example: response headers, logprobs, token counts, model name. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n response_metadata?: Record<string, any>;\n id?: string;\n}\ninterface StoredMessage {\n type: string;\n data: StoredMessageData;\n}\ninterface StoredGeneration {\n text: string;\n message?: StoredMessage;\n}\ninterface StoredMessageV1 {\n type: string;\n role: string | undefined;\n text: string;\n}\ntype MessageContent = string | Array<ContentBlock>;\ninterface FunctionCall {\n /**\n * The arguments to call the function with, as generated by the model in JSON\n * format. Note that the model does not always generate valid JSON, and may\n * hallucinate parameters not defined by your function schema. Validate the\n * arguments in your code before calling your function.\n */\n arguments: string;\n /**\n * The name of the function to call.\n */\n name: string;\n}\ntype BaseMessageFields<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> = {\n id?: string;\n name?: string;\n content?: $InferMessageContent<TStructure, TRole>;\n contentBlocks?: Array<ContentBlock.Standard>;\n /** @deprecated */\n additional_kwargs?: {\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n function_call?: FunctionCall;\n /**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\n tool_calls?: OpenAIToolCall[];\n [key: string]: unknown;\n };\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n};\ndeclare function mergeContent(firstContent: MessageContent, secondContent: MessageContent): MessageContent;\n/**\n * 'Merge' two statuses. If either value passed is 'error', it will return 'error'. Else\n * it will return 'success'.\n *\n * @param {\"success\" | \"error\" | undefined} left The existing value to 'merge' with the new value.\n * @param {\"success\" | \"error\" | undefined} right The new value to 'merge' with the existing value\n * @returns {\"success\" | \"error\"} The 'merged' value.\n */\ndeclare function _mergeStatus(left?: \"success\" | \"error\", right?: \"success\" | \"error\"): \"success\" | \"error\" | undefined;\n/**\n * Base class for all types of messages in a conversation. It includes\n * properties like `content`, `name`, and `additional_kwargs`. It also\n * includes methods like `toDict()` and `_getType()`.\n */\ndeclare abstract class BaseMessage<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends Serializable implements Message<TStructure, TRole> {\n lc_namespace: string[];\n lc_serializable: boolean;\n get lc_aliases(): Record<string, string>;\n readonly [MESSAGE_SYMBOL]: true;\n abstract readonly type: TRole;\n id?: string;\n name?: string;\n content: $InferMessageContent<TStructure, TRole>;\n additional_kwargs: NonNullable<BaseMessageFields<TStructure, TRole>[\"additional_kwargs\"]>;\n response_metadata: NonNullable<BaseMessageFields<TStructure, TRole>[\"response_metadata\"]>;\n /**\n * @deprecated Use .getType() instead or import the proper typeguard.\n * For example:\n *\n * ```ts\n * import { isAIMessage } from \"@langchain/core/messages\";\n *\n * const message = new AIMessage(\"Hello!\");\n * isAIMessage(message); // true\n * ```\n */\n _getType(): MessageType;\n /**\n * @deprecated Use .type instead\n * The type of the message.\n */\n getType(): MessageType;\n constructor(arg: $InferMessageContent<TStructure, TRole> | BaseMessageFields<TStructure, TRole>);\n /** Get text content of the message. */\n get text(): string;\n get contentBlocks(): Array<ContentBlock.Standard>;\n toDict(): StoredMessage;\n static lc_name(): string;\n // Can't be protected for silly reasons\n get _printableFields(): Record<string, unknown>;\n static isInstance(obj: unknown): obj is BaseMessage;\n // this private method is used to update the ID for the runtime\n // value as well as in lc_kwargs for serialisation\n _updateId(value: string | undefined): void;\n get [Symbol.toStringTag](): any;\n}\n/**\n * @deprecated Use \"tool_calls\" field on AIMessages instead\n */\ntype OpenAIToolCall = {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The function that the model called.\n */\n function: FunctionCall;\n /**\n * The type of the tool. Currently, only `function` is supported.\n */\n type: \"function\";\n index?: number;\n};\ndeclare function isOpenAIToolCallArray(value?: unknown): value is OpenAIToolCall[];\ndeclare function _mergeDicts(\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nleft?: Record<string, any>,\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nright?: Record<string, any>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\n): Record<string, any>;\ndeclare function _mergeLists<Content extends ContentBlock>(left?: Content[], right?: Content[]): Content[] | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ndeclare function _mergeObj<T = any>(left: T | undefined, right: T | undefined): T;\n/**\n * Represents a chunk of a message, which can be concatenated with other\n * message chunks. It includes a method `_merge_kwargs_dict()` for merging\n * additional keyword arguments from another `BaseMessageChunk` into this\n * one. It also overrides the `__add__()` method to support concatenation\n * of `BaseMessageChunk` instances.\n */\ndeclare abstract class BaseMessageChunk<TStructure extends MessageStructure = MessageStructure, TRole extends MessageType = MessageType> extends BaseMessage<TStructure, TRole> {\n abstract concat(chunk: BaseMessageChunk): BaseMessageChunk<TStructure, TRole>;\n static isInstance(obj: unknown): obj is BaseMessageChunk;\n}\ntype MessageFieldWithRole = {\n role: MessageType;\n content: MessageContent;\n name?: string;\n} & Record<string, unknown>;\ndeclare function _isMessageFieldWithRole(x: BaseMessageLike): x is MessageFieldWithRole;\ntype BaseMessageLike = BaseMessage | MessageFieldWithRole | [MessageType, MessageContent] | string\n/**\n * @deprecated Specifying \"type\" is deprecated and will be removed in 0.4.0.\n */ | ({\n type: MessageType | \"user\" | \"assistant\" | \"placeholder\";\n} & BaseMessageFields & Record<string, unknown>) | SerializedConstructor;\n/**\n * @deprecated Use {@link BaseMessage.isInstance} instead\n */\ndeclare function isBaseMessage(messageLike?: unknown): messageLike is BaseMessage;\n/**\n * @deprecated Use {@link BaseMessageChunk.isInstance} instead\n */\ndeclare function isBaseMessageChunk(messageLike?: unknown): messageLike is BaseMessageChunk;\n//#endregion\nexport { BaseMessage, BaseMessageChunk, BaseMessageFields, BaseMessageLike, FunctionCall, MessageContent, MessageFieldWithRole, OpenAIToolCall, StoredGeneration, StoredMessage, StoredMessageData, StoredMessageV1, _isMessageFieldWithRole, _mergeDicts, _mergeLists, _mergeObj, _mergeStatus, isBaseMessage, isBaseMessageChunk, isOpenAIToolCallArray, mergeContent };\n//# sourceMappingURL=base.d.ts.map"],"mappings":";;;;;;;AAEoH;AAIzE,cAA7BQ,cACa,EAAA,OAAA,MAAA;UAAjBC,iBAAAA,CAAiB;EAAA,OAMLC,EAAAA,MAAAA;EAAM,IAAA,EAGNA,MAAAA,GAAAA,SAAAA;EAAM,IAAA,EAAA,MAAA,GAAA,SAAA;EAAA,YAGlBC,EAAAA,MAAa,GAAA,SAEfF;EAW4B;EACd,iBAajBQ,CAAAA,EAjCiBP,MAiCA,CAAA,MAAA,EAAA,GAAA,CAAA;EAAA;EAAA;EAAoC,iBAAGJ,CAAAA,EA9BvCI,MA8BuCJ,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAAgB,EAAA,CAAA,EAAgBC,MAAAA;;UA3BnFI,aAAAA,CA8BuBO;EAAU,IAAA,EAAEC,MAAAA;EAAK,IAAA,EA5B1CV,iBA4BIN;;UAhBFa,YAAAA,CA+C4CV;EAAgB;;;;;;EAG5C,SACdE,EAAAA,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92
  index?: number;
93
93
  }
94
+ /**
95
+ * Provider-specific content block.
96
+ *
97
+ * This is used to represent content blocks that are not part of the standard LangChain content model.
98
+ * If a provider's non-standard output includes reasoning and tool calls, it should be
99
+ * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.
100
+ */
101
+ export interface NonStandard<
102
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
103
+ TValue extends Record<string, any> = Record<string, any>> extends ContentBlock {
104
+ /**
105
+ * Type of the content block
106
+ */
107
+ type: "non_standard";
108
+ /**
109
+ * Provider-specific data
110
+ */
111
+ value: TValue;
112
+ }
94
113
  export { Tools };
95
114
  export { Multimodal };
96
115
  export { Data };
97
- export type Standard = Text | Reasoning | Tools.Standard | Multimodal.Standard;
116
+ export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;
98
117
  }
99
118
  //#endregion
100
119
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["BaseContentBlock","Tools","Multimodal","Data","ContentBlock","KNOWN_BLOCK_TYPES","Citation","Array","Text","Reasoning","Standard"],"sources":["../../../../../../../langchain-core/dist/messages/content/index.d.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\nimport { Tools } from \"./tools.js\";\nimport { Multimodal } from \"./multimodal.js\";\nimport { Data } from \"./data.js\";\n\n//#region src/messages/content/index.d.ts\ninterface ContentBlock extends BaseContentBlock {}\ndeclare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\ndeclare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n export { Tools };\n export { Multimodal };\n export { Data };\n export type Standard = Text | Reasoning | Tools.Standard | Multimodal.Standard;\n}\n//#endregion\nexport { ContentBlock, KNOWN_BLOCK_TYPES };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AAGiC,UAGvBI,YAAAA,SAAqBJ,gBAAgB,CAAA,CAAA;;kBAG7BI,YAAAA,CA8DME;EAAQ;;;EAhBY,OAqBPF,UAAAA,QAAAA,CAAAA;IAAY;;;IAmBlC,SACUI,IAAAA,EAAAA,UAAAA;IAAI;;;IAAmD,MAAA,CAAA,EAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAzChDJ;;;;;;;;;;;;;;;;kBAgBdG,MAAMD,WAAWN;;;;;qCAKEI;;;;;;;;;;;;;;;;;WAiB1BH;WACAC;WACAC;yBACcK,OAAOC,YAAYR,KAAAA,CAAMS,WAAWR,UAAAA,CAAWQ"}
1
+ {"version":3,"file":"index.d.ts","names":["BaseContentBlock","Tools","Multimodal","Data","ContentBlock","KNOWN_BLOCK_TYPES","Citation","Array","Record","TValue","Text","Reasoning","NonStandard","Standard"],"sources":["../../../../../../../langchain-core/dist/messages/content/index.d.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\nimport { Tools } from \"./tools.js\";\nimport { Multimodal } from \"./multimodal.js\";\nimport { Data } from \"./data.js\";\n\n//#region src/messages/content/index.d.ts\ninterface ContentBlock extends BaseContentBlock {}\ndeclare const KNOWN_BLOCK_TYPES: string[];\n// eslint-disable-next-line @typescript-eslint/no-namespace\ndeclare namespace ContentBlock {\n /**\n * Annotation for citing data from a document.\n */\n export interface Citation {\n /**\n * Type of the content block\n */\n readonly type: \"citation\";\n /**\n * Source type for the citation.\n */\n source?: string;\n /**\n * URL of the document source\n */\n url?: string;\n /**\n * Source document title.\n *\n * For example, the page title for a web page or the title of a paper.\n */\n title?: string;\n /**\n * Start index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n startIndex?: number;\n /**\n * End index of the **response text** for which the annotation applies.\n *\n * @see {Text}\n */\n endIndex?: number;\n /**\n * Excerpt of source text being cited.\n */\n citedText?: string;\n }\n /**\n * Text output from a LLM.\n *\n * This typically represents the main text content of a message, such as the response\n * from a language model or the text of a user message.\n */\n export interface Text extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"text\";\n /**\n * Block text.\n */\n text: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n /**\n * Citations and other annotations.\n */\n annotations?: Array<Citation | BaseContentBlock>;\n }\n /**\n * Reasoning output from a LLM.\n */\n export interface Reasoning extends ContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"reasoning\";\n /**\n * Reasoning text.\n *\n * Either the thought summary or the raw reasoning text itself.\n * This is often parsed from `<think>` tags in the model's response.\n */\n reasoning: string;\n /**\n * Index of block in aggregate response. Used during streaming.\n */\n index?: number;\n }\n /**\n * Provider-specific content block.\n *\n * This is used to represent content blocks that are not part of the standard LangChain content model.\n * If a provider's non-standard output includes reasoning and tool calls, it should be\n * the adapter's job to parse that payload and emit the corresponding standard reasoning and tool call blocks.\n */\n export interface NonStandard<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TValue extends Record<string, any> = Record<string, any>> extends ContentBlock {\n /**\n * Type of the content block\n */\n type: \"non_standard\";\n /**\n * Provider-specific data\n */\n value: TValue;\n }\n export { Tools };\n export { Multimodal };\n export { Data };\n export type Standard = Text | Reasoning | NonStandard | Tools.Standard | Multimodal.Standard;\n}\n//#endregion\nexport { ContentBlock, KNOWN_BLOCK_TYPES };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AAGiC,UAGvBI,YAAAA,SAAqBJ,gBAAgB,CAAA,CAAA;;kBAG7BI,YAAAA,CA8DME;EAAQ;;;EAhBY,OAqBPF,UAAAA,QAAAA,CAAAA;IAAY;;;IAkChC,SARmDA,IAAAA,EAAAA,UAAAA;IAAY;;;IAYjE,MACUM,CAAAA,EAAAA,MAAAA;IAAI;;;IAA2C,GAAGR,CAAAA,EAAAA,MAAAA;IAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCA5D9DE;;;;;;;;;;;;;;;;kBAgBdG,MAAMD,WAAWN;;;;;qCAKEI;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BpBI,sBAAsBA,6BAA6BJ;;;;;;;;WAQzDK;;WAEAR;WACAC;WACAC;yBACcO,OAAOC,YAAYC,cAAcX,KAAAA,CAAMY,WAAWX,UAAAA,CAAWW"}
@@ -76,7 +76,56 @@ declare namespace Tools {
76
76
  */
77
77
  index?: string | number;
78
78
  }
79
- /** Content block for a built-in web search tool call. */
79
+ interface ServerToolCall<TName extends string = string, TArgs = unknown> extends BaseContentBlock {
80
+ /**
81
+ * Type of the content block
82
+ */
83
+ readonly type: "server_tool_call";
84
+ /**
85
+ * The name of the tool being called
86
+ */
87
+ name: TName;
88
+ /**
89
+ * The arguments to the tool call
90
+ */
91
+ args: TArgs;
92
+ }
93
+ interface ServerToolCallChunk<TName extends string = string> extends BaseContentBlock {
94
+ /**
95
+ * Type of the content block
96
+ */
97
+ readonly type: "server_tool_call_chunk";
98
+ /**
99
+ * The name of the tool being called
100
+ */
101
+ name?: TName;
102
+ /**
103
+ * The arguments to the tool call
104
+ */
105
+ args?: string;
106
+ }
107
+ interface ServerToolCallResult<TOutput = Record<string, unknown>> extends BaseContentBlock {
108
+ /**
109
+ * Type of the content block
110
+ */
111
+ readonly type: "server_tool_call_result";
112
+ /**
113
+ * The unique identifier of the tool call that this result corresponds to
114
+ */
115
+ toolCallId: string;
116
+ /**
117
+ * The status of the server tool call
118
+ */
119
+ status: "success" | "error";
120
+ /**
121
+ * The output of the server tool call
122
+ */
123
+ output: TOutput;
124
+ }
125
+ /**
126
+ * Content block for a built-in web search tool call.
127
+ * @deprecated Use ServerToolCall instead
128
+ */
80
129
  interface WebSearchCall extends BaseContentBlock {
81
130
  /**
82
131
  * Type of the content block
@@ -87,7 +136,10 @@ declare namespace Tools {
87
136
  */
88
137
  query?: string;
89
138
  }
90
- /** Content block for the result of a built-in search tool call */
139
+ /**
140
+ * Content block for the result of a built-in search tool call
141
+ * @deprecated Use ServerToolCallResult instead
142
+ */
91
143
  interface WebSearchResult extends BaseContentBlock {
92
144
  /**
93
145
  * Type of the content block
@@ -98,7 +150,10 @@ declare namespace Tools {
98
150
  */
99
151
  urls?: string[];
100
152
  }
101
- /** Content block for a built-in code interpreter tool call. */
153
+ /**
154
+ * Content block for a built-in code interpreter tool call.
155
+ * @deprecated Use ServerToolCall instead
156
+ */
102
157
  interface CodeInterpreterCall extends BaseContentBlock {
103
158
  /**
104
159
  * Type of the content block
@@ -113,7 +168,10 @@ declare namespace Tools {
113
168
  */
114
169
  code?: string;
115
170
  }
116
- /** Content block for the output of a singular code interpreter tool call */
171
+ /**
172
+ * Content block for the output of a singular code interpreter tool call
173
+ * @deprecated Use ServerToolCallResult instead
174
+ */
117
175
  interface CodeInterpreterOutput {
118
176
  readonly type: "code_interpreter_output";
119
177
  /**
@@ -134,7 +192,10 @@ declare namespace Tools {
134
192
  */
135
193
  fileIds?: string[];
136
194
  }
137
- /** Content block for the result of a code interpreter tool call */
195
+ /**
196
+ * Content block for the result of a code interpreter tool call
197
+ * @deprecated Use ServerToolCallResult instead
198
+ */
138
199
  interface CodeInterpreterResult extends BaseContentBlock {
139
200
  /**
140
201
  * Type of the content block
@@ -145,7 +206,7 @@ declare namespace Tools {
145
206
  */
146
207
  output: CodeInterpreterOutput[];
147
208
  }
148
- type Standard = ToolCall | ToolCallChunk | InvalidToolCall | WebSearchCall | WebSearchResult | CodeInterpreterCall | CodeInterpreterResult;
209
+ type Standard = ToolCall | ToolCallChunk | InvalidToolCall | ServerToolCall | ServerToolCallChunk | ServerToolCallResult | WebSearchCall | WebSearchResult | CodeInterpreterCall | CodeInterpreterResult;
149
210
  }
150
211
  //#endregion
151
212
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","names":["BaseContentBlock","Tools","TName","TArgs","CodeInterpreterOutput","ToolCall","ToolCallChunk","InvalidToolCall","WebSearchCall","WebSearchResult","CodeInterpreterCall","CodeInterpreterResult"],"sources":["../../../../../../../langchain-core/dist/messages/content/tools.d.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\n\n//#region src/messages/content/tools.d.ts\ntype Tools = never;\n// eslint-disable-next-line @typescript-eslint/no-namespace\ndeclare 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 /** Content block for a built-in web search tool call. */\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 /** Content block for the result of a built-in search tool call */\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 /** Content block for a built-in code interpreter tool call. */\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 /** Content block for the output of a singular code interpreter tool call */\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 /** Content block for the result of a code interpreter tool call */\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 | WebSearchCall | WebSearchResult | CodeInterpreterCall | CodeInterpreterResult;\n}\n//#endregion\nexport { Tools };\n//# sourceMappingURL=tools.d.ts.map"],"mappings":";;;;AAA6C,KAGxCC,KAAAA,GAAK,KAAA;AAAA;kBAEQA,KAAAA,CAAK;EAAA;;;;;;;;;;;;;;;EA6IqC,UAAGO,QAAAA,CAAAA,cAAAA,MAAAA,GAAAA,MAAAA,EAAAA,QAAAA,OAAAA,CAAAA,SA7HcR,gBA6HdQ,CAAAA;IAAa;;;IAAgE,SAAA,IAAA,EAAA,WAAA;;;;UArHlIN;;;;UAIAC;;;iEAGuDH;;;;;;;;WAQtDE;;;;;;;;;;;mEAWwDF;;;;;;;;WAQxDE;;;;;;;;;;;;;;;kCAeuBF;;;;;;;;;;;oCAWEA;;;;;;;;;;;wCAWIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CAoCEA;;;;;;;;YAQ9BI;;kBAEMC,WAAWC,gBAAgBC,kBAAkBC,gBAAgBC,kBAAkBC,sBAAsBC"}
1
+ {"version":3,"file":"tools.d.ts","names":["BaseContentBlock","Tools","TName","TArgs","Record","TOutput","CodeInterpreterOutput","ToolCall","ToolCallChunk","InvalidToolCall","ServerToolCall","ServerToolCallChunk","ServerToolCallResult","WebSearchCall","WebSearchResult","CodeInterpreterCall","CodeInterpreterResult"],"sources":["../../../../../../../langchain-core/dist/messages/content/tools.d.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\n\n//#region src/messages/content/tools.d.ts\ntype Tools = never;\n// eslint-disable-next-line @typescript-eslint/no-namespace\ndeclare 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//#endregion\nexport { Tools };\n//# sourceMappingURL=tools.d.ts.map"],"mappings":";;;;AAA6C,KAGxCC,KAAAA,GAAK,KAAA;AAAA;kBAEQA,KAAAA,CAAK;EAAA;;;;;;;;;;;;;;;EAoGqE,UAsB1DD,QAAAA,CAAAA,cAAAA,MAAAA,GAAAA,MAAAA,EAAAA,QAAAA,OAAAA,CAAAA,SA1G2CA,gBA0G3CA,CAAAA;IAAgB;;;IA8EjB,SARSA,IAAAA,EAAAA,WAAAA;IAAgB;;;IAUE,IAAGU,EAlLrDR,KAkLqDQ;IAAc;;;IAA6D,IAAGI,EA9KnIX,KA8KmIW;EAAe;EAAsB;EAAwB,UAAA,aAAA,CAAA,cAAA,MAAA,GAAA,MAAA,CAAA,SA3KzId,gBA2KyI,CAAA;;;;;;;;WAnK/LE;;;;;;;;;;;mEAWwDF;;;;;;;;WAQxDE;;;;;;;;;;;;;;mFAcwEF;;;;;;;;UAQzEE;;;;UAIAC;;uEAE6DH;;;;;;;;WAQ5DE;;;;;;2CAMgCE,iCAAiCJ;;;;;;;;;;;;;;;;YAgBhEK;;;;;;kCAMsBL;;;;;;;;;;;;;;oCAcEA;;;;;;;;;;;;;;wCAcIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0CA0CEA;;;;;;;;YAQ9BM;;kBAEMC,WAAWC,gBAAgBC,kBAAkBC,iBAAiBC,sBAAsBC,uBAAuBC,gBAAgBC,kBAAkBC,sBAAsBC"}
@@ -332,21 +332,21 @@ interface StandardMessageStructure extends MessageStructure {
332
332
  /** Properties specific to AI messages */
333
333
  ai: {
334
334
  /** Metadata about the AI model response */
335
- response_metadata?: ResponseMetadata;
335
+ response_metadata: ResponseMetadata;
336
336
  /** Usage statistics for the AI response */
337
- usage_metadata?: UsageMetadata;
337
+ usage_metadata: UsageMetadata;
338
338
  };
339
339
  human: {
340
340
  /** Metadata about the human message */
341
- response_metadata?: Record<string, unknown>;
341
+ response_metadata: Record<string, unknown>;
342
342
  };
343
343
  system: {
344
344
  /** Metadata about the system message */
345
- response_metadata?: Record<string, unknown>;
345
+ response_metadata: Record<string, unknown>;
346
346
  };
347
347
  tool: {
348
348
  /** Metadata about the tool message */
349
- response_metadata?: Record<string, unknown>;
349
+ response_metadata: Record<string, unknown>;
350
350
  };
351
351
  };
352
352
  }
@@ -532,7 +532,7 @@ type $InferMessageProperty<TStructure extends MessageStructure, TRole extends Me
532
532
  * // HumanResponseMetadata = Record<string, unknown> (fallback since not defined)
533
533
  * ```
534
534
  */
535
- type $InferResponseMetadata<TStructure extends MessageStructure, TRole extends MessageType> = $InferMessageProperty<TStructure, TRole, "response_metadata"> extends infer P ? [P] extends [unknown] ? Record<string, unknown> : P : never;
535
+ type $InferResponseMetadata<TStructure extends MessageStructure, TRole extends MessageType> = $InferMessageProperty<TStructure, TRole, "response_metadata"> extends infer P ? [P] extends [never] ? Record<string, unknown> : P : never;
536
536
  /**
537
537
  * Represents a message object that organizes context for an LLM.
538
538
  *
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","names":["ContentBlock","ResponseMetadata","UsageMetadata","$MergeDiscriminatedUnion","$MergeObjects","MessageType","NonNullable","MessageOutputVersion","MessageToolDefinition","TInput","TOutput","MessageToolSet","$MessageToolCallBlock","MessageStructure","TStructure","K","Tools","ToolCall","Partial","Record","$NormalizeMessageOutputVersion","T","Extract","$MergeOutputVersion","U","TV","UV","Exclude","$MergeContentDefinition","$MergeMessageStructure","StandardMessageStructure","Text","$NormalizedMessageStructure","$InferMessageContentBlocks","S","C","PropertyKey","TRole","$InferMessageContent","Array","$InferMessageProperties","P","Omit","$InferMessageProperty","$InferResponseMetadata","Message","isMessage"],"sources":["../../../../../../langchain-core/dist/messages/message.d.ts"],"sourcesContent":["import { ContentBlock } from \"./content/index.js\";\nimport { ResponseMetadata, UsageMetadata } from \"./metadata.js\";\nimport { $MergeDiscriminatedUnion, $MergeObjects } from \"./utils.js\";\n\n//#region src/messages/message.d.ts\n\n/**\n * Represents the possible types of messages in the system.\n * Includes standard message types (\"ai\", \"human\", \"tool\", \"system\")\n * and allows for custom string types that are non-null.\n *\n * @example\n * ```ts\n * // Standard message types\n * const messageType1: MessageType = \"ai\";\n * const messageType2: MessageType = \"human\";\n *\n * // Custom message type\n * const messageType3: MessageType = \"custom_type\";\n * ```\n */\ntype MessageType = \"ai\" | \"human\" | \"tool\" | \"system\" | (string & NonNullable<unknown>);\n/**\n * Represents the output version format for message content.\n *\n * This type determines how the content field is structured in a message:\n * - \"v0\": Content is represented as a simple string or array of content blocks\n * - provides backward compatibility with simpler content representations\n * - \"v1\": Content follows the structured ContentBlock format with typed discriminated unions\n * - enables full type safety and structured content block handling\n *\n * @example\n * ```ts\n * // v0 format - simple content representation\n * const v0Message: Message<{ outputVersion: \"v0\", content: ... }> = {\n * type: \"human\",\n * content: \"Hello world\" // string | Array<ContentBlock | ContentBlock.Text>\n * };\n *\n * // v1 format - structured content blocks\n * const v1Message: Message<{ outputVersion: \"v1\", content: ... }> = {\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello world\" },\n * { type: \"image\", image_url: \"...\" }\n * ] // Array<ContentBlock | ...> (determined by the structure)\n * };\n * ```\n */\ntype MessageOutputVersion = \"v0\" | \"v1\";\n/**\n * Represents the input and output types of a tool that can be used in messages.\n *\n * @template TInput - The type of input the tool accepts.\n * @template TOutput - The type of output the tool produces.\n *\n * @example\n * ```ts\n * // Tool that takes a string input and returns a number\n * interface StringToNumberTool extends MessageToolDefinition<string, number> {\n * input: string;\n * output: number;\n * }\n * ```\n */\ninterface MessageToolDefinition<TInput = unknown, TOutput = unknown> {\n input: TInput;\n output: TOutput;\n}\n/**\n * Represents a structured set of tools by mapping tool names to definitions\n * that can be used in messages.\n *\n * @example\n * ```ts\n * interface MyToolSet extends MessageToolSet {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * translator: MessageToolDefinition<\n * { text: string; targetLanguage: string },\n * string\n * >;\n * }\n * ```\n */\ninterface MessageToolSet {\n [key: string]: MessageToolDefinition;\n}\n/**\n * Represents a tool call block within a message structure by mapping tool names to their\n * corresponding tool call formats, including the input arguments and an optional identifier.\n *\n * @template TStructure - A message structure type that may contain tool definitions\n *\n * @example\n * ```ts\n * // Given a message structure with a calculator tool:\n * interface MyStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<{ operation: string, numbers: number[] }, number>\n * }\n * }\n *\n * // The tool call block would be:\n * type CalcToolCall = $MessageToolCallBlock<MyStructure>;\n * // Resolves to:\n * // {\n * // type: \"tool_call\";\n * // name: \"calculator\";\n * // args: { operation: string, numbers: number[] };\n * // id?: string;\n * // }\n * ```\n */\ntype $MessageToolCallBlock<TStructure extends MessageStructure> = TStructure[\"tools\"] extends MessageToolSet ? { [K in keyof TStructure[\"tools\"]]: K extends string ? TStructure[\"tools\"][K] extends MessageToolDefinition ? ContentBlock.Tools.ToolCall<K, TStructure[\"tools\"][K][\"input\"]> : never : never }[keyof TStructure[\"tools\"]] : never;\n/**\n * Core interface that defines the structure of messages.\n *\n * @example\n * ```ts\n * // Basic message structure with just content blocks\n * interface SimpleMessageStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * // allows for text + reasoning blocks in ai messages\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * }\n * }\n *\n * // Message structure with tools and properties\n * interface AdvancedMessageStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * };\n * content: {\n * // allows for text + image blocks in human messages\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // only allows for text blocks in ai messages\n * ai: ContentBlock.Text;\n * };\n * properties: {\n * // pins properties to ai messages\n * ai: {\n * response_metadata: {\n * confidence: number;\n * model: string;\n * };\n * };\n * }\n * }\n *\n * // Using with $MergeMessageStructure to combine structures\n * // The resulting type when passed into BaseMessage will have a calculator tool,\n * // allow for text + image blocks in human messages,\n * // and text + reasoning blocks + additional arbitrary properties in ai messages.\n * type CombinedStructure = $MergeMessageStructure<\n * SimpleMessageStructure,\n * AdvancedMessageStructure\n * >;\n *\n * // Using in a Message object\n * const message: Message<CombinedStructure> = {\n * id: \"msg-123\",\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello!\" }\n * { type: \"image\", mimeType: \"image/jpeg\", url: \"https://example.com/image.jpg\" }\n * // this block will throw an error because it's not defined in the structure\n * { type: \"reasoning\", reasoning: \"The answer is 42\" }\n * ]\n * };\n * ```\n */\ninterface MessageStructure {\n /**\n * Optional output version for the message structure.\n * If not provided, defaults to \"v0\".\n */\n readonly outputVersion?: MessageOutputVersion;\n /**\n * Optional set of tool definitions that can be used in messages.\n * Each tool is defined with input/output types and can be referenced in tool messages.\n */\n readonly tools?: MessageToolSet;\n /**\n * Optional mapping of message types to their allowed content blocks.\n * Each message type can specify what content block types it supports (text, images, etc).\n */\n readonly content?: Partial<{ [key in MessageType]: ContentBlock }>;\n /**\n * Optional mapping of message types to arbitrary property objects.\n * Allows attaching custom metadata or other information to specific message types.\n */\n readonly properties?: Partial<{ [key in MessageType]: Record<string, unknown> }>;\n}\n/**\n * Normalizes an arbitrary type to a message output version or undefined.\n * Accepts unknown and narrows to a valid MessageOutputVersion if present.\n */\ntype $NormalizeMessageOutputVersion<T> = Extract<T, MessageOutputVersion> | undefined;\n/**\n * Merges two output version types from message structures.\n *\n * This utility type determines the resulting output version when combining two message structures.\n * The merge logic follows these rules:\n *\n * - If both T and U are undefined, defaults to \"v0\" for backwards compatibility\n * - If T is undefined but U is defined, uses U's version\n * - If U is undefined but T is defined, uses T's version\n * - If both T and U are defined, U takes precedence (later structure wins)\n *\n * @template T - The output version from the first message structure\n * @template U - The output version from the second message structure\n *\n * @example\n * ```ts\n * // Both undefined - defaults to \"v0\"\n * type Result1 = $MergeOutputVersion<undefined, undefined>; // \"v0\"\n *\n * // One defined - uses the defined version\n * type Result2 = $MergeOutputVersion<undefined, \"v1\">; // \"v1\"\n * type Result3 = $MergeOutputVersion<\"v0\", undefined>; // \"v0\"\n *\n * // Both defined - second takes precedence\n * type Result4 = $MergeOutputVersion<\"v0\", \"v1\">; // \"v1\"\n * ```\n */\ntype $MergeOutputVersion<T, U> = $NormalizeMessageOutputVersion<T> extends infer TV ? $NormalizeMessageOutputVersion<U> extends infer UV ? [TV, UV] extends [undefined, undefined] ? \"v0\" : [TV] extends [undefined] ? Exclude<UV, undefined> : [UV] extends [undefined] ? Exclude<TV, undefined> : UV : never : never;\n/**\n * Merges two content definition objects from message structures.\n *\n * This utility type combines content definitions from two message structures, handling\n * the merging of content block types for each message type. The merge logic follows\n * these rules:\n *\n * - For keys that exist in both T and U: Merges the content blocks using discriminated\n * union merging based on the \"type\" property. This allows combining different content\n * block types (e.g., text + image) for the same message type.\n * - For keys that exist only in T: Uses T's content definition as-is\n * - For keys that exist only in U: Uses U's content definition as-is\n *\n * @template T - The content definition from the first message structure\n * @template U - The content definition from the second message structure\n *\n * @example\n * ```ts\n * // T allows text content for human messages\n * type ContentA = {\n * human: ContentBlock.Text;\n * };\n *\n * // U allows image content for human messages and text for AI messages\n * type ContentB = {\n * human: ContentBlock.Multimodal.Image;\n * ai: ContentBlock.Text;\n * };\n *\n * // Merged result allows both text and images for human messages, text for AI\n * type Merged = $MergeContentDefinition<ContentA, ContentB>;\n * // Result: {\n * // human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // ai: ContentBlock.Text;\n * // }\n * ```\n */\ntype $MergeContentDefinition<T, U> = { [K in keyof T | keyof U as Extract<(K extends keyof T ? T[K] : never) | (K extends keyof U ? U[K] : never), ContentBlock> extends never ? never : K]: K extends keyof T ? K extends keyof U ? $MergeDiscriminatedUnion<Extract<T[K], ContentBlock>, Extract<U[K], ContentBlock>, \"type\"> : Extract<T[K], ContentBlock> : K extends keyof U ? Extract<U[K], ContentBlock> : never };\n/**\n * Merges two message structures A and B into a combined structure.\n * This is a type utility that handles merging of tools, content blocks, and properties\n * from two message structures. The resulting type is usable as its own message structure.\n *\n * @example\n * ```ts\n * // Structure A allows text in human messages and has a confidence property on AI messages\n * interface StructureA extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * };\n * properties: {\n * ai: { confidence: number };\n * }\n * }\n *\n * // Structure B allows images in human messages and has a model property on AI messages\n * interface StructureB extends MessageStructure {\n * content: {\n * human: ContentBlock.Multimodal.Image;\n * };\n * properties: {\n * ai: { model: string };\n * }\n * }\n *\n * // Merged structure allows both text and images in human messages\n * // AI messages have both confidence and model properties\n * type Merged = $MergeMessageStructure<StructureA, StructureB>;\n * ```\n *\n * @template A - First message structure to merge\n * @template B - Second message structure to merge (takes precedence over A)\n */\ntype $MergeMessageStructure<T extends MessageStructure, U extends MessageStructure> = {\n outputVersion: $MergeOutputVersion<T[\"outputVersion\"], U[\"outputVersion\"]>;\n tools: $MergeObjects<T[\"tools\"], U[\"tools\"]>;\n content: $MergeContentDefinition<T[\"content\"], U[\"content\"]>;\n properties: $MergeObjects<T[\"properties\"], U[\"properties\"]>;\n};\n/**\n * Standard message structured used to define the most basic message structure that's\n * used throughout the library.\n *\n * This is also the message structure that's used when a message structure is not provided.\n */\ninterface StandardMessageStructure extends MessageStructure {\n content: {\n /** Text content for AI messages */\n ai: ContentBlock.Text;\n /** Text content for human messages */\n human: ContentBlock.Text;\n /** Text content for system messages */\n system: ContentBlock.Text;\n /** Text content for tool messages */\n tool: ContentBlock.Text;\n };\n properties: {\n /** Properties specific to AI messages */\n ai: {\n /** Metadata about the AI model response */\n response_metadata?: ResponseMetadata;\n /** Usage statistics for the AI response */\n usage_metadata?: UsageMetadata;\n };\n human: {\n /** Metadata about the human message */\n response_metadata?: Record<string, unknown>;\n };\n system: {\n /** Metadata about the system message */\n response_metadata?: Record<string, unknown>;\n };\n tool: {\n /** Metadata about the tool message */\n response_metadata?: Record<string, unknown>;\n };\n };\n}\n/**\n * Takes a message structure type T and normalizes it by merging it with the standard message structure.\n * If T is already a standard message structure, returns T unchanged.\n *\n * This ensures that any custom message structure includes all the standard message structure fields\n * by default while allowing overrides and extensions.\n *\n * @template T - The message structure type to normalize, must extend MessageStructure\n * @returns Either T if it's already a standard structure, or the merged result of T with standard structure\n */\ntype $NormalizedMessageStructure<T extends MessageStructure> = T extends StandardMessageStructure ? T : $MergeMessageStructure<StandardMessageStructure, T>;\n/**\n * Infers the content blocks for a specific message type in a message structure.\n *\n * This utility type extracts the content block type that corresponds to a given message type\n * from the message structure's content definition.\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content block type for the specified type, or never if its not defined in the structure\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContent = $InferMessageContentBlocks<MyStructure, \"human\">;\n * // HumanContent = ContentBlock.Text\n *\n * type AIContent = $InferMessageContentBlocks<MyStructure, \"ai\">;\n * // AIContent = ContentBlock.Text | ContentBlock.ToolCall\n * ```\n */\ntype $InferMessageContentBlocks<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"content\"] extends infer C ? C extends Record<PropertyKey, ContentBlock> ? TRole extends keyof C ? [$MessageToolCallBlock<TStructure>] extends [never] ? C[TRole] : $MergeDiscriminatedUnion<NonNullable<C[TRole]>, $MessageToolCallBlock<TStructure>, \"type\"> : never : never : never : never : never;\n/**\n * Infers the content type for a specific message type from a message structure.\n *\n * This utility type determines the appropriate content type based on the message structure's\n * output version and the specified message type. The content type varies depending on the\n * output version (see {@link MessageOutputVersion})\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content type for the specified role based on the output version\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * outputVersion: \"v0\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContentV0 = $InferMessageContent<MyStructure, \"human\">;\n * // HumanContentV0 = string | Array<ContentBlock | ContentBlock.Text>\n *\n * interface MyStructureV1 extends MessageStructure {\n * outputVersion: \"v1\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * };\n * }\n *\n * type HumanContentV1 = $InferMessageContent<MyStructureV1, \"human\">;\n * // HumanContentV1 = ContentBlock.Text\n *\n * type AIContentV1 = $InferMessageContent<MyStructureV1, \"ai\">;\n * // AIContentV1 = ContentBlock.Text | ContentBlock.Reasoning\n * ```\n */\ntype $InferMessageContent<TStructure extends MessageStructure, TRole extends MessageType> = TStructure[\"outputVersion\"] extends \"v1\" ? Array<$InferMessageContentBlocks<TStructure, TRole>> : string | Array<ContentBlock | ContentBlock.Text>;\n/**\n * Infers the properties for a specific message type from a message structure.\n *\n * This utility type extracts the properties object that corresponds to a given message type\n * from the message structure's properties definition, and excludes the reserved\n * \"content\" and \"type\" properties to avoid conflicts with the core message structure.\n *\n * If the specified type is not defined in the message structure's properties, it returns\n * a generic Record<string, unknown> type to allow for arbitrary properties.\n *\n * @template TStructure - The message structure to infer properties from\n * @template TRole - The message type/role to get properties for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The properties object type for the specified type, excluding \"content\" and \"type\"\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string };\n * usage_metadata: { tokens: number };\n * content: string; // This will be omitted\n * type: string; // This will be omitted\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIProperties = $InferMessageProperties<MyStructure, \"ai\">;\n * // AIProperties = { response_metadata: { model: string }; usage_metadata: { tokens: number } }\n *\n * type HumanProperties = $InferMessageProperties<MyStructure, \"human\">;\n * // HumanProperties = { metadata: Record<string, unknown> }\n *\n * type SystemProperties = $InferMessageProperties<MyStructure, \"system\">;\n * // SystemProperties = Record<string, unknown> (fallback for undefined role)\n * ```\n */\ntype $InferMessageProperties<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"properties\"] extends infer P | undefined ? P extends Record<PropertyKey, unknown> ? TRole extends keyof P ? Omit<P[TRole], \"content\" | \"type\"> : Record<string, unknown> : Record<string, unknown> : Record<string, unknown> : never : never;\n/**\n * Infers the type of a specific property for a message type from a message structure.\n *\n * This utility type extracts the type of a single property by name from the properties\n * object that corresponds to a given message type. If the specified property key does\n * not exist in the type's properties, it returns `never`.\n *\n * @template TStructure - The message structure to infer the property from\n * @template TRole - The message type/role to get the property for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @template K - The property key to extract the type for\n * @returns The type of the specified property, or `never` if the property doesn't exist\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number };\n * usage_metadata: { input_tokens: number; output_tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type ResponseMetadata = $InferMessageProperty<MyStructure, \"ai\", \"response_metadata\">;\n * // ResponseMetadata = { model: string; temperature: number }\n *\n * type UsageMetadata = $InferMessageProperty<MyStructure, \"ai\", \"usage_metadata\">;\n * // UsageMetadata = { input_tokens: number; output_tokens: number }\n *\n * type NonExistentProperty = $InferMessageProperty<MyStructure, \"ai\", \"nonExistent\">;\n * // NonExistentProperty = Record<string, unknown>\n *\n * type HumanMetadata = $InferMessageProperty<MyStructure, \"human\", \"metadata\">;\n * // HumanMetadata = Record<string, unknown>\n * ```\n */\ntype $InferMessageProperty<TStructure extends MessageStructure, TRole extends MessageType, K extends string> = K extends keyof $InferMessageProperties<TStructure, TRole> ? $InferMessageProperties<TStructure, TRole>[K] : never;\n/**\n * Infers the response metadata type for a specific message type from a message structure.\n *\n * This utility type extracts the `response_metadata` property type for a given message type.\n *\n * @template TStructure - The message structure to infer the response metadata from\n * @template TRole - The message type/role to get the response metadata for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The type of the response_metadata property, or `Record<string, unknown>` as fallback\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number; tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIResponseMetadata = $InferResponseMetadata<MyStructure, \"ai\">;\n * // AIResponseMetadata = { model: string; temperature: number; tokens: number }\n *\n * type HumanResponseMetadata = $InferResponseMetadata<MyStructure, \"human\">;\n * // HumanResponseMetadata = Record<string, unknown> (fallback since not defined)\n * ```\n */\ntype $InferResponseMetadata<TStructure extends MessageStructure, TRole extends MessageType> = $InferMessageProperty<TStructure, TRole, \"response_metadata\"> extends infer P ? [P] extends [unknown] ? Record<string, unknown> : P : never;\n/**\n * Represents a message object that organizes context for an LLM.\n *\n * @example\n * ```ts\n * // Basic message with text content\n * const message: Message = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"human\",\n * content: [{ type: \"text\", text: \"Hello!\" }]\n * };\n *\n * // Basic ai message interface extension\n * interface MyMessage extends Message<StandardMessageStructure, \"ai\"> {\n * // Additional AI-specific properties can be added here\n * }\n *`\n * // Custom message structure\n * interface CustomStructure extends MessageStructure {\n * content: {\n * ai: ContentBlock.Text | ContentBlock.ToolCall<\"search\", { query: string }>;\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * };\n * }\n *\n * // Create a message with custom structure\n * const message: Message<CustomStructure> = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"ai\",\n * content: [\n * { type: \"text\", text: \"Hello!\" },\n * {\n * type: \"tool_call\",\n * name: \"search\",\n * args: { query: \"What is the capital of France?\" }\n * }\n * ]\n * };\n * ```\n */\ninterface Message<TStructure extends MessageStructure = StandardMessageStructure, TRole extends MessageType = MessageType> {\n /** The message type/role */\n readonly type: TRole;\n /** Unique identifier for this message */\n id?: string;\n /** Optional name/identifier for the entity that created this message */\n name?: string;\n /** Array of content blocks that make up the message content */\n content: $InferMessageContent<TStructure, TRole>;\n /** Metadata about the message */\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n}\n/**\n * Type guard to check if a value is a valid Message object.\n *\n * @param message - The value to check\n * @returns true if the value is a valid Message object, false otherwise\n */\ndeclare function isMessage(message: unknown): message is Message;\n//#endregion\nexport { $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $MergeContentDefinition, $MergeMessageStructure, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, Message, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, StandardMessageStructure, isMessage };\n//# sourceMappingURL=message.d.ts.map"],"mappings":";;;;;;;AAqB6E;AA4BpD;;;;AAkBR;AAAA;AAqBqB;;;;;;;;KAnEjCK,WAAAA,GA+FqLU,IAAAA,GAAAA,OAAAA,GAAAA,MAAAA,GAAAA,QAAAA,GAAAA,CAAAA,MAAAA,GA/FxHT,WA+FwHS,CAAAA,OAAAA,CAAAA,CAAAA;;;;;;;AAAqI;AAAA;;;;;;;;;;AAkFhS;AAAA;;;;;AAMiB;AAAA;;;KA3J3CR,oBAAAA,GAuL4Ba,IAAAA,GAAAA,IAAAA;;;;;;;;;;;;AAAqQ;AAAA;;;UAvK5RZ,qBA6MmDgB,CAAAA,SAAAA,OAAAA,EAAAA,UAAAA,OAAAA,CAAAA,CAAAA;EAAC,KAAaT,EA5MlEN,MA4MkEM;EAAC,MAAeM,EA3MjFX,OA2MiFW;;;;;;;;;;;;;;;;;;;;UAvLjFV,cAAAA,CAuL+RX;EAAY,CAAA,GAAA,EAA1BsB,MAAAA,CAAAA,EAtL1Qd,qBAsL0Qc;;;;;;;;;;;;AAAgG;AAAA;;;;;;;;;;;;;;;KA1JtXV,qBAkMSR,CAAAA,mBAlMgCS,gBAkMhCT,CAAAA,GAlMoDU,UAkMpDV,CAAAA,OAAAA,CAAAA,SAlMgFO,cAkMhFP,GAAAA,QAAAA,MAlM+GU,UAkM/GV,CAAAA,OAAAA,CAAAA,GAlMqIW,CAkMrIX,SAAAA,MAAAA,GAlMwJU,UAkMxJV,CAAAA,OAAAA,CAAAA,CAlM4KW,CAkM5KX,CAAAA,SAlMuLI,qBAkMvLJ,GAlM+MJ,YAAAA,CAAagB,KAAAA,CAAMC,QAkMlOb,CAlM2OW,CAkM3OX,EAlM8OU,UAkM9OV,CAAAA,OAAAA,CAAAA,CAlMkQ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,aAAapC,gBAAgBqC,oBAAoBF,KAAKvB,sBAAsBE,+BAA+BqB,EAAEE,SAASlC,yBAAyBG,YAAY6B,EAAEE,SAASzB,sBAAsBE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwChawB,wCAAwCzB,gCAAgCR,eAAeS,2CAA2CyB,MAAMN,2BAA2BnB,YAAYuB,mBAAmBE,MAAMvC,eAAeA,YAAAA,CAAa+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCpOS,2CAA2C3B,gCAAgCR,eAAe2B,4BAA4BlB,8BAA8BoB,UAAUrB,mBAAmBqB,8CAA8CO,UAAUtB,OAAOiB,wBAAwBC,oBAAoBI,IAAIC,KAAKD,EAAEJ,8BAA8BlB,0BAA0BA,0BAA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsCzXwB,yCAAyC9B,gCAAgCR,iCAAiCU,gBAAgByB,wBAAwB1B,YAAYuB,SAASG,wBAAwB1B,YAAYuB,OAAOtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BlN6B,0CAA0C/B,gCAAgCR,eAAesC,sBAAsB7B,YAAYuB,+CAA+CI,uBAAuBtB,0BAA0BsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2CtNI,2BAA2BhC,mBAAmBiB,wCAAwCzB,cAAcA;;iBAE7FgC;;;;;;WAMNC,qBAAqBxB,YAAYuB;;sBAEtBnB,QAAQ0B,uBAAuB9B,YAAYuB"}
1
+ {"version":3,"file":"message.d.ts","names":["ContentBlock","ResponseMetadata","UsageMetadata","$MergeDiscriminatedUnion","$MergeObjects","MessageType","NonNullable","MessageOutputVersion","MessageToolDefinition","TInput","TOutput","MessageToolSet","$MessageToolCallBlock","MessageStructure","TStructure","K","Tools","ToolCall","Partial","Record","$NormalizeMessageOutputVersion","T","Extract","$MergeOutputVersion","U","TV","UV","Exclude","$MergeContentDefinition","$MergeMessageStructure","StandardMessageStructure","Text","$NormalizedMessageStructure","$InferMessageContentBlocks","S","C","PropertyKey","TRole","$InferMessageContent","Array","$InferMessageProperties","P","Omit","$InferMessageProperty","$InferResponseMetadata","Message","isMessage"],"sources":["../../../../../../langchain-core/dist/messages/message.d.ts"],"sourcesContent":["import { ContentBlock } from \"./content/index.js\";\nimport { ResponseMetadata, UsageMetadata } from \"./metadata.js\";\nimport { $MergeDiscriminatedUnion, $MergeObjects } from \"./utils.js\";\n\n//#region src/messages/message.d.ts\n\n/**\n * Represents the possible types of messages in the system.\n * Includes standard message types (\"ai\", \"human\", \"tool\", \"system\")\n * and allows for custom string types that are non-null.\n *\n * @example\n * ```ts\n * // Standard message types\n * const messageType1: MessageType = \"ai\";\n * const messageType2: MessageType = \"human\";\n *\n * // Custom message type\n * const messageType3: MessageType = \"custom_type\";\n * ```\n */\ntype MessageType = \"ai\" | \"human\" | \"tool\" | \"system\" | (string & NonNullable<unknown>);\n/**\n * Represents the output version format for message content.\n *\n * This type determines how the content field is structured in a message:\n * - \"v0\": Content is represented as a simple string or array of content blocks\n * - provides backward compatibility with simpler content representations\n * - \"v1\": Content follows the structured ContentBlock format with typed discriminated unions\n * - enables full type safety and structured content block handling\n *\n * @example\n * ```ts\n * // v0 format - simple content representation\n * const v0Message: Message<{ outputVersion: \"v0\", content: ... }> = {\n * type: \"human\",\n * content: \"Hello world\" // string | Array<ContentBlock | ContentBlock.Text>\n * };\n *\n * // v1 format - structured content blocks\n * const v1Message: Message<{ outputVersion: \"v1\", content: ... }> = {\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello world\" },\n * { type: \"image\", image_url: \"...\" }\n * ] // Array<ContentBlock | ...> (determined by the structure)\n * };\n * ```\n */\ntype MessageOutputVersion = \"v0\" | \"v1\";\n/**\n * Represents the input and output types of a tool that can be used in messages.\n *\n * @template TInput - The type of input the tool accepts.\n * @template TOutput - The type of output the tool produces.\n *\n * @example\n * ```ts\n * // Tool that takes a string input and returns a number\n * interface StringToNumberTool extends MessageToolDefinition<string, number> {\n * input: string;\n * output: number;\n * }\n * ```\n */\ninterface MessageToolDefinition<TInput = unknown, TOutput = unknown> {\n input: TInput;\n output: TOutput;\n}\n/**\n * Represents a structured set of tools by mapping tool names to definitions\n * that can be used in messages.\n *\n * @example\n * ```ts\n * interface MyToolSet extends MessageToolSet {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * translator: MessageToolDefinition<\n * { text: string; targetLanguage: string },\n * string\n * >;\n * }\n * ```\n */\ninterface MessageToolSet {\n [key: string]: MessageToolDefinition;\n}\n/**\n * Represents a tool call block within a message structure by mapping tool names to their\n * corresponding tool call formats, including the input arguments and an optional identifier.\n *\n * @template TStructure - A message structure type that may contain tool definitions\n *\n * @example\n * ```ts\n * // Given a message structure with a calculator tool:\n * interface MyStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<{ operation: string, numbers: number[] }, number>\n * }\n * }\n *\n * // The tool call block would be:\n * type CalcToolCall = $MessageToolCallBlock<MyStructure>;\n * // Resolves to:\n * // {\n * // type: \"tool_call\";\n * // name: \"calculator\";\n * // args: { operation: string, numbers: number[] };\n * // id?: string;\n * // }\n * ```\n */\ntype $MessageToolCallBlock<TStructure extends MessageStructure> = TStructure[\"tools\"] extends MessageToolSet ? { [K in keyof TStructure[\"tools\"]]: K extends string ? TStructure[\"tools\"][K] extends MessageToolDefinition ? ContentBlock.Tools.ToolCall<K, TStructure[\"tools\"][K][\"input\"]> : never : never }[keyof TStructure[\"tools\"]] : never;\n/**\n * Core interface that defines the structure of messages.\n *\n * @example\n * ```ts\n * // Basic message structure with just content blocks\n * interface SimpleMessageStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * // allows for text + reasoning blocks in ai messages\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * }\n * }\n *\n * // Message structure with tools and properties\n * interface AdvancedMessageStructure extends MessageStructure {\n * tools: {\n * calculator: MessageToolDefinition<\n * { operation: string; numbers: number[] },\n * number\n * >;\n * };\n * content: {\n * // allows for text + image blocks in human messages\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // only allows for text blocks in ai messages\n * ai: ContentBlock.Text;\n * };\n * properties: {\n * // pins properties to ai messages\n * ai: {\n * response_metadata: {\n * confidence: number;\n * model: string;\n * };\n * };\n * }\n * }\n *\n * // Using with $MergeMessageStructure to combine structures\n * // The resulting type when passed into BaseMessage will have a calculator tool,\n * // allow for text + image blocks in human messages,\n * // and text + reasoning blocks + additional arbitrary properties in ai messages.\n * type CombinedStructure = $MergeMessageStructure<\n * SimpleMessageStructure,\n * AdvancedMessageStructure\n * >;\n *\n * // Using in a Message object\n * const message: Message<CombinedStructure> = {\n * id: \"msg-123\",\n * type: \"human\",\n * content: [\n * { type: \"text\", text: \"Hello!\" }\n * { type: \"image\", mimeType: \"image/jpeg\", url: \"https://example.com/image.jpg\" }\n * // this block will throw an error because it's not defined in the structure\n * { type: \"reasoning\", reasoning: \"The answer is 42\" }\n * ]\n * };\n * ```\n */\ninterface MessageStructure {\n /**\n * Optional output version for the message structure.\n * If not provided, defaults to \"v0\".\n */\n readonly outputVersion?: MessageOutputVersion;\n /**\n * Optional set of tool definitions that can be used in messages.\n * Each tool is defined with input/output types and can be referenced in tool messages.\n */\n readonly tools?: MessageToolSet;\n /**\n * Optional mapping of message types to their allowed content blocks.\n * Each message type can specify what content block types it supports (text, images, etc).\n */\n readonly content?: Partial<{ [key in MessageType]: ContentBlock }>;\n /**\n * Optional mapping of message types to arbitrary property objects.\n * Allows attaching custom metadata or other information to specific message types.\n */\n readonly properties?: Partial<{ [key in MessageType]: Record<string, unknown> }>;\n}\n/**\n * Normalizes an arbitrary type to a message output version or undefined.\n * Accepts unknown and narrows to a valid MessageOutputVersion if present.\n */\ntype $NormalizeMessageOutputVersion<T> = Extract<T, MessageOutputVersion> | undefined;\n/**\n * Merges two output version types from message structures.\n *\n * This utility type determines the resulting output version when combining two message structures.\n * The merge logic follows these rules:\n *\n * - If both T and U are undefined, defaults to \"v0\" for backwards compatibility\n * - If T is undefined but U is defined, uses U's version\n * - If U is undefined but T is defined, uses T's version\n * - If both T and U are defined, U takes precedence (later structure wins)\n *\n * @template T - The output version from the first message structure\n * @template U - The output version from the second message structure\n *\n * @example\n * ```ts\n * // Both undefined - defaults to \"v0\"\n * type Result1 = $MergeOutputVersion<undefined, undefined>; // \"v0\"\n *\n * // One defined - uses the defined version\n * type Result2 = $MergeOutputVersion<undefined, \"v1\">; // \"v1\"\n * type Result3 = $MergeOutputVersion<\"v0\", undefined>; // \"v0\"\n *\n * // Both defined - second takes precedence\n * type Result4 = $MergeOutputVersion<\"v0\", \"v1\">; // \"v1\"\n * ```\n */\ntype $MergeOutputVersion<T, U> = $NormalizeMessageOutputVersion<T> extends infer TV ? $NormalizeMessageOutputVersion<U> extends infer UV ? [TV, UV] extends [undefined, undefined] ? \"v0\" : [TV] extends [undefined] ? Exclude<UV, undefined> : [UV] extends [undefined] ? Exclude<TV, undefined> : UV : never : never;\n/**\n * Merges two content definition objects from message structures.\n *\n * This utility type combines content definitions from two message structures, handling\n * the merging of content block types for each message type. The merge logic follows\n * these rules:\n *\n * - For keys that exist in both T and U: Merges the content blocks using discriminated\n * union merging based on the \"type\" property. This allows combining different content\n * block types (e.g., text + image) for the same message type.\n * - For keys that exist only in T: Uses T's content definition as-is\n * - For keys that exist only in U: Uses U's content definition as-is\n *\n * @template T - The content definition from the first message structure\n * @template U - The content definition from the second message structure\n *\n * @example\n * ```ts\n * // T allows text content for human messages\n * type ContentA = {\n * human: ContentBlock.Text;\n * };\n *\n * // U allows image content for human messages and text for AI messages\n * type ContentB = {\n * human: ContentBlock.Multimodal.Image;\n * ai: ContentBlock.Text;\n * };\n *\n * // Merged result allows both text and images for human messages, text for AI\n * type Merged = $MergeContentDefinition<ContentA, ContentB>;\n * // Result: {\n * // human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * // ai: ContentBlock.Text;\n * // }\n * ```\n */\ntype $MergeContentDefinition<T, U> = { [K in keyof T | keyof U as Extract<(K extends keyof T ? T[K] : never) | (K extends keyof U ? U[K] : never), ContentBlock> extends never ? never : K]: K extends keyof T ? K extends keyof U ? $MergeDiscriminatedUnion<Extract<T[K], ContentBlock>, Extract<U[K], ContentBlock>, \"type\"> : Extract<T[K], ContentBlock> : K extends keyof U ? Extract<U[K], ContentBlock> : never };\n/**\n * Merges two message structures A and B into a combined structure.\n * This is a type utility that handles merging of tools, content blocks, and properties\n * from two message structures. The resulting type is usable as its own message structure.\n *\n * @example\n * ```ts\n * // Structure A allows text in human messages and has a confidence property on AI messages\n * interface StructureA extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * };\n * properties: {\n * ai: { confidence: number };\n * }\n * }\n *\n * // Structure B allows images in human messages and has a model property on AI messages\n * interface StructureB extends MessageStructure {\n * content: {\n * human: ContentBlock.Multimodal.Image;\n * };\n * properties: {\n * ai: { model: string };\n * }\n * }\n *\n * // Merged structure allows both text and images in human messages\n * // AI messages have both confidence and model properties\n * type Merged = $MergeMessageStructure<StructureA, StructureB>;\n * ```\n *\n * @template A - First message structure to merge\n * @template B - Second message structure to merge (takes precedence over A)\n */\ntype $MergeMessageStructure<T extends MessageStructure, U extends MessageStructure> = {\n outputVersion: $MergeOutputVersion<T[\"outputVersion\"], U[\"outputVersion\"]>;\n tools: $MergeObjects<T[\"tools\"], U[\"tools\"]>;\n content: $MergeContentDefinition<T[\"content\"], U[\"content\"]>;\n properties: $MergeObjects<T[\"properties\"], U[\"properties\"]>;\n};\n/**\n * Standard message structured used to define the most basic message structure that's\n * used throughout the library.\n *\n * This is also the message structure that's used when a message structure is not provided.\n */\ninterface StandardMessageStructure extends MessageStructure {\n content: {\n /** Text content for AI messages */\n ai: ContentBlock.Text;\n /** Text content for human messages */\n human: ContentBlock.Text;\n /** Text content for system messages */\n system: ContentBlock.Text;\n /** Text content for tool messages */\n tool: ContentBlock.Text;\n };\n properties: {\n /** Properties specific to AI messages */\n ai: {\n /** Metadata about the AI model response */\n response_metadata: ResponseMetadata;\n /** Usage statistics for the AI response */\n usage_metadata: UsageMetadata;\n };\n human: {\n /** Metadata about the human message */\n response_metadata: Record<string, unknown>;\n };\n system: {\n /** Metadata about the system message */\n response_metadata: Record<string, unknown>;\n };\n tool: {\n /** Metadata about the tool message */\n response_metadata: Record<string, unknown>;\n };\n };\n}\n/**\n * Takes a message structure type T and normalizes it by merging it with the standard message structure.\n * If T is already a standard message structure, returns T unchanged.\n *\n * This ensures that any custom message structure includes all the standard message structure fields\n * by default while allowing overrides and extensions.\n *\n * @template T - The message structure type to normalize, must extend MessageStructure\n * @returns Either T if it's already a standard structure, or the merged result of T with standard structure\n */\ntype $NormalizedMessageStructure<T extends MessageStructure> = T extends StandardMessageStructure ? T : $MergeMessageStructure<StandardMessageStructure, T>;\n/**\n * Infers the content blocks for a specific message type in a message structure.\n *\n * This utility type extracts the content block type that corresponds to a given message type\n * from the message structure's content definition.\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content block type for the specified type, or never if its not defined in the structure\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContent = $InferMessageContentBlocks<MyStructure, \"human\">;\n * // HumanContent = ContentBlock.Text\n *\n * type AIContent = $InferMessageContentBlocks<MyStructure, \"ai\">;\n * // AIContent = ContentBlock.Text | ContentBlock.ToolCall\n * ```\n */\ntype $InferMessageContentBlocks<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"content\"] extends infer C ? C extends Record<PropertyKey, ContentBlock> ? TRole extends keyof C ? [$MessageToolCallBlock<TStructure>] extends [never] ? C[TRole] : $MergeDiscriminatedUnion<NonNullable<C[TRole]>, $MessageToolCallBlock<TStructure>, \"type\"> : never : never : never : never : never;\n/**\n * Infers the content type for a specific message type from a message structure.\n *\n * This utility type determines the appropriate content type based on the message structure's\n * output version and the specified message type. The content type varies depending on the\n * output version (see {@link MessageOutputVersion})\n *\n * @template TStructure - The message structure to infer content from\n * @template TRole - The message role/type to get content for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The content type for the specified role based on the output version\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * outputVersion: \"v0\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.ToolCall;\n * };\n * }\n *\n * type HumanContentV0 = $InferMessageContent<MyStructure, \"human\">;\n * // HumanContentV0 = string | Array<ContentBlock | ContentBlock.Text>\n *\n * interface MyStructureV1 extends MessageStructure {\n * outputVersion: \"v1\";\n * content: {\n * human: ContentBlock.Text;\n * ai: ContentBlock.Text | ContentBlock.Reasoning;\n * };\n * }\n *\n * type HumanContentV1 = $InferMessageContent<MyStructureV1, \"human\">;\n * // HumanContentV1 = ContentBlock.Text\n *\n * type AIContentV1 = $InferMessageContent<MyStructureV1, \"ai\">;\n * // AIContentV1 = ContentBlock.Text | ContentBlock.Reasoning\n * ```\n */\ntype $InferMessageContent<TStructure extends MessageStructure, TRole extends MessageType> = TStructure[\"outputVersion\"] extends \"v1\" ? Array<$InferMessageContentBlocks<TStructure, TRole>> : string | Array<ContentBlock | ContentBlock.Text>;\n/**\n * Infers the properties for a specific message type from a message structure.\n *\n * This utility type extracts the properties object that corresponds to a given message type\n * from the message structure's properties definition, and excludes the reserved\n * \"content\" and \"type\" properties to avoid conflicts with the core message structure.\n *\n * If the specified type is not defined in the message structure's properties, it returns\n * a generic Record<string, unknown> type to allow for arbitrary properties.\n *\n * @template TStructure - The message structure to infer properties from\n * @template TRole - The message type/role to get properties for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The properties object type for the specified type, excluding \"content\" and \"type\"\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string };\n * usage_metadata: { tokens: number };\n * content: string; // This will be omitted\n * type: string; // This will be omitted\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIProperties = $InferMessageProperties<MyStructure, \"ai\">;\n * // AIProperties = { response_metadata: { model: string }; usage_metadata: { tokens: number } }\n *\n * type HumanProperties = $InferMessageProperties<MyStructure, \"human\">;\n * // HumanProperties = { metadata: Record<string, unknown> }\n *\n * type SystemProperties = $InferMessageProperties<MyStructure, \"system\">;\n * // SystemProperties = Record<string, unknown> (fallback for undefined role)\n * ```\n */\ntype $InferMessageProperties<TStructure extends MessageStructure, TRole extends MessageType> = $NormalizedMessageStructure<TStructure> extends infer S ? S extends MessageStructure ? S[\"properties\"] extends infer P | undefined ? P extends Record<PropertyKey, unknown> ? TRole extends keyof P ? Omit<P[TRole], \"content\" | \"type\"> : Record<string, unknown> : Record<string, unknown> : Record<string, unknown> : never : never;\n/**\n * Infers the type of a specific property for a message type from a message structure.\n *\n * This utility type extracts the type of a single property by name from the properties\n * object that corresponds to a given message type. If the specified property key does\n * not exist in the type's properties, it returns `never`.\n *\n * @template TStructure - The message structure to infer the property from\n * @template TRole - The message type/role to get the property for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @template K - The property key to extract the type for\n * @returns The type of the specified property, or `never` if the property doesn't exist\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number };\n * usage_metadata: { input_tokens: number; output_tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type ResponseMetadata = $InferMessageProperty<MyStructure, \"ai\", \"response_metadata\">;\n * // ResponseMetadata = { model: string; temperature: number }\n *\n * type UsageMetadata = $InferMessageProperty<MyStructure, \"ai\", \"usage_metadata\">;\n * // UsageMetadata = { input_tokens: number; output_tokens: number }\n *\n * type NonExistentProperty = $InferMessageProperty<MyStructure, \"ai\", \"nonExistent\">;\n * // NonExistentProperty = Record<string, unknown>\n *\n * type HumanMetadata = $InferMessageProperty<MyStructure, \"human\", \"metadata\">;\n * // HumanMetadata = Record<string, unknown>\n * ```\n */\ntype $InferMessageProperty<TStructure extends MessageStructure, TRole extends MessageType, K extends string> = K extends keyof $InferMessageProperties<TStructure, TRole> ? $InferMessageProperties<TStructure, TRole>[K] : never;\n/**\n * Infers the response metadata type for a specific message type from a message structure.\n *\n * This utility type extracts the `response_metadata` property type for a given message type.\n *\n * @template TStructure - The message structure to infer the response metadata from\n * @template TRole - The message type/role to get the response metadata for (e.g., \"ai\", \"human\", \"system\", \"tool\")\n * @returns The type of the response_metadata property, or `Record<string, unknown>` as fallback\n *\n * @example\n * ```ts\n * interface MyStructure extends MessageStructure {\n * properties: {\n * ai: {\n * response_metadata: { model: string; temperature: number; tokens: number };\n * };\n * human: { metadata: Record<string, unknown> };\n * };\n * }\n *\n * type AIResponseMetadata = $InferResponseMetadata<MyStructure, \"ai\">;\n * // AIResponseMetadata = { model: string; temperature: number; tokens: number }\n *\n * type HumanResponseMetadata = $InferResponseMetadata<MyStructure, \"human\">;\n * // HumanResponseMetadata = Record<string, unknown> (fallback since not defined)\n * ```\n */\ntype $InferResponseMetadata<TStructure extends MessageStructure, TRole extends MessageType> = $InferMessageProperty<TStructure, TRole, \"response_metadata\"> extends infer P ? [P] extends [never] ? Record<string, unknown> : P : never;\n/**\n * Represents a message object that organizes context for an LLM.\n *\n * @example\n * ```ts\n * // Basic message with text content\n * const message: Message = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"human\",\n * content: [{ type: \"text\", text: \"Hello!\" }]\n * };\n *\n * // Basic ai message interface extension\n * interface MyMessage extends Message<StandardMessageStructure, \"ai\"> {\n * // Additional AI-specific properties can be added here\n * }\n *`\n * // Custom message structure\n * interface CustomStructure extends MessageStructure {\n * content: {\n * ai: ContentBlock.Text | ContentBlock.ToolCall<\"search\", { query: string }>;\n * human: ContentBlock.Text | ContentBlock.Multimodal.Image;\n * };\n * }\n *\n * // Create a message with custom structure\n * const message: Message<CustomStructure> = {\n * id: \"msg-123\",\n * name: \"user\",\n * type: \"ai\",\n * content: [\n * { type: \"text\", text: \"Hello!\" },\n * {\n * type: \"tool_call\",\n * name: \"search\",\n * args: { query: \"What is the capital of France?\" }\n * }\n * ]\n * };\n * ```\n */\ninterface Message<TStructure extends MessageStructure = StandardMessageStructure, TRole extends MessageType = MessageType> {\n /** The message type/role */\n readonly type: TRole;\n /** Unique identifier for this message */\n id?: string;\n /** Optional name/identifier for the entity that created this message */\n name?: string;\n /** Array of content blocks that make up the message content */\n content: $InferMessageContent<TStructure, TRole>;\n /** Metadata about the message */\n response_metadata?: Partial<$InferResponseMetadata<TStructure, TRole>>;\n}\n/**\n * Type guard to check if a value is a valid Message object.\n *\n * @param message - The value to check\n * @returns true if the value is a valid Message object, false otherwise\n */\ndeclare function isMessage(message: unknown): message is Message;\n//#endregion\nexport { $InferMessageContent, $InferMessageContentBlocks, $InferMessageProperties, $InferMessageProperty, $InferResponseMetadata, $MergeContentDefinition, $MergeMessageStructure, $MergeOutputVersion, $MessageToolCallBlock, $NormalizedMessageStructure, Message, MessageOutputVersion, MessageStructure, MessageToolDefinition, MessageToolSet, MessageType, StandardMessageStructure, isMessage };\n//# sourceMappingURL=message.d.ts.map"],"mappings":";;;;;;;AAqB6E;AA4BpD;;;;AAkBR;AAAA;AAqBqB;;;;;;;;KAnEjCK,WAAAA,GA+FqLU,IAAAA,GAAAA,OAAAA,GAAAA,MAAAA,GAAAA,QAAAA,GAAAA,CAAAA,MAAAA,GA/FxHT,WA+FwHS,CAAAA,OAAAA,CAAAA,CAAAA;;;;;;;AAAqI;AAAA;;;;;;;;;;AAkFhS;AAAA;;;;;AAMiB;AAAA;;;KA3J3CR,oBAAAA,GAuL4Ba,IAAAA,GAAAA,IAAAA;;;;;;;;;;;;AAAqQ;AAAA;;;UAvK5RZ,qBA6MmDgB,CAAAA,SAAAA,OAAAA,EAAAA,UAAAA,OAAAA,CAAAA,CAAAA;EA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B,YAAYuB,SAASG,wBAAwB1B,YAAYuB,OAAOtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BlN6B,0CAA0C/B,gCAAgCR,eAAesC,sBAAsB7B,YAAYuB,+CAA+CI,qBAAqBtB,0BAA0BsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA2CpNI,2BAA2BhC,mBAAmBiB,wCAAwCzB,cAAcA;;iBAE7FgC;;;;;;WAMNC,qBAAqBxB,YAAYuB;;sBAEtBnB,QAAQ0B,uBAAuB9B,YAAYuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["InferInteropZodInput","InferInteropZodOutput","InteropZodIssue","InteropZodObject","InteropZodObjectShape","InteropZodType","Mutable","ZodObjectV3","ZodObjectV4","ZodStringV3","ZodStringV4","extendInteropZodObject","getInteropZodDefaultGetter","getInteropZodObjectShape","getSchemaDescription","interopParse","interopParseAsync","interopSafeParse","interopSafeParseAsync","interopZodObjectPartial","interopZodObjectPassthrough","interopZodObjectStrict","interopZodTransformInputSchema","isInteropZodObject","isInteropZodSchema","isShapelessZodSchema","isSimpleStringZodSchema","isZodArrayV4","isZodObjectV3","isZodObjectV4","isZodSchema","isZodSchemaV3","isZodSchemaV4","StringWithAutocomplete","T","Record","InputValues","K","PartialValues","Promise","ChainValues"],"sources":["../../../../../../../langchain-core/dist/utils/types/index.d.ts"],"sourcesContent":["import { InferInteropZodInput, InferInteropZodOutput, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodType, Mutable, ZodObjectV3, ZodObjectV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from \"./zod.js\";\n\n//#region src/utils/types/index.d.ts\n\n/**\n * Represents a string value with autocompleted, but not required, suggestions.\n */\ntype StringWithAutocomplete<T> = T | (string & Record<never, never>);\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InputValues<K extends string = string> = Record<K, any>;\ntype PartialValues<K extends string = string> = Record<K, string | (() => Promise<string>) | (() => string)>;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ChainValues = Record<string, any>;\n//#endregion\nexport { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodObjectV3, ZodObjectV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;KAYKwC,WAAAA,GAAcL"}
1
+ {"version":3,"file":"index.d.ts","names":["InferInteropZodInput","InferInteropZodOutput","InteropZodDefault","InteropZodIssue","InteropZodObject","InteropZodObjectShape","InteropZodOptional","InteropZodType","Mutable","ZodDefaultV3","ZodDefaultV4","ZodObjectV3","ZodObjectV4","ZodOptionalV3","ZodOptionalV4","ZodStringV3","ZodStringV4","extendInteropZodObject","getInteropZodDefaultGetter","getInteropZodObjectShape","getSchemaDescription","interopParse","interopParseAsync","interopSafeParse","interopSafeParseAsync","interopZodObjectMakeFieldsOptional","interopZodObjectPartial","interopZodObjectPassthrough","interopZodObjectStrict","interopZodTransformInputSchema","isInteropZodObject","isInteropZodSchema","isShapelessZodSchema","isSimpleStringZodSchema","isZodArrayV4","isZodObjectV3","isZodObjectV4","isZodSchema","isZodSchemaV3","isZodSchemaV4","StringWithAutocomplete","T","Record","InputValues","K","PartialValues","Promise","ChainValues"],"sources":["../../../../../../../langchain-core/dist/utils/types/index.d.ts"],"sourcesContent":["import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from \"./zod.js\";\n\n//#region src/utils/types/index.d.ts\n\n/**\n * Represents a string value with autocompleted, but not required, suggestions.\n */\ntype StringWithAutocomplete<T> = T | (string & Record<never, never>);\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype InputValues<K extends string = string> = Record<K, any>;\ntype PartialValues<K extends string = string> = Record<K, string | (() => Promise<string>) | (() => string)>;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ChainValues = Record<string, any>;\n//#endregion\nexport { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;KAYK+C,WAAAA,GAAcL"}
@@ -1,6 +1,7 @@
1
1
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
2
  const require_document = require('../document.cjs');
3
3
  const require_chat_models_universal = require('../chat_models/universal.cjs');
4
+ const require_agents_middlewareAgent_middleware_index = require('../agents/middlewareAgent/middleware/index.cjs');
4
5
  const require_index = require('../index.cjs');
5
6
  const require_sql_db = require('../sql_db.cjs');
6
7
  const require_text_splitter = require('../text_splitter.cjs');
@@ -32,7 +33,6 @@ const require_chains_query_constructor_ir = require('../chains/query_constructor
32
33
  const require_chains_sql_db_index = require('../chains/sql_db/index.cjs');
33
34
  const require_chains_graph_qa_cypher = require('../chains/graph_qa/cypher.cjs');
34
35
  const require_memory_index = require('../memory/index.cjs');
35
- const require_agents_middlewareAgent_middleware_index = require('../agents/middlewareAgent/middleware/index.cjs');
36
36
  const require_document_loaders_fs_buffer = require('../document_loaders/fs/buffer.cjs');
37
37
  const require_document_loaders_fs_directory = require('../document_loaders/fs/directory.cjs');
38
38
  const require_document_loaders_fs_text = require('../document_loaders/fs/text.cjs');
@@ -1,6 +1,7 @@
1
1
  import { __export } from "../_virtual/rolldown_runtime.js";
2
2
  import { document_exports } from "../document.js";
3
3
  import { universal_exports } from "../chat_models/universal.js";
4
+ import { middleware_exports } from "../agents/middlewareAgent/middleware/index.js";
4
5
  import { src_exports } from "../index.js";
5
6
  import { sql_db_exports } from "../sql_db.js";
6
7
  import { text_splitter_exports } from "../text_splitter.js";
@@ -32,7 +33,6 @@ import { ir_exports } from "../chains/query_constructor/ir.js";
32
33
  import { sql_db_exports as sql_db_exports$1 } from "../chains/sql_db/index.js";
33
34
  import { cypher_exports } from "../chains/graph_qa/cypher.js";
34
35
  import { memory_exports as memory_exports$1 } from "../memory/index.js";
35
- import { middleware_exports } from "../agents/middlewareAgent/middleware/index.js";
36
36
  import { buffer_exports } from "../document_loaders/fs/buffer.js";
37
37
  import { directory_exports } from "../document_loaders/fs/directory.js";
38
38
  import { text_exports } from "../document_loaders/fs/text.js";
@@ -1,6 +1,6 @@
1
1
  import { serializable_d_exports } from "../load/serializable.cjs";
2
- import { z } from "zod/v3";
3
2
  import { InferInteropZodOutput, InteropZodType } from "@langchain/core/utils/types";
3
+ import { z } from "zod/v3";
4
4
  import { BaseOutputParser, FormatInstructionsOptions } from "@langchain/core/output_parsers";
5
5
 
6
6
  //#region src/output_parsers/structured.d.ts
@@ -1,7 +1,7 @@
1
1
  import { BaseFileStore } from "../stores/file/base.cjs";
2
- import { z } from "zod/v3";
3
2
  import { InferInteropZodOutput } from "@langchain/core/utils/types";
4
3
  import { StructuredTool, ToolParams } from "@langchain/core/tools";
4
+ import { z } from "zod/v3";
5
5
 
6
6
  //#region src/tools/fs.d.ts
7
7
 
@@ -1,5 +1,5 @@
1
- import { z } from "zod/v3";
2
1
  import { DynamicStructuredTool, DynamicStructuredToolInput } from "@langchain/core/tools";
2
+ import { z } from "zod/v3";
3
3
  import { BaseRetrieverInterface } from "@langchain/core/retrievers";
4
4
 
5
5
  //#region src/tools/retriever.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.7",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -39,14 +39,14 @@
39
39
  "typeorm": "^0.3.20",
40
40
  "typescript": "~5.8.3",
41
41
  "vitest": "^3.2.4",
42
- "@langchain/core": "1.0.0-alpha.4",
43
- "@langchain/openai": "1.0.0-alpha.1",
42
+ "@langchain/anthropic": "1.0.0-alpha.1",
44
43
  "@langchain/cohere": "0.3.4",
45
- "@langchain/eslint": "0.1.0",
46
- "@langchain/anthropic": "1.0.0-alpha.1"
44
+ "@langchain/core": "1.0.0-alpha.6",
45
+ "@langchain/openai": "1.0.0-alpha.1",
46
+ "@langchain/eslint": "0.1.0"
47
47
  },
48
48
  "peerDependencies": {
49
- "@langchain/core": "^1.0.0-alpha.3 <2.0.0",
49
+ "@langchain/core": "^1.0.0-alpha.6 <2.0.0",
50
50
  "cheerio": "*",
51
51
  "peggy": "^3.0.2",
52
52
  "typeorm": "*"
@@ -63,7 +63,7 @@
63
63
  }
64
64
  },
65
65
  "dependencies": {
66
- "@langchain/langgraph": "^1.0.0-alpha",
66
+ "@langchain/langgraph": "next",
67
67
  "@langchain/langgraph-checkpoint": "^0.1.1",
68
68
  "js-yaml": "^4.1.0",
69
69
  "jsonpointer": "^5.0.1",