ai 5.0.19 → 5.0.21

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
@@ -3981,30 +3981,6 @@ var DelayedPromise = class {
3981
3981
  }
3982
3982
  };
3983
3983
 
3984
- // src/util/filter-stream-errors.ts
3985
- function filterStreamErrors(readable, onError) {
3986
- return new ReadableStream({
3987
- async start(controller) {
3988
- const reader = readable.getReader();
3989
- try {
3990
- while (true) {
3991
- const { done, value } = await reader.read();
3992
- if (done) {
3993
- controller.close();
3994
- break;
3995
- }
3996
- controller.enqueue(value);
3997
- }
3998
- } catch (error) {
3999
- await onError({ error, controller });
4000
- }
4001
- },
4002
- cancel(reason) {
4003
- return readable.cancel(reason);
4004
- }
4005
- });
4006
- }
4007
-
4008
3984
  // src/util/now.ts
4009
3985
  function now() {
4010
3986
  var _a17, _b;
@@ -4643,23 +4619,40 @@ var DefaultStreamTextResult = class {
4643
4619
  const stitchableStream = createStitchableStream();
4644
4620
  this.addStream = stitchableStream.addStream;
4645
4621
  this.closeStream = stitchableStream.close;
4646
- let stream = stitchableStream.stream;
4647
- stream = filterStreamErrors(stream, ({ error, controller }) => {
4648
- if (isAbortError2(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) {
4649
- onAbort == null ? void 0 : onAbort({ steps: recordedSteps });
4650
- controller.enqueue({ type: "abort" });
4651
- controller.close();
4652
- } else {
4653
- controller.error(error);
4622
+ const reader = stitchableStream.stream.getReader();
4623
+ let stream = new ReadableStream({
4624
+ async start(controller) {
4625
+ controller.enqueue({ type: "start" });
4626
+ },
4627
+ async pull(controller) {
4628
+ function abort() {
4629
+ onAbort == null ? void 0 : onAbort({ steps: recordedSteps });
4630
+ controller.enqueue({ type: "abort" });
4631
+ controller.close();
4632
+ }
4633
+ try {
4634
+ const { done, value } = await reader.read();
4635
+ if (done) {
4636
+ controller.close();
4637
+ return;
4638
+ }
4639
+ if (abortSignal == null ? void 0 : abortSignal.aborted) {
4640
+ abort();
4641
+ return;
4642
+ }
4643
+ controller.enqueue(value);
4644
+ } catch (error) {
4645
+ if (isAbortError2(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) {
4646
+ abort();
4647
+ } else {
4648
+ controller.error(error);
4649
+ }
4650
+ }
4651
+ },
4652
+ cancel(reason) {
4653
+ return stitchableStream.stream.cancel(reason);
4654
4654
  }
4655
4655
  });
4656
- stream = stream.pipeThrough(
4657
- new TransformStream({
4658
- start(controller) {
4659
- controller.enqueue({ type: "start" });
4660
- }
4661
- })
4662
- );
4663
4656
  for (const transform of transforms) {
4664
4657
  stream = stream.pipeThrough(
4665
4658
  transform({
@@ -7054,6 +7047,7 @@ var DefaultStreamObjectResult = class {
7054
7047
  case "response-metadata":
7055
7048
  case "finish":
7056
7049
  case "error":
7050
+ case "stream-start":
7057
7051
  controller.enqueue(chunk);
7058
7052
  break;
7059
7053
  }
@@ -7192,6 +7186,7 @@ var DefaultStreamObjectResult = class {
7192
7186
  });
7193
7187
  self._usage.resolve(usage);
7194
7188
  self._providerMetadata.resolve(providerMetadata);
7189
+ self._warnings.resolve(warnings);
7195
7190
  self._response.resolve({
7196
7191
  ...fullResponse,
7197
7192
  headers: response == null ? void 0 : response.headers