ai 6.0.253 → 6.0.255

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/dist/index.mjs CHANGED
@@ -1193,7 +1193,7 @@ import {
1193
1193
  } from "@ai-sdk/provider-utils";
1194
1194
 
1195
1195
  // src/version.ts
1196
- var VERSION = true ? "6.0.253" : "0.0.0-test";
1196
+ var VERSION = true ? "6.0.255" : "0.0.0-test";
1197
1197
 
1198
1198
  // src/util/download/download.ts
1199
1199
  var download = async ({
@@ -6260,7 +6260,7 @@ function processUIMessageStream({
6260
6260
  }
6261
6261
  await updateMessageMetadata(chunk.messageMetadata);
6262
6262
  if (chunk.messageId != null || chunk.messageMetadata != null) {
6263
- write();
6263
+ write({ updateStatus: false });
6264
6264
  }
6265
6265
  break;
6266
6266
  }
@@ -8960,6 +8960,27 @@ function createUIMessageStream({
8960
8960
  }
8961
8961
 
8962
8962
  // src/ui-message-stream/read-ui-message-stream.ts
8963
+ function createUIMessageSnapshot(message) {
8964
+ const textByPartIndex = /* @__PURE__ */ new Map();
8965
+ const messageWithoutText = {
8966
+ ...message,
8967
+ parts: message.parts.map((part, index) => {
8968
+ if (part.type === "text" || part.type === "reasoning") {
8969
+ textByPartIndex.set(index, part.text);
8970
+ return { ...part, text: "" };
8971
+ }
8972
+ return part;
8973
+ })
8974
+ };
8975
+ const snapshot = structuredClone(messageWithoutText);
8976
+ for (const [index, text2] of textByPartIndex) {
8977
+ const part = snapshot.parts[index];
8978
+ if (part.type === "text" || part.type === "reasoning") {
8979
+ part.text = text2;
8980
+ }
8981
+ }
8982
+ return snapshot;
8983
+ }
8963
8984
  function readUIMessageStream({
8964
8985
  message,
8965
8986
  stream,
@@ -8992,7 +9013,7 @@ function readUIMessageStream({
8992
9013
  return job({
8993
9014
  state,
8994
9015
  write: () => {
8995
- controller == null ? void 0 : controller.enqueue(structuredClone(state.message));
9016
+ controller == null ? void 0 : controller.enqueue(createUIMessageSnapshot(state.message));
8996
9017
  }
8997
9018
  });
8998
9019
  },
@@ -14065,12 +14086,14 @@ var AbstractChat = class {
14065
14086
  }
14066
14087
  return job({
14067
14088
  state: response.state,
14068
- write: () => {
14089
+ write: ({ updateStatus = true } = {}) => {
14069
14090
  var _a23;
14070
14091
  if (response.abortController.signal.aborted) {
14071
14092
  return;
14072
14093
  }
14073
- this.setStatus({ status: "streaming" });
14094
+ if (updateStatus) {
14095
+ this.setStatus({ status: "streaming" });
14096
+ }
14074
14097
  const replaceLastMessage = response.state.message.id === ((_a23 = this.lastMessage) == null ? void 0 : _a23.id);
14075
14098
  if (replaceLastMessage) {
14076
14099
  this.state.replaceMessage(