ai 4.1.13 → 4.1.14
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.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/rsc/dist/rsc-server.mjs +7 -4
- package/rsc/dist/rsc-server.mjs.map +1 -1
package/package.json
CHANGED
package/rsc/dist/rsc-server.mjs
CHANGED
@@ -979,7 +979,9 @@ function convertToCoreMessages(messages, options) {
|
|
979
979
|
var _a9;
|
980
980
|
const tools = (_a9 = options == null ? void 0 : options.tools) != null ? _a9 : {};
|
981
981
|
const coreMessages = [];
|
982
|
-
for (
|
982
|
+
for (let i = 0; i < messages.length; i++) {
|
983
|
+
const message = messages[i];
|
984
|
+
const isLastMessage = i === messages.length - 1;
|
983
985
|
const { role, content, toolInvocations, experimental_attachments } = message;
|
984
986
|
switch (role) {
|
985
987
|
case "system": {
|
@@ -1008,11 +1010,11 @@ function convertToCoreMessages(messages, options) {
|
|
1008
1010
|
var _a10;
|
1009
1011
|
return Math.max(max, (_a10 = toolInvocation.step) != null ? _a10 : 0);
|
1010
1012
|
}, 0);
|
1011
|
-
for (let
|
1013
|
+
for (let i2 = 0; i2 <= maxStep; i2++) {
|
1012
1014
|
const stepInvocations = toolInvocations.filter(
|
1013
1015
|
(toolInvocation) => {
|
1014
1016
|
var _a10;
|
1015
|
-
return ((_a10 = toolInvocation.step) != null ? _a10 : 0) ===
|
1017
|
+
return ((_a10 = toolInvocation.step) != null ? _a10 : 0) === i2;
|
1016
1018
|
}
|
1017
1019
|
);
|
1018
1020
|
if (stepInvocations.length === 0) {
|
@@ -1021,6 +1023,7 @@ function convertToCoreMessages(messages, options) {
|
|
1021
1023
|
coreMessages.push({
|
1022
1024
|
role: "assistant",
|
1023
1025
|
content: [
|
1026
|
+
...isLastMessage && content && i2 === 0 ? [{ type: "text", text: content }] : [],
|
1024
1027
|
...stepInvocations.map(
|
1025
1028
|
({ toolCallId, toolName, args }) => ({
|
1026
1029
|
type: "tool-call",
|
@@ -1057,7 +1060,7 @@ function convertToCoreMessages(messages, options) {
|
|
1057
1060
|
})
|
1058
1061
|
});
|
1059
1062
|
}
|
1060
|
-
if (content) {
|
1063
|
+
if (content && !isLastMessage) {
|
1061
1064
|
coreMessages.push({ role: "assistant", content });
|
1062
1065
|
}
|
1063
1066
|
break;
|