ai 3.3.29 → 3.3.30

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
@@ -3983,9 +3983,9 @@ var DefaultStreamTextResult = class {
3983
3983
  });
3984
3984
  }
3985
3985
  toAIStream(callbacks = {}) {
3986
- return this.toDataStream({ callbacks });
3986
+ return this.toDataStreamInternal({ callbacks });
3987
3987
  }
3988
- toDataStream({
3988
+ toDataStreamInternal({
3989
3989
  callbacks = {},
3990
3990
  getErrorMessage: getErrorMessage4 = () => ""
3991
3991
  // mask error messages for safety by default
@@ -4109,7 +4109,7 @@ var DefaultStreamTextResult = class {
4109
4109
  contentType: "text/plain; charset=utf-8",
4110
4110
  dataStreamVersion: "v1"
4111
4111
  }),
4112
- stream: data ? mergeStreams(data.stream, this.toDataStream({ getErrorMessage: getErrorMessage4 })) : this.toDataStream({ getErrorMessage: getErrorMessage4 })
4112
+ stream: this.toDataStream({ data, getErrorMessage: getErrorMessage4 })
4113
4113
  });
4114
4114
  }
4115
4115
  pipeTextStreamToResponse(response, init) {
@@ -4126,6 +4126,12 @@ var DefaultStreamTextResult = class {
4126
4126
  toAIStreamResponse(options) {
4127
4127
  return this.toDataStreamResponse(options);
4128
4128
  }
4129
+ toDataStream(options) {
4130
+ const stream = this.toDataStreamInternal({
4131
+ getErrorMessage: options == null ? void 0 : options.getErrorMessage
4132
+ });
4133
+ return (options == null ? void 0 : options.data) ? mergeStreams(options == null ? void 0 : options.data.stream, stream) : stream;
4134
+ }
4129
4135
  toDataStreamResponse(options) {
4130
4136
  var _a11;
4131
4137
  const init = options == null ? void 0 : "init" in options ? options.init : {
@@ -4135,8 +4141,7 @@ var DefaultStreamTextResult = class {
4135
4141
  };
4136
4142
  const data = options == null ? void 0 : "data" in options ? options.data : void 0;
4137
4143
  const getErrorMessage4 = options == null ? void 0 : "getErrorMessage" in options ? options.getErrorMessage : void 0;
4138
- const stream = data ? mergeStreams(data.stream, this.toDataStream({ getErrorMessage: getErrorMessage4 })) : this.toDataStream({ getErrorMessage: getErrorMessage4 });
4139
- return new Response(stream, {
4144
+ return new Response(this.toDataStream({ data, getErrorMessage: getErrorMessage4 }), {
4140
4145
  status: (_a11 = init == null ? void 0 : init.status) != null ? _a11 : 200,
4141
4146
  statusText: init == null ? void 0 : init.statusText,
4142
4147
  headers: prepareResponseHeaders(init, {