ai 5.0.278 → 5.0.280
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 +20 -0
- package/dist/index.js +55 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -727,7 +727,7 @@ import {
|
|
|
727
727
|
} from "@ai-sdk/provider-utils";
|
|
728
728
|
|
|
729
729
|
// src/version.ts
|
|
730
|
-
var VERSION = true ? "5.0.
|
|
730
|
+
var VERSION = true ? "5.0.280" : "0.0.0-test";
|
|
731
731
|
|
|
732
732
|
// src/util/download/download.ts
|
|
733
733
|
var download = async ({
|
|
@@ -5349,12 +5349,23 @@ var DefaultStreamTextResult = class {
|
|
|
5349
5349
|
return stitchableStream.stream.cancel(reason);
|
|
5350
5350
|
}
|
|
5351
5351
|
});
|
|
5352
|
+
let isRunning = true;
|
|
5353
|
+
stream = stream.pipeThrough(
|
|
5354
|
+
new TransformStream({
|
|
5355
|
+
async transform(chunk, controller) {
|
|
5356
|
+
if (isRunning) {
|
|
5357
|
+
controller.enqueue(chunk);
|
|
5358
|
+
}
|
|
5359
|
+
}
|
|
5360
|
+
})
|
|
5361
|
+
);
|
|
5352
5362
|
for (const transform of transforms) {
|
|
5353
5363
|
stream = stream.pipeThrough(
|
|
5354
5364
|
transform({
|
|
5355
5365
|
tools,
|
|
5356
5366
|
stopStream() {
|
|
5357
5367
|
stitchableStream.terminate();
|
|
5368
|
+
isRunning = false;
|
|
5358
5369
|
}
|
|
5359
5370
|
})
|
|
5360
5371
|
);
|
|
@@ -8873,21 +8884,52 @@ function pruneMessages({
|
|
|
8873
8884
|
if (message.role !== "assistant" && message.role !== "tool" || typeof message.content === "string" || keepLastMessagesCount && messageIndex >= messages.length - keepLastMessagesCount) {
|
|
8874
8885
|
return message;
|
|
8875
8886
|
}
|
|
8876
|
-
const
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8887
|
+
const keepParts = message.content.map((part) => {
|
|
8888
|
+
if (part.type !== "tool-call" && part.type !== "tool-result") {
|
|
8889
|
+
return true;
|
|
8890
|
+
}
|
|
8891
|
+
if ((part.type === "tool-call" || part.type === "tool-result") && keptToolCallIds.has(part.toolCallId)) {
|
|
8892
|
+
return true;
|
|
8893
|
+
}
|
|
8894
|
+
return toolCall.tools != null && !toolCall.tools.includes(part.toolName);
|
|
8895
|
+
});
|
|
8896
|
+
if (message.role === "assistant") {
|
|
8897
|
+
for (let reasoningIndex = 0; reasoningIndex < message.content.length; reasoningIndex++) {
|
|
8898
|
+
const part = message.content[reasoningIndex];
|
|
8899
|
+
if (part.type !== "reasoning") {
|
|
8900
|
+
continue;
|
|
8882
8901
|
}
|
|
8883
|
-
|
|
8884
|
-
|
|
8902
|
+
let reasoningEndIndex = reasoningIndex + 1;
|
|
8903
|
+
while (reasoningEndIndex < message.content.length) {
|
|
8904
|
+
const nextPart = message.content[reasoningEndIndex];
|
|
8905
|
+
if (nextPart.type !== "reasoning") {
|
|
8906
|
+
break;
|
|
8907
|
+
}
|
|
8908
|
+
reasoningEndIndex++;
|
|
8885
8909
|
}
|
|
8886
|
-
|
|
8887
|
-
|
|
8910
|
+
let followingPartIndex = reasoningEndIndex;
|
|
8911
|
+
let hasFollowingPart = false;
|
|
8912
|
+
let hasKeptFollowingPart = false;
|
|
8913
|
+
while (followingPartIndex < message.content.length) {
|
|
8914
|
+
const followingPart = message.content[followingPartIndex];
|
|
8915
|
+
if (followingPart.type === "reasoning") {
|
|
8916
|
+
break;
|
|
8917
|
+
}
|
|
8918
|
+
hasFollowingPart = true;
|
|
8919
|
+
hasKeptFollowingPart || (hasKeptFollowingPart = keepParts[followingPartIndex]);
|
|
8920
|
+
followingPartIndex++;
|
|
8888
8921
|
}
|
|
8889
|
-
|
|
8890
|
-
|
|
8922
|
+
if (hasFollowingPart && !hasKeptFollowingPart) {
|
|
8923
|
+
for (let index = reasoningIndex; index < reasoningEndIndex; index++) {
|
|
8924
|
+
keepParts[index] = false;
|
|
8925
|
+
}
|
|
8926
|
+
}
|
|
8927
|
+
reasoningIndex = followingPartIndex - 1;
|
|
8928
|
+
}
|
|
8929
|
+
}
|
|
8930
|
+
return {
|
|
8931
|
+
...message,
|
|
8932
|
+
content: message.content.filter((_, index) => keepParts[index])
|
|
8891
8933
|
};
|
|
8892
8934
|
});
|
|
8893
8935
|
}
|