ai 6.0.252 → 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.252" : "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 ({
@@ -5949,6 +5949,7 @@ function processUIMessageStream({
5949
5949
  case "reasoning-start": {
5950
5950
  const reasoningPart = {
5951
5951
  type: "reasoning",
5952
+ id: chunk.id,
5952
5953
  text: "",
5953
5954
  providerMetadata: chunk.providerMetadata,
5954
5955
  state: "streaming"
@@ -6259,7 +6260,7 @@ function processUIMessageStream({
6259
6260
  }
6260
6261
  await updateMessageMetadata(chunk.messageMetadata);
6261
6262
  if (chunk.messageId != null || chunk.messageMetadata != null) {
6262
- write();
6263
+ write({ updateStatus: false });
6263
6264
  }
6264
6265
  break;
6265
6266
  }
@@ -8959,6 +8960,27 @@ function createUIMessageStream({
8959
8960
  }
8960
8961
 
8961
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
+ }
8962
8984
  function readUIMessageStream({
8963
8985
  message,
8964
8986
  stream,
@@ -8991,7 +9013,7 @@ function readUIMessageStream({
8991
9013
  return job({
8992
9014
  state,
8993
9015
  write: () => {
8994
- controller == null ? void 0 : controller.enqueue(structuredClone(state.message));
9016
+ controller == null ? void 0 : controller.enqueue(createUIMessageSnapshot(state.message));
8995
9017
  }
8996
9018
  });
8997
9019
  },
@@ -9276,6 +9298,7 @@ var uiMessagesSchema = lazySchema2(
9276
9298
  }),
9277
9299
  z8.object({
9278
9300
  type: z8.literal("reasoning"),
9301
+ id: z8.string().optional(),
9279
9302
  text: z8.string(),
9280
9303
  state: z8.enum(["streaming", "done"]).optional(),
9281
9304
  providerMetadata: providerMetadataSchema.optional()
@@ -14063,12 +14086,14 @@ var AbstractChat = class {
14063
14086
  }
14064
14087
  return job({
14065
14088
  state: response.state,
14066
- write: () => {
14089
+ write: ({ updateStatus = true } = {}) => {
14067
14090
  var _a23;
14068
14091
  if (response.abortController.signal.aborted) {
14069
14092
  return;
14070
14093
  }
14071
- this.setStatus({ status: "streaming" });
14094
+ if (updateStatus) {
14095
+ this.setStatus({ status: "streaming" });
14096
+ }
14072
14097
  const replaceLastMessage = response.state.message.id === ((_a23 = this.lastMessage) == null ? void 0 : _a23.id);
14073
14098
  if (replaceLastMessage) {
14074
14099
  this.state.replaceMessage(