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.js CHANGED
@@ -1024,7 +1024,7 @@ var import_provider_utils3 = require("@ai-sdk/provider-utils");
1024
1024
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
1025
1025
 
1026
1026
  // src/version.ts
1027
- var VERSION = true ? "6.0.24" : "0.0.0-test";
1027
+ var VERSION = true ? "6.0.25" : "0.0.0-test";
1028
1028
 
1029
1029
  // src/util/download/download.ts
1030
1030
  var download = async ({ url }) => {
@@ -2995,12 +2995,16 @@ async function parsePartialJson(jsonText) {
2995
2995
 
2996
2996
  // src/generate-text/output.ts
2997
2997
  var text = () => ({
2998
+ name: "text",
2998
2999
  responseFormat: Promise.resolve({ type: "text" }),
2999
3000
  async parseCompleteOutput({ text: text2 }) {
3000
3001
  return text2;
3001
3002
  },
3002
3003
  async parsePartialOutput({ text: text2 }) {
3003
3004
  return { partial: text2 };
3005
+ },
3006
+ createElementStreamTransform() {
3007
+ return void 0;
3004
3008
  }
3005
3009
  });
3006
3010
  var object = ({
@@ -3010,6 +3014,7 @@ var object = ({
3010
3014
  }) => {
3011
3015
  const schema = (0, import_provider_utils13.asSchema)(inputSchema);
3012
3016
  return {
3017
+ name: "object",
3013
3018
  responseFormat: (0, import_provider_utils13.resolve)(schema.jsonSchema).then((jsonSchema2) => ({
3014
3019
  type: "json",
3015
3020
  schema: jsonSchema2,
@@ -3059,6 +3064,9 @@ var object = ({
3059
3064
  };
3060
3065
  }
3061
3066
  }
3067
+ },
3068
+ createElementStreamTransform() {
3069
+ return void 0;
3062
3070
  }
3063
3071
  };
3064
3072
  };
@@ -3069,6 +3077,7 @@ var array = ({
3069
3077
  }) => {
3070
3078
  const elementSchema = (0, import_provider_utils13.asSchema)(inputElementSchema);
3071
3079
  return {
3080
+ name: "array",
3072
3081
  // JSON schema that describes an array of elements:
3073
3082
  responseFormat: (0, import_provider_utils13.resolve)(elementSchema.jsonSchema).then((jsonSchema2) => {
3074
3083
  const { $schema, ...itemSchema } = jsonSchema2;
@@ -3158,6 +3167,18 @@ var array = ({
3158
3167
  return { partial: parsedElements };
3159
3168
  }
3160
3169
  }
3170
+ },
3171
+ createElementStreamTransform() {
3172
+ let publishedElements = 0;
3173
+ return new TransformStream({
3174
+ transform({ partialOutput }, controller) {
3175
+ if (partialOutput != null) {
3176
+ for (; publishedElements < partialOutput.length; publishedElements++) {
3177
+ controller.enqueue(partialOutput[publishedElements]);
3178
+ }
3179
+ }
3180
+ }
3181
+ });
3161
3182
  }
3162
3183
  };
3163
3184
  };
@@ -3167,6 +3188,7 @@ var choice = ({
3167
3188
  description
3168
3189
  }) => {
3169
3190
  return {
3191
+ name: "choice",
3170
3192
  // JSON schema that describes an enumeration:
3171
3193
  responseFormat: Promise.resolve({
3172
3194
  type: "json",
@@ -3233,6 +3255,9 @@ var choice = ({
3233
3255
  }
3234
3256
  }
3235
3257
  }
3258
+ },
3259
+ createElementStreamTransform() {
3260
+ return void 0;
3236
3261
  }
3237
3262
  };
3238
3263
  };
@@ -3241,6 +3266,7 @@ var json = ({
3241
3266
  description
3242
3267
  } = {}) => {
3243
3268
  return {
3269
+ name: "json",
3244
3270
  responseFormat: Promise.resolve({
3245
3271
  type: "json",
3246
3272
  ...name16 != null && { name: name16 },
@@ -3272,6 +3298,9 @@ var json = ({
3272
3298
  return result.value === void 0 ? void 0 : { partial: result.value };
3273
3299
  }
3274
3300
  }
3301
+ },
3302
+ createElementStreamTransform() {
3303
+ return void 0;
3275
3304
  }
3276
3305
  };
3277
3306
  };
@@ -6936,6 +6965,16 @@ var DefaultStreamTextResult = class {
6936
6965
  )
6937
6966
  );
6938
6967
  }
6968
+ get elementStream() {
6969
+ var _a16, _b, _c;
6970
+ const transform = (_a16 = this.outputSpecification) == null ? void 0 : _a16.createElementStreamTransform();
6971
+ if (transform == null) {
6972
+ throw new import_provider24.UnsupportedFunctionalityError({
6973
+ functionality: `element streams in ${(_c = (_b = this.outputSpecification) == null ? void 0 : _b.name) != null ? _c : "text"} mode`
6974
+ });
6975
+ }
6976
+ return createAsyncIterableStream(this.teeStream().pipeThrough(transform));
6977
+ }
6939
6978
  get output() {
6940
6979
  return this.finalStep.then((step) => {
6941
6980
  var _a16;