ai 3.4.25 → 3.4.26
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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +23 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
@@ -4721,7 +4721,9 @@ function attachmentsToParts(attachments) {
|
|
4721
4721
|
}
|
4722
4722
|
|
4723
4723
|
// core/prompt/convert-to-core-messages.ts
|
4724
|
-
function convertToCoreMessages(messages) {
|
4724
|
+
function convertToCoreMessages(messages, options) {
|
4725
|
+
var _a11;
|
4726
|
+
const tools = (_a11 = options == null ? void 0 : options.tools) != null ? _a11 : {};
|
4725
4727
|
const coreMessages = [];
|
4726
4728
|
for (const message of messages) {
|
4727
4729
|
const { role, content, toolInvocations, experimental_attachments } = message;
|
@@ -4752,29 +4754,37 @@ function convertToCoreMessages(messages) {
|
|
4752
4754
|
role: "assistant",
|
4753
4755
|
content: [
|
4754
4756
|
{ type: "text", text: content },
|
4755
|
-
...toolInvocations.map(
|
4756
|
-
|
4757
|
-
|
4758
|
-
|
4759
|
-
|
4760
|
-
|
4757
|
+
...toolInvocations.map(
|
4758
|
+
({ toolCallId, toolName, args }) => ({
|
4759
|
+
type: "tool-call",
|
4760
|
+
toolCallId,
|
4761
|
+
toolName,
|
4762
|
+
args
|
4763
|
+
})
|
4764
|
+
)
|
4761
4765
|
]
|
4762
4766
|
});
|
4763
4767
|
coreMessages.push({
|
4764
4768
|
role: "tool",
|
4765
|
-
content: toolInvocations.map((
|
4766
|
-
if (!("result" in
|
4769
|
+
content: toolInvocations.map((toolInvocation) => {
|
4770
|
+
if (!("result" in toolInvocation)) {
|
4767
4771
|
throw new MessageConversionError({
|
4768
4772
|
originalMessage: message,
|
4769
|
-
message: "ToolInvocation must have a result: " + JSON.stringify(
|
4773
|
+
message: "ToolInvocation must have a result: " + JSON.stringify(toolInvocation)
|
4770
4774
|
});
|
4771
4775
|
}
|
4772
|
-
const { toolCallId, toolName,
|
4773
|
-
|
4776
|
+
const { toolCallId, toolName, result } = toolInvocation;
|
4777
|
+
const tool2 = tools[toolName];
|
4778
|
+
return (tool2 == null ? void 0 : tool2.experimental_toToolResultContent) != null ? {
|
4779
|
+
type: "tool-result",
|
4780
|
+
toolCallId,
|
4781
|
+
toolName,
|
4782
|
+
result: tool2.experimental_toToolResultContent(result),
|
4783
|
+
experimental_content: tool2.experimental_toToolResultContent(result)
|
4784
|
+
} : {
|
4774
4785
|
type: "tool-result",
|
4775
4786
|
toolCallId,
|
4776
4787
|
toolName,
|
4777
|
-
args,
|
4778
4788
|
result
|
4779
4789
|
};
|
4780
4790
|
})
|