ai 5.0.259 → 5.0.261

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
@@ -727,7 +727,7 @@ import {
727
727
  } from "@ai-sdk/provider-utils";
728
728
 
729
729
  // src/version.ts
730
- var VERSION = true ? "5.0.259" : "0.0.0-test";
730
+ var VERSION = true ? "5.0.261" : "0.0.0-test";
731
731
 
732
732
  // src/util/download/download.ts
733
733
  var download = async ({
@@ -8937,7 +8937,11 @@ function simulateStreamingMiddleware() {
8937
8937
  switch (part.type) {
8938
8938
  case "text": {
8939
8939
  if (part.text.length > 0) {
8940
- controller.enqueue({ type: "text-start", id: String(id) });
8940
+ controller.enqueue({
8941
+ type: "text-start",
8942
+ id: String(id),
8943
+ ...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
8944
+ });
8941
8945
  controller.enqueue({
8942
8946
  type: "text-delta",
8943
8947
  id: String(id),
@@ -10654,9 +10658,15 @@ function readUIMessageStream({
10654
10658
  var _a16;
10655
10659
  let controller;
10656
10660
  let hasErrored = false;
10661
+ let isCancelled = false;
10662
+ const abortController = new AbortController();
10657
10663
  const outputStream = new ReadableStream({
10658
10664
  start(controllerParam) {
10659
10665
  controller = controllerParam;
10666
+ },
10667
+ cancel() {
10668
+ isCancelled = true;
10669
+ abortController.abort();
10660
10670
  }
10661
10671
  });
10662
10672
  const state = createStreamingUIMessageState({
@@ -10677,15 +10687,18 @@ function readUIMessageStream({
10677
10687
  return job({
10678
10688
  state,
10679
10689
  write: () => {
10680
- controller == null ? void 0 : controller.enqueue(createUIMessageSnapshot(state.message));
10690
+ if (!isCancelled) {
10691
+ controller == null ? void 0 : controller.enqueue(createUIMessageSnapshot(state.message));
10692
+ }
10681
10693
  }
10682
10694
  });
10683
10695
  },
10684
10696
  onError: handleError
10685
10697
  }),
10686
- onError: handleError
10698
+ onError: handleError,
10699
+ abortSignal: abortController.signal
10687
10700
  }).finally(() => {
10688
- if (!hasErrored) {
10701
+ if (!hasErrored && !isCancelled) {
10689
10702
  controller == null ? void 0 : controller.close();
10690
10703
  }
10691
10704
  });