ai 6.0.0-beta.95 → 6.0.0-beta.96

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
@@ -757,7 +757,7 @@ import {
757
757
  } from "@ai-sdk/provider-utils";
758
758
 
759
759
  // src/version.ts
760
- var VERSION = true ? "6.0.0-beta.95" : "0.0.0-test";
760
+ var VERSION = true ? "6.0.0-beta.96" : "0.0.0-test";
761
761
 
762
762
  // src/util/download/download.ts
763
763
  var download = async ({ url }) => {
@@ -4059,6 +4059,15 @@ var uiMessageChunkSchema = lazySchema(
4059
4059
  }),
4060
4060
  z7.strictObject({
4061
4061
  type: z7.literal("finish"),
4062
+ finishReason: z7.enum([
4063
+ "stop",
4064
+ "length",
4065
+ "content-filter",
4066
+ "tool-calls",
4067
+ "error",
4068
+ "other",
4069
+ "unknown"
4070
+ ]).optional(),
4062
4071
  messageMetadata: z7.unknown().optional()
4063
4072
  }),
4064
4073
  z7.strictObject({
@@ -4557,6 +4566,9 @@ function processUIMessageStream({
4557
4566
  break;
4558
4567
  }
4559
4568
  case "finish": {
4569
+ if (chunk.finishReason != null) {
4570
+ state.finishReason = chunk.finishReason;
4571
+ }
4560
4572
  await updateMessageMetadata(chunk.messageMetadata);
4561
4573
  if (chunk.messageMetadata != null) {
4562
4574
  write();
@@ -4664,7 +4676,8 @@ function handleUIMessageStreamFinish({
4664
4676
  messages: [
4665
4677
  ...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
4666
4678
  state.message
4667
- ]
4679
+ ],
4680
+ finishReason: state.finishReason
4668
4681
  });
4669
4682
  };
4670
4683
  return processUIMessageStream({
@@ -6468,6 +6481,7 @@ var DefaultStreamTextResult = class {
6468
6481
  if (sendFinish) {
6469
6482
  controller.enqueue({
6470
6483
  type: "finish",
6484
+ finishReason: part.finishReason,
6471
6485
  ...messageMetadataValue != null ? { messageMetadata: messageMetadataValue } : {}
6472
6486
  });
6473
6487
  }
@@ -10973,7 +10987,7 @@ var AbstractChat = class {
10973
10987
  body,
10974
10988
  messageId
10975
10989
  }) {
10976
- var _a15, _b, _c;
10990
+ var _a15, _b, _c, _d;
10977
10991
  this.setStatus({ status: "submitted", error: void 0 });
10978
10992
  const lastMessage = this.lastMessage;
10979
10993
  let isAbort = false;
@@ -11070,22 +11084,23 @@ var AbstractChat = class {
11070
11084
  this.setStatus({ status: "error", error: err });
11071
11085
  } finally {
11072
11086
  try {
11073
- (_a15 = this.onFinish) == null ? void 0 : _a15.call(this, {
11087
+ (_b = this.onFinish) == null ? void 0 : _b.call(this, {
11074
11088
  message: this.activeResponse.state.message,
11075
11089
  messages: this.state.messages,
11076
11090
  isAbort,
11077
11091
  isDisconnect,
11078
- isError
11092
+ isError,
11093
+ finishReason: (_a15 = this.activeResponse) == null ? void 0 : _a15.state.finishReason
11079
11094
  });
11080
11095
  } catch (err) {
11081
11096
  console.error(err);
11082
11097
  }
11083
11098
  this.activeResponse = void 0;
11084
11099
  }
11085
- if (((_b = this.sendAutomaticallyWhen) == null ? void 0 : _b.call(this, { messages: this.state.messages })) && !isError) {
11100
+ if (((_c = this.sendAutomaticallyWhen) == null ? void 0 : _c.call(this, { messages: this.state.messages })) && !isError) {
11086
11101
  await this.makeRequest({
11087
11102
  trigger: "submit-message",
11088
- messageId: (_c = this.lastMessage) == null ? void 0 : _c.id,
11103
+ messageId: (_d = this.lastMessage) == null ? void 0 : _d.id,
11089
11104
  metadata,
11090
11105
  headers,
11091
11106
  body