ai 4.3.1 → 4.3.2

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
@@ -4702,6 +4702,25 @@ function asArray(value) {
4702
4702
  return value === void 0 ? [] : Array.isArray(value) ? value : [value];
4703
4703
  }
4704
4704
 
4705
+ // util/consume-stream.ts
4706
+ async function consumeStream({
4707
+ stream,
4708
+ onError
4709
+ }) {
4710
+ const reader = stream.getReader();
4711
+ try {
4712
+ while (true) {
4713
+ const { done } = await reader.read();
4714
+ if (done)
4715
+ break;
4716
+ }
4717
+ } catch (error) {
4718
+ onError == null ? void 0 : onError(error);
4719
+ } finally {
4720
+ reader.releaseLock();
4721
+ }
4722
+ }
4723
+
4705
4724
  // core/util/merge-streams.ts
4706
4725
  function mergeStreams(stream1, stream2) {
4707
4726
  const reader1 = stream1.getReader();
@@ -5943,9 +5962,15 @@ var DefaultStreamTextResult = class {
5943
5962
  )
5944
5963
  );
5945
5964
  }
5946
- async consumeStream() {
5947
- const stream = this.fullStream;
5948
- for await (const part of stream) {
5965
+ async consumeStream(options) {
5966
+ var _a17;
5967
+ try {
5968
+ await consumeStream({
5969
+ stream: this.fullStream,
5970
+ onError: options == null ? void 0 : options.onError
5971
+ });
5972
+ } catch (error) {
5973
+ (_a17 = options == null ? void 0 : options.onError) == null ? void 0 : _a17.call(options, error);
5949
5974
  }
5950
5975
  }
5951
5976
  get experimental_partialOutputStream() {