ai 4.1.11 → 4.1.12
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 +10 -0
- package/dist/index.js +113 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +93 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/rsc/dist/rsc-server.mjs +54 -37
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ai",
|
3
|
-
"version": "4.1.
|
3
|
+
"version": "4.1.12",
|
4
4
|
"description": "AI SDK by Vercel - The AI Toolkit for TypeScript and JavaScript",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"sideEffects": false,
|
@@ -42,8 +42,8 @@
|
|
42
42
|
"dependencies": {
|
43
43
|
"@ai-sdk/provider": "1.0.6",
|
44
44
|
"@ai-sdk/provider-utils": "2.1.5",
|
45
|
-
"@ai-sdk/react": "1.1.
|
46
|
-
"@ai-sdk/ui-utils": "1.1.
|
45
|
+
"@ai-sdk/react": "1.1.7",
|
46
|
+
"@ai-sdk/ui-utils": "1.1.7",
|
47
47
|
"@opentelemetry/api": "1.9.0",
|
48
48
|
"jsondiffpatch": "0.6.0"
|
49
49
|
},
|
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -1004,45 +1004,62 @@ function convertToCoreMessages(messages, options) {
|
|
1004
1004
|
coreMessages.push({ role: "assistant", content });
|
1005
1005
|
break;
|
1006
1006
|
}
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1007
|
+
const maxStep = toolInvocations.reduce((max, toolInvocation) => {
|
1008
|
+
var _a10;
|
1009
|
+
return Math.max(max, (_a10 = toolInvocation.step) != null ? _a10 : 0);
|
1010
|
+
}, 0);
|
1011
|
+
for (let i = 0; i <= maxStep; i++) {
|
1012
|
+
const stepInvocations = toolInvocations.filter(
|
1013
|
+
(toolInvocation) => {
|
1014
|
+
var _a10;
|
1015
|
+
return ((_a10 = toolInvocation.step) != null ? _a10 : 0) === i;
|
1016
|
+
}
|
1017
|
+
);
|
1018
|
+
if (stepInvocations.length === 0) {
|
1019
|
+
continue;
|
1020
|
+
}
|
1021
|
+
coreMessages.push({
|
1022
|
+
role: "assistant",
|
1023
|
+
content: [
|
1024
|
+
...stepInvocations.map(
|
1025
|
+
({ toolCallId, toolName, args }) => ({
|
1026
|
+
type: "tool-call",
|
1027
|
+
toolCallId,
|
1028
|
+
toolName,
|
1029
|
+
args
|
1030
|
+
})
|
1031
|
+
)
|
1032
|
+
]
|
1033
|
+
});
|
1034
|
+
coreMessages.push({
|
1035
|
+
role: "tool",
|
1036
|
+
content: stepInvocations.map((toolInvocation) => {
|
1037
|
+
if (!("result" in toolInvocation)) {
|
1038
|
+
throw new MessageConversionError({
|
1039
|
+
originalMessage: message,
|
1040
|
+
message: "ToolInvocation must have a result: " + JSON.stringify(toolInvocation)
|
1041
|
+
});
|
1042
|
+
}
|
1043
|
+
const { toolCallId, toolName, result } = toolInvocation;
|
1044
|
+
const tool = tools[toolName];
|
1045
|
+
return (tool == null ? void 0 : tool.experimental_toToolResultContent) != null ? {
|
1046
|
+
type: "tool-result",
|
1014
1047
|
toolCallId,
|
1015
1048
|
toolName,
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
const { toolCallId, toolName, result } = toolInvocation;
|
1031
|
-
const tool = tools[toolName];
|
1032
|
-
return (tool == null ? void 0 : tool.experimental_toToolResultContent) != null ? {
|
1033
|
-
type: "tool-result",
|
1034
|
-
toolCallId,
|
1035
|
-
toolName,
|
1036
|
-
result: tool.experimental_toToolResultContent(result),
|
1037
|
-
experimental_content: tool.experimental_toToolResultContent(result)
|
1038
|
-
} : {
|
1039
|
-
type: "tool-result",
|
1040
|
-
toolCallId,
|
1041
|
-
toolName,
|
1042
|
-
result
|
1043
|
-
};
|
1044
|
-
})
|
1045
|
-
});
|
1049
|
+
result: tool.experimental_toToolResultContent(result),
|
1050
|
+
experimental_content: tool.experimental_toToolResultContent(result)
|
1051
|
+
} : {
|
1052
|
+
type: "tool-result",
|
1053
|
+
toolCallId,
|
1054
|
+
toolName,
|
1055
|
+
result
|
1056
|
+
};
|
1057
|
+
})
|
1058
|
+
});
|
1059
|
+
}
|
1060
|
+
if (content) {
|
1061
|
+
coreMessages.push({ role: "assistant", content });
|
1062
|
+
}
|
1046
1063
|
break;
|
1047
1064
|
}
|
1048
1065
|
case "data": {
|