ai 6.0.80 → 6.0.82
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 +13 -0
- package/dist/index.d.mts +28 -2
- package/dist/index.d.ts +28 -2
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/04-tools.mdx +6 -4
- package/docs/07-reference/01-ai-sdk-core/20-tool.mdx +1 -1
- package/package.json +2 -2
- package/src/ui-message-stream/create-ui-message-stream.ts +9 -0
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +37 -2
- package/src/ui-message-stream/index.ts +1 -0
- package/src/ui-message-stream/ui-message-stream-on-step-finish-callback.ts +25 -0
package/dist/index.mjs
CHANGED
|
@@ -1100,7 +1100,7 @@ import {
|
|
|
1100
1100
|
} from "@ai-sdk/provider-utils";
|
|
1101
1101
|
|
|
1102
1102
|
// src/version.ts
|
|
1103
|
-
var VERSION = true ? "6.0.
|
|
1103
|
+
var VERSION = true ? "6.0.82" : "0.0.0-test";
|
|
1104
1104
|
|
|
1105
1105
|
// src/util/download/download.ts
|
|
1106
1106
|
var download = async ({ url }) => {
|
|
@@ -5490,6 +5490,7 @@ function processUIMessageStream({
|
|
|
5490
5490
|
function handleUIMessageStreamFinish({
|
|
5491
5491
|
messageId,
|
|
5492
5492
|
originalMessages = [],
|
|
5493
|
+
onStepFinish,
|
|
5493
5494
|
onFinish,
|
|
5494
5495
|
onError,
|
|
5495
5496
|
stream
|
|
@@ -5517,7 +5518,7 @@ function handleUIMessageStreamFinish({
|
|
|
5517
5518
|
}
|
|
5518
5519
|
})
|
|
5519
5520
|
);
|
|
5520
|
-
if (onFinish == null) {
|
|
5521
|
+
if (onFinish == null && onStepFinish == null) {
|
|
5521
5522
|
return idInjectedStream;
|
|
5522
5523
|
}
|
|
5523
5524
|
const state = createStreamingUIMessageState({
|
|
@@ -5547,13 +5548,34 @@ function handleUIMessageStreamFinish({
|
|
|
5547
5548
|
finishReason: state.finishReason
|
|
5548
5549
|
});
|
|
5549
5550
|
};
|
|
5551
|
+
const callOnStepFinish = async () => {
|
|
5552
|
+
if (!onStepFinish) {
|
|
5553
|
+
return;
|
|
5554
|
+
}
|
|
5555
|
+
const isContinuation = state.message.id === (lastMessage == null ? void 0 : lastMessage.id);
|
|
5556
|
+
try {
|
|
5557
|
+
await onStepFinish({
|
|
5558
|
+
isContinuation,
|
|
5559
|
+
responseMessage: structuredClone(state.message),
|
|
5560
|
+
messages: [
|
|
5561
|
+
...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
|
|
5562
|
+
structuredClone(state.message)
|
|
5563
|
+
]
|
|
5564
|
+
});
|
|
5565
|
+
} catch (error) {
|
|
5566
|
+
onError(error);
|
|
5567
|
+
}
|
|
5568
|
+
};
|
|
5550
5569
|
return processUIMessageStream({
|
|
5551
5570
|
stream: idInjectedStream,
|
|
5552
5571
|
runUpdateMessageJob,
|
|
5553
5572
|
onError
|
|
5554
5573
|
}).pipeThrough(
|
|
5555
5574
|
new TransformStream({
|
|
5556
|
-
transform(chunk, controller) {
|
|
5575
|
+
async transform(chunk, controller) {
|
|
5576
|
+
if (chunk.type === "finish-step") {
|
|
5577
|
+
await callOnStepFinish();
|
|
5578
|
+
}
|
|
5557
5579
|
controller.enqueue(chunk);
|
|
5558
5580
|
},
|
|
5559
5581
|
// @ts-expect-error cancel is still new and missing from types https://developer.mozilla.org/en-US/docs/Web/API/TransformStream#browser_compatibility
|
|
@@ -7696,6 +7718,7 @@ function createUIMessageStream({
|
|
|
7696
7718
|
execute,
|
|
7697
7719
|
onError = getErrorMessage8,
|
|
7698
7720
|
originalMessages,
|
|
7721
|
+
onStepFinish,
|
|
7699
7722
|
onFinish,
|
|
7700
7723
|
generateId: generateId2 = generateIdFunc
|
|
7701
7724
|
}) {
|
|
@@ -7771,6 +7794,7 @@ function createUIMessageStream({
|
|
|
7771
7794
|
stream,
|
|
7772
7795
|
messageId: generateId2(),
|
|
7773
7796
|
originalMessages,
|
|
7797
|
+
onStepFinish,
|
|
7774
7798
|
onFinish,
|
|
7775
7799
|
onError
|
|
7776
7800
|
});
|