ai 6.0.294 → 6.0.295

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
@@ -1224,7 +1224,7 @@ import {
1224
1224
  } from "@ai-sdk/provider-utils";
1225
1225
 
1226
1226
  // src/version.ts
1227
- var VERSION = true ? "6.0.294" : "0.0.0-test";
1227
+ var VERSION = true ? "6.0.295" : "0.0.0-test";
1228
1228
 
1229
1229
  // src/util/download/download.ts
1230
1230
  var download = async ({
@@ -14440,6 +14440,7 @@ var AbstractChat = class {
14440
14440
  }) {
14441
14441
  this.activeResponse = void 0;
14442
14442
  this.activeResumeRequest = void 0;
14443
+ this.resumableStreamState = void 0;
14443
14444
  this.jobExecutor = new SerialJobExecutor();
14444
14445
  /**
14445
14446
  * Appends or replaces a user message to the chat list. This triggers the API call to fetch
@@ -14719,6 +14720,9 @@ var AbstractChat = class {
14719
14720
  messageId
14720
14721
  }) {
14721
14722
  var _a23, _b, _c;
14723
+ if (trigger !== "resume-stream") {
14724
+ this.resumableStreamState = void 0;
14725
+ }
14722
14726
  const abortController = new AbortController();
14723
14727
  const activeResumeRequest = trigger === "resume-stream" ? { abortController } : void 0;
14724
14728
  if (activeResumeRequest) {
@@ -14746,12 +14750,14 @@ var AbstractChat = class {
14746
14750
  }));
14747
14751
  if (isCurrentRequest()) {
14748
14752
  this.setStatus({ status: "ready" });
14753
+ this.resumableStreamState = void 0;
14749
14754
  }
14750
14755
  clearActiveResumeRequest();
14751
14756
  return;
14752
14757
  }
14753
14758
  if (reconnect == null) {
14754
14759
  this.setStatus({ status: "ready" });
14760
+ this.resumableStreamState = void 0;
14755
14761
  clearActiveResumeRequest();
14756
14762
  return;
14757
14763
  }
@@ -14760,6 +14766,7 @@ var AbstractChat = class {
14760
14766
  if (abortController.signal.aborted || err.name === "AbortError") {
14761
14767
  if (isCurrentRequest()) {
14762
14768
  this.setStatus({ status: "ready" });
14769
+ this.resumableStreamState = void 0;
14763
14770
  }
14764
14771
  clearActiveResumeRequest();
14765
14772
  return;
@@ -14786,7 +14793,7 @@ var AbstractChat = class {
14786
14793
  let activeResponse;
14787
14794
  try {
14788
14795
  const response = {
14789
- state: createStreamingUIMessageState({
14796
+ state: trigger === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : createStreamingUIMessageState({
14790
14797
  lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? void 0 : this.state.snapshot(responseMessage),
14791
14798
  messageId: this.generateId()
14792
14799
  }),
@@ -14865,17 +14872,26 @@ var AbstractChat = class {
14865
14872
  if (isAbort) {
14866
14873
  if (isCurrentRequest()) {
14867
14874
  this.setStatus({ status: "ready" });
14875
+ if (this.resumableStreamState === response.state) {
14876
+ this.resumableStreamState = void 0;
14877
+ }
14868
14878
  }
14869
14879
  return null;
14870
14880
  }
14871
14881
  if (isCurrentRequest()) {
14872
14882
  this.setStatus({ status: "ready" });
14883
+ if (this.resumableStreamState === response.state) {
14884
+ this.resumableStreamState = void 0;
14885
+ }
14873
14886
  }
14874
14887
  } catch (err) {
14875
14888
  if (isAbort || err.name === "AbortError") {
14876
14889
  isAbort = true;
14877
14890
  if (isCurrentRequest()) {
14878
14891
  this.setStatus({ status: "ready" });
14892
+ if (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) {
14893
+ this.resumableStreamState = void 0;
14894
+ }
14879
14895
  }
14880
14896
  return null;
14881
14897
  }
@@ -14886,6 +14902,11 @@ var AbstractChat = class {
14886
14902
  if (err instanceof TypeError && (err.message.toLowerCase().includes("fetch") || err.message.toLowerCase().includes("network"))) {
14887
14903
  isDisconnect = true;
14888
14904
  }
14905
+ if (isDisconnect) {
14906
+ this.resumableStreamState = activeResponse == null ? void 0 : activeResponse.state;
14907
+ } else if (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) {
14908
+ this.resumableStreamState = void 0;
14909
+ }
14889
14910
  if (this.onError && err instanceof Error) {
14890
14911
  this.onError(err);
14891
14912
  }