ai 6.0.24 → 6.0.25

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
@@ -921,7 +921,7 @@ import {
921
921
  } from "@ai-sdk/provider-utils";
922
922
 
923
923
  // src/version.ts
924
- var VERSION = true ? "6.0.24" : "0.0.0-test";
924
+ var VERSION = true ? "6.0.25" : "0.0.0-test";
925
925
 
926
926
  // src/util/download/download.ts
927
927
  var download = async ({ url }) => {
@@ -2907,12 +2907,16 @@ async function parsePartialJson(jsonText) {
2907
2907
 
2908
2908
  // src/generate-text/output.ts
2909
2909
  var text = () => ({
2910
+ name: "text",
2910
2911
  responseFormat: Promise.resolve({ type: "text" }),
2911
2912
  async parseCompleteOutput({ text: text2 }) {
2912
2913
  return text2;
2913
2914
  },
2914
2915
  async parsePartialOutput({ text: text2 }) {
2915
2916
  return { partial: text2 };
2917
+ },
2918
+ createElementStreamTransform() {
2919
+ return void 0;
2916
2920
  }
2917
2921
  });
2918
2922
  var object = ({
@@ -2922,6 +2926,7 @@ var object = ({
2922
2926
  }) => {
2923
2927
  const schema = asSchema2(inputSchema);
2924
2928
  return {
2929
+ name: "object",
2925
2930
  responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
2926
2931
  type: "json",
2927
2932
  schema: jsonSchema2,
@@ -2971,6 +2976,9 @@ var object = ({
2971
2976
  };
2972
2977
  }
2973
2978
  }
2979
+ },
2980
+ createElementStreamTransform() {
2981
+ return void 0;
2974
2982
  }
2975
2983
  };
2976
2984
  };
@@ -2981,6 +2989,7 @@ var array = ({
2981
2989
  }) => {
2982
2990
  const elementSchema = asSchema2(inputElementSchema);
2983
2991
  return {
2992
+ name: "array",
2984
2993
  // JSON schema that describes an array of elements:
2985
2994
  responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema2) => {
2986
2995
  const { $schema, ...itemSchema } = jsonSchema2;
@@ -3070,6 +3079,18 @@ var array = ({
3070
3079
  return { partial: parsedElements };
3071
3080
  }
3072
3081
  }
3082
+ },
3083
+ createElementStreamTransform() {
3084
+ let publishedElements = 0;
3085
+ return new TransformStream({
3086
+ transform({ partialOutput }, controller) {
3087
+ if (partialOutput != null) {
3088
+ for (; publishedElements < partialOutput.length; publishedElements++) {
3089
+ controller.enqueue(partialOutput[publishedElements]);
3090
+ }
3091
+ }
3092
+ }
3093
+ });
3073
3094
  }
3074
3095
  };
3075
3096
  };
@@ -3079,6 +3100,7 @@ var choice = ({
3079
3100
  description
3080
3101
  }) => {
3081
3102
  return {
3103
+ name: "choice",
3082
3104
  // JSON schema that describes an enumeration:
3083
3105
  responseFormat: Promise.resolve({
3084
3106
  type: "json",
@@ -3145,6 +3167,9 @@ var choice = ({
3145
3167
  }
3146
3168
  }
3147
3169
  }
3170
+ },
3171
+ createElementStreamTransform() {
3172
+ return void 0;
3148
3173
  }
3149
3174
  };
3150
3175
  };
@@ -3153,6 +3178,7 @@ var json = ({
3153
3178
  description
3154
3179
  } = {}) => {
3155
3180
  return {
3181
+ name: "json",
3156
3182
  responseFormat: Promise.resolve({
3157
3183
  type: "json",
3158
3184
  ...name16 != null && { name: name16 },
@@ -3184,6 +3210,9 @@ var json = ({
3184
3210
  return result.value === void 0 ? void 0 : { partial: result.value };
3185
3211
  }
3186
3212
  }
3213
+ },
3214
+ createElementStreamTransform() {
3215
+ return void 0;
3187
3216
  }
3188
3217
  };
3189
3218
  };
@@ -4306,7 +4335,8 @@ function asContent({
4306
4335
 
4307
4336
  // src/generate-text/stream-text.ts
4308
4337
  import {
4309
- getErrorMessage as getErrorMessage7
4338
+ getErrorMessage as getErrorMessage7,
4339
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError2
4310
4340
  } from "@ai-sdk/provider";
4311
4341
  import {
4312
4342
  createIdGenerator as createIdGenerator2,
@@ -6860,6 +6890,16 @@ var DefaultStreamTextResult = class {
6860
6890
  )
6861
6891
  );
6862
6892
  }
6893
+ get elementStream() {
6894
+ var _a16, _b, _c;
6895
+ const transform = (_a16 = this.outputSpecification) == null ? void 0 : _a16.createElementStreamTransform();
6896
+ if (transform == null) {
6897
+ throw new UnsupportedFunctionalityError2({
6898
+ functionality: `element streams in ${(_c = (_b = this.outputSpecification) == null ? void 0 : _b.name) != null ? _c : "text"} mode`
6899
+ });
6900
+ }
6901
+ return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
6902
+ }
6863
6903
  get output() {
6864
6904
  return this.finalStep.then((step) => {
6865
6905
  var _a16;
@@ -8685,7 +8725,7 @@ import {
8685
8725
  isJSONArray,
8686
8726
  isJSONObject,
8687
8727
  TypeValidationError as TypeValidationError4,
8688
- UnsupportedFunctionalityError as UnsupportedFunctionalityError2
8728
+ UnsupportedFunctionalityError as UnsupportedFunctionalityError3
8689
8729
  } from "@ai-sdk/provider";
8690
8730
  import {
8691
8731
  asSchema as asSchema4,
@@ -8710,7 +8750,7 @@ var noSchemaOutputStrategy = {
8710
8750
  } : { success: true, value };
8711
8751
  },
8712
8752
  createElementStream() {
8713
- throw new UnsupportedFunctionalityError2({
8753
+ throw new UnsupportedFunctionalityError3({
8714
8754
  functionality: "element streams in no-schema mode"
8715
8755
  });
8716
8756
  }
@@ -8732,7 +8772,7 @@ var objectOutputStrategy = (schema) => ({
8732
8772
  return safeValidateTypes4({ value, schema });
8733
8773
  },
8734
8774
  createElementStream() {
8735
- throw new UnsupportedFunctionalityError2({
8775
+ throw new UnsupportedFunctionalityError3({
8736
8776
  functionality: "element streams in object mode"
8737
8777
  });
8738
8778
  }
@@ -8921,7 +8961,7 @@ var enumOutputStrategy = (enumValues) => {
8921
8961
  };
8922
8962
  },
8923
8963
  createElementStream() {
8924
- throw new UnsupportedFunctionalityError2({
8964
+ throw new UnsupportedFunctionalityError3({
8925
8965
  functionality: "element streams in enum mode"
8926
8966
  });
8927
8967
  }