ai 5.0.90 → 5.0.92

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
@@ -671,7 +671,7 @@ import {
671
671
  } from "@ai-sdk/provider-utils";
672
672
 
673
673
  // src/version.ts
674
- var VERSION = true ? "5.0.90" : "0.0.0-test";
674
+ var VERSION = true ? "5.0.92" : "0.0.0-test";
675
675
 
676
676
  // src/util/download/download.ts
677
677
  var download = async ({ url }) => {
@@ -2986,6 +2986,15 @@ var uiMessageChunkSchema = lazyValidator(
2986
2986
  }),
2987
2987
  z7.strictObject({
2988
2988
  type: z7.literal("finish"),
2989
+ finishReason: z7.enum([
2990
+ "stop",
2991
+ "length",
2992
+ "content-filter",
2993
+ "tool-calls",
2994
+ "error",
2995
+ "other",
2996
+ "unknown"
2997
+ ]).optional(),
2989
2998
  messageMetadata: z7.unknown().optional()
2990
2999
  }),
2991
3000
  z7.strictObject({
@@ -3806,6 +3815,9 @@ function processUIMessageStream({
3806
3815
  break;
3807
3816
  }
3808
3817
  case "finish": {
3818
+ if (chunk.finishReason != null) {
3819
+ state.finishReason = chunk.finishReason;
3820
+ }
3809
3821
  await updateMessageMetadata(chunk.messageMetadata);
3810
3822
  if (chunk.messageMetadata != null) {
3811
3823
  write();
@@ -3913,7 +3925,8 @@ function handleUIMessageStreamFinish({
3913
3925
  messages: [
3914
3926
  ...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
3915
3927
  state.message
3916
- ]
3928
+ ],
3929
+ finishReason: state.finishReason
3917
3930
  });
3918
3931
  };
3919
3932
  return processUIMessageStream({
@@ -5649,6 +5662,7 @@ var DefaultStreamTextResult = class {
5649
5662
  if (sendFinish) {
5650
5663
  controller.enqueue({
5651
5664
  type: "finish",
5665
+ finishReason: part.finishReason,
5652
5666
  ...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {}
5653
5667
  });
5654
5668
  }
@@ -9329,7 +9343,7 @@ var AbstractChat = class {
9329
9343
  body,
9330
9344
  messageId
9331
9345
  }) {
9332
- var _a16, _b, _c;
9346
+ var _a16, _b, _c, _d;
9333
9347
  this.setStatus({ status: "submitted", error: void 0 });
9334
9348
  const lastMessage = this.lastMessage;
9335
9349
  let isAbort = false;
@@ -9426,22 +9440,23 @@ var AbstractChat = class {
9426
9440
  this.setStatus({ status: "error", error: err });
9427
9441
  } finally {
9428
9442
  try {
9429
- (_a16 = this.onFinish) == null ? void 0 : _a16.call(this, {
9443
+ (_b = this.onFinish) == null ? void 0 : _b.call(this, {
9430
9444
  message: this.activeResponse.state.message,
9431
9445
  messages: this.state.messages,
9432
9446
  isAbort,
9433
9447
  isDisconnect,
9434
- isError
9448
+ isError,
9449
+ finishReason: (_a16 = this.activeResponse) == null ? void 0 : _a16.state.finishReason
9435
9450
  });
9436
9451
  } catch (err) {
9437
9452
  console.error(err);
9438
9453
  }
9439
9454
  this.activeResponse = void 0;
9440
9455
  }
9441
- if (((_b = this.sendAutomaticallyWhen) == null ? void 0 : _b.call(this, { messages: this.state.messages })) && !isError) {
9456
+ if (((_c = this.sendAutomaticallyWhen) == null ? void 0 : _c.call(this, { messages: this.state.messages })) && !isError) {
9442
9457
  await this.makeRequest({
9443
9458
  trigger: "submit-message",
9444
- messageId: (_c = this.lastMessage) == null ? void 0 : _c.id,
9459
+ messageId: (_d = this.lastMessage) == null ? void 0 : _d.id,
9445
9460
  metadata,
9446
9461
  headers,
9447
9462
  body