ai 4.1.12 → 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 +12 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -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/dist/index.mjs
CHANGED
@@ -38,6 +38,9 @@ function createDataStream({
|
|
38
38
|
}
|
39
39
|
try {
|
40
40
|
const result = execute({
|
41
|
+
write(data) {
|
42
|
+
safeEnqueue(data);
|
43
|
+
},
|
41
44
|
writeData(data) {
|
42
45
|
safeEnqueue(formatDataStreamPart("data", [data]));
|
43
46
|
},
|
@@ -1522,7 +1525,9 @@ function convertToCoreMessages(messages, options) {
|
|
1522
1525
|
var _a15;
|
1523
1526
|
const tools = (_a15 = options == null ? void 0 : options.tools) != null ? _a15 : {};
|
1524
1527
|
const coreMessages = [];
|
1525
|
-
for (
|
1528
|
+
for (let i = 0; i < messages.length; i++) {
|
1529
|
+
const message = messages[i];
|
1530
|
+
const isLastMessage = i === messages.length - 1;
|
1526
1531
|
const { role, content, toolInvocations, experimental_attachments } = message;
|
1527
1532
|
switch (role) {
|
1528
1533
|
case "system": {
|
@@ -1551,11 +1556,11 @@ function convertToCoreMessages(messages, options) {
|
|
1551
1556
|
var _a16;
|
1552
1557
|
return Math.max(max, (_a16 = toolInvocation.step) != null ? _a16 : 0);
|
1553
1558
|
}, 0);
|
1554
|
-
for (let
|
1559
|
+
for (let i2 = 0; i2 <= maxStep; i2++) {
|
1555
1560
|
const stepInvocations = toolInvocations.filter(
|
1556
1561
|
(toolInvocation) => {
|
1557
1562
|
var _a16;
|
1558
|
-
return ((_a16 = toolInvocation.step) != null ? _a16 : 0) ===
|
1563
|
+
return ((_a16 = toolInvocation.step) != null ? _a16 : 0) === i2;
|
1559
1564
|
}
|
1560
1565
|
);
|
1561
1566
|
if (stepInvocations.length === 0) {
|
@@ -1564,6 +1569,7 @@ function convertToCoreMessages(messages, options) {
|
|
1564
1569
|
coreMessages.push({
|
1565
1570
|
role: "assistant",
|
1566
1571
|
content: [
|
1572
|
+
...isLastMessage && content && i2 === 0 ? [{ type: "text", text: content }] : [],
|
1567
1573
|
...stepInvocations.map(
|
1568
1574
|
({ toolCallId, toolName, args }) => ({
|
1569
1575
|
type: "tool-call",
|
@@ -1600,7 +1606,7 @@ function convertToCoreMessages(messages, options) {
|
|
1600
1606
|
})
|
1601
1607
|
});
|
1602
1608
|
}
|
1603
|
-
if (content) {
|
1609
|
+
if (content && !isLastMessage) {
|
1604
1610
|
coreMessages.push({ role: "assistant", content });
|
1605
1611
|
}
|
1606
1612
|
break;
|