ai 6.0.0-beta.68 → 6.0.0-beta.69
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/CHANGELOG.md +6 -0
 - package/dist/index.d.mts +26 -12
 - package/dist/index.d.ts +26 -12
 - package/dist/index.js +144 -40
 - package/dist/index.js.map +1 -1
 - package/dist/index.mjs +126 -20
 - package/dist/index.mjs.map +1 -1
 - package/dist/internal/index.js +1 -1
 - package/dist/internal/index.mjs +1 -1
 - package/package.json +1 -1
 
    
        package/dist/index.mjs
    CHANGED
    
    | 
         @@ -775,7 +775,7 @@ import { 
     | 
|
| 
       775 
775 
     | 
    
         
             
            } from "@ai-sdk/provider-utils";
         
     | 
| 
       776 
776 
     | 
    
         | 
| 
       777 
777 
     | 
    
         
             
            // src/version.ts
         
     | 
| 
       778 
     | 
    
         
            -
            var VERSION = true ? "6.0.0-beta. 
     | 
| 
      
 778 
     | 
    
         
            +
            var VERSION = true ? "6.0.0-beta.69" : "0.0.0-test";
         
     | 
| 
       779 
779 
     | 
    
         | 
| 
       780 
780 
     | 
    
         
             
            // src/util/download/download.ts
         
     | 
| 
       781 
781 
     | 
    
         
             
            var download = async ({ url }) => {
         
     | 
| 
         @@ -7219,13 +7219,13 @@ var DefaultEmbedResult = class { 
     | 
|
| 
       7219 
7219 
     | 
    
         
             
            import { withUserAgentSuffix as withUserAgentSuffix4 } from "@ai-sdk/provider-utils";
         
     | 
| 
       7220 
7220 
     | 
    
         | 
| 
       7221 
7221 
     | 
    
         
             
            // src/util/split-array.ts
         
     | 
| 
       7222 
     | 
    
         
            -
            function splitArray( 
     | 
| 
      
 7222 
     | 
    
         
            +
            function splitArray(array2, chunkSize) {
         
     | 
| 
       7223 
7223 
     | 
    
         
             
              if (chunkSize <= 0) {
         
     | 
| 
       7224 
7224 
     | 
    
         
             
                throw new Error("chunkSize must be greater than 0");
         
     | 
| 
       7225 
7225 
     | 
    
         
             
              }
         
     | 
| 
       7226 
7226 
     | 
    
         
             
              const result = [];
         
     | 
| 
       7227 
     | 
    
         
            -
              for (let i = 0; i <  
     | 
| 
       7228 
     | 
    
         
            -
                result.push( 
     | 
| 
      
 7227 
     | 
    
         
            +
              for (let i = 0; i < array2.length; i += chunkSize) {
         
     | 
| 
      
 7228 
     | 
    
         
            +
                result.push(array2.slice(i, i + chunkSize));
         
     | 
| 
       7229 
7229 
     | 
    
         
             
              }
         
     | 
| 
       7230 
7230 
     | 
    
         
             
              return result;
         
     | 
| 
       7231 
7231 
     | 
    
         
             
            }
         
     | 
| 
         @@ -7747,9 +7747,9 @@ var arrayOutputStrategy = (schema) => { 
     | 
|
| 
       7747 
7747 
     | 
    
         
             
                        transform(chunk, controller) {
         
     | 
| 
       7748 
7748 
     | 
    
         
             
                          switch (chunk.type) {
         
     | 
| 
       7749 
7749 
     | 
    
         
             
                            case "object": {
         
     | 
| 
       7750 
     | 
    
         
            -
                              const  
     | 
| 
       7751 
     | 
    
         
            -
                              for (; publishedElements <  
     | 
| 
       7752 
     | 
    
         
            -
                                controller.enqueue( 
     | 
| 
      
 7750 
     | 
    
         
            +
                              const array2 = chunk.object;
         
     | 
| 
      
 7751 
     | 
    
         
            +
                              for (; publishedElements < array2.length; publishedElements++) {
         
     | 
| 
      
 7752 
     | 
    
         
            +
                                controller.enqueue(array2[publishedElements]);
         
     | 
| 
       7753 
7753 
     | 
    
         
             
                              }
         
     | 
| 
       7754 
7754 
     | 
    
         
             
                              break;
         
     | 
| 
       7755 
7755 
     | 
    
         
             
                            }
         
     | 
| 
         @@ -9060,9 +9060,13 @@ var DefaultSpeechResult = class { 
     | 
|
| 
       9060 
9060 
     | 
    
         
             
            // src/generate-text/output.ts
         
     | 
| 
       9061 
9061 
     | 
    
         
             
            var output_exports = {};
         
     | 
| 
       9062 
9062 
     | 
    
         
             
            __export(output_exports, {
         
     | 
| 
      
 9063 
     | 
    
         
            +
              array: () => array,
         
     | 
| 
       9063 
9064 
     | 
    
         
             
              object: () => object,
         
     | 
| 
       9064 
9065 
     | 
    
         
             
              text: () => text
         
     | 
| 
       9065 
9066 
     | 
    
         
             
            });
         
     | 
| 
      
 9067 
     | 
    
         
            +
            import {
         
     | 
| 
      
 9068 
     | 
    
         
            +
              TypeValidationError as TypeValidationError5
         
     | 
| 
      
 9069 
     | 
    
         
            +
            } from "@ai-sdk/provider";
         
     | 
| 
       9066 
9070 
     | 
    
         
             
            import {
         
     | 
| 
       9067 
9071 
     | 
    
         
             
              asSchema as asSchema4,
         
     | 
| 
       9068 
9072 
     | 
    
         
             
              resolve,
         
     | 
| 
         @@ -9072,11 +9076,11 @@ import { 
     | 
|
| 
       9072 
9076 
     | 
    
         
             
            var text = () => ({
         
     | 
| 
       9073 
9077 
     | 
    
         
             
              type: "text",
         
     | 
| 
       9074 
9078 
     | 
    
         
             
              responseFormat: Promise.resolve({ type: "text" }),
         
     | 
| 
       9075 
     | 
    
         
            -
              async parsePartial({ text: text2 }) {
         
     | 
| 
       9076 
     | 
    
         
            -
                return { partial: text2 };
         
     | 
| 
       9077 
     | 
    
         
            -
              },
         
     | 
| 
       9078 
9079 
     | 
    
         
             
              async parseOutput({ text: text2 }) {
         
     | 
| 
       9079 
9080 
     | 
    
         
             
                return text2;
         
     | 
| 
      
 9081 
     | 
    
         
            +
              },
         
     | 
| 
      
 9082 
     | 
    
         
            +
              async parsePartial({ text: text2 }) {
         
     | 
| 
      
 9083 
     | 
    
         
            +
                return { partial: text2 };
         
     | 
| 
       9080 
9084 
     | 
    
         
             
              }
         
     | 
| 
       9081 
9085 
     | 
    
         
             
            });
         
     | 
| 
       9082 
9086 
     | 
    
         
             
            var object = ({
         
     | 
| 
         @@ -9089,24 +9093,78 @@ var object = ({ 
     | 
|
| 
       9089 
9093 
     | 
    
         
             
                  type: "json",
         
     | 
| 
       9090 
9094 
     | 
    
         
             
                  schema: jsonSchema3
         
     | 
| 
       9091 
9095 
     | 
    
         
             
                })),
         
     | 
| 
      
 9096 
     | 
    
         
            +
                async parseOutput({ text: text2 }, context) {
         
     | 
| 
      
 9097 
     | 
    
         
            +
                  const parseResult = await safeParseJSON4({ text: text2 });
         
     | 
| 
      
 9098 
     | 
    
         
            +
                  if (!parseResult.success) {
         
     | 
| 
      
 9099 
     | 
    
         
            +
                    throw new NoObjectGeneratedError({
         
     | 
| 
      
 9100 
     | 
    
         
            +
                      message: "No object generated: could not parse the response.",
         
     | 
| 
      
 9101 
     | 
    
         
            +
                      cause: parseResult.error,
         
     | 
| 
      
 9102 
     | 
    
         
            +
                      text: text2,
         
     | 
| 
      
 9103 
     | 
    
         
            +
                      response: context.response,
         
     | 
| 
      
 9104 
     | 
    
         
            +
                      usage: context.usage,
         
     | 
| 
      
 9105 
     | 
    
         
            +
                      finishReason: context.finishReason
         
     | 
| 
      
 9106 
     | 
    
         
            +
                    });
         
     | 
| 
      
 9107 
     | 
    
         
            +
                  }
         
     | 
| 
      
 9108 
     | 
    
         
            +
                  const validationResult = await safeValidateTypes4({
         
     | 
| 
      
 9109 
     | 
    
         
            +
                    value: parseResult.value,
         
     | 
| 
      
 9110 
     | 
    
         
            +
                    schema
         
     | 
| 
      
 9111 
     | 
    
         
            +
                  });
         
     | 
| 
      
 9112 
     | 
    
         
            +
                  if (!validationResult.success) {
         
     | 
| 
      
 9113 
     | 
    
         
            +
                    throw new NoObjectGeneratedError({
         
     | 
| 
      
 9114 
     | 
    
         
            +
                      message: "No object generated: response did not match schema.",
         
     | 
| 
      
 9115 
     | 
    
         
            +
                      cause: validationResult.error,
         
     | 
| 
      
 9116 
     | 
    
         
            +
                      text: text2,
         
     | 
| 
      
 9117 
     | 
    
         
            +
                      response: context.response,
         
     | 
| 
      
 9118 
     | 
    
         
            +
                      usage: context.usage,
         
     | 
| 
      
 9119 
     | 
    
         
            +
                      finishReason: context.finishReason
         
     | 
| 
      
 9120 
     | 
    
         
            +
                    });
         
     | 
| 
      
 9121 
     | 
    
         
            +
                  }
         
     | 
| 
      
 9122 
     | 
    
         
            +
                  return validationResult.value;
         
     | 
| 
      
 9123 
     | 
    
         
            +
                },
         
     | 
| 
       9092 
9124 
     | 
    
         
             
                async parsePartial({ text: text2 }) {
         
     | 
| 
       9093 
9125 
     | 
    
         
             
                  const result = await parsePartialJson(text2);
         
     | 
| 
       9094 
9126 
     | 
    
         
             
                  switch (result.state) {
         
     | 
| 
       9095 
9127 
     | 
    
         
             
                    case "failed-parse":
         
     | 
| 
       9096 
     | 
    
         
            -
                    case "undefined-input":
         
     | 
| 
      
 9128 
     | 
    
         
            +
                    case "undefined-input": {
         
     | 
| 
       9097 
9129 
     | 
    
         
             
                      return void 0;
         
     | 
| 
      
 9130 
     | 
    
         
            +
                    }
         
     | 
| 
       9098 
9131 
     | 
    
         
             
                    case "repaired-parse":
         
     | 
| 
       9099 
     | 
    
         
            -
                    case "successful-parse":
         
     | 
| 
      
 9132 
     | 
    
         
            +
                    case "successful-parse": {
         
     | 
| 
       9100 
9133 
     | 
    
         
             
                      return {
         
     | 
| 
       9101 
9134 
     | 
    
         
             
                        // Note: currently no validation of partial results:
         
     | 
| 
       9102 
9135 
     | 
    
         
             
                        partial: result.value
         
     | 
| 
       9103 
9136 
     | 
    
         
             
                      };
         
     | 
| 
      
 9137 
     | 
    
         
            +
                    }
         
     | 
| 
       9104 
9138 
     | 
    
         
             
                    default: {
         
     | 
| 
       9105 
9139 
     | 
    
         
             
                      const _exhaustiveCheck = result.state;
         
     | 
| 
       9106 
9140 
     | 
    
         
             
                      throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
         
     | 
| 
       9107 
9141 
     | 
    
         
             
                    }
         
     | 
| 
       9108 
9142 
     | 
    
         
             
                  }
         
     | 
| 
       9109 
     | 
    
         
            -
                } 
     | 
| 
      
 9143 
     | 
    
         
            +
                }
         
     | 
| 
      
 9144 
     | 
    
         
            +
              };
         
     | 
| 
      
 9145 
     | 
    
         
            +
            };
         
     | 
| 
      
 9146 
     | 
    
         
            +
            var array = ({
         
     | 
| 
      
 9147 
     | 
    
         
            +
              element: inputElementSchema
         
     | 
| 
      
 9148 
     | 
    
         
            +
            }) => {
         
     | 
| 
      
 9149 
     | 
    
         
            +
              const elementSchema = asSchema4(inputElementSchema);
         
     | 
| 
      
 9150 
     | 
    
         
            +
              return {
         
     | 
| 
      
 9151 
     | 
    
         
            +
                type: "object",
         
     | 
| 
      
 9152 
     | 
    
         
            +
                // returns a JSON schema that describes an array of elements:
         
     | 
| 
      
 9153 
     | 
    
         
            +
                responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema3) => {
         
     | 
| 
      
 9154 
     | 
    
         
            +
                  const { $schema, ...itemSchema } = jsonSchema3;
         
     | 
| 
      
 9155 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 9156 
     | 
    
         
            +
                    type: "json",
         
     | 
| 
      
 9157 
     | 
    
         
            +
                    schema: {
         
     | 
| 
      
 9158 
     | 
    
         
            +
                      $schema: "http://json-schema.org/draft-07/schema#",
         
     | 
| 
      
 9159 
     | 
    
         
            +
                      type: "object",
         
     | 
| 
      
 9160 
     | 
    
         
            +
                      properties: {
         
     | 
| 
      
 9161 
     | 
    
         
            +
                        elements: { type: "array", items: itemSchema }
         
     | 
| 
      
 9162 
     | 
    
         
            +
                      },
         
     | 
| 
      
 9163 
     | 
    
         
            +
                      required: ["elements"],
         
     | 
| 
      
 9164 
     | 
    
         
            +
                      additionalProperties: false
         
     | 
| 
      
 9165 
     | 
    
         
            +
                    }
         
     | 
| 
      
 9166 
     | 
    
         
            +
                  };
         
     | 
| 
      
 9167 
     | 
    
         
            +
                }),
         
     | 
| 
       9110 
9168 
     | 
    
         
             
                async parseOutput({ text: text2 }, context) {
         
     | 
| 
       9111 
9169 
     | 
    
         
             
                  const parseResult = await safeParseJSON4({ text: text2 });
         
     | 
| 
       9112 
9170 
     | 
    
         
             
                  if (!parseResult.success) {
         
     | 
| 
         @@ -9119,21 +9177,69 @@ var object = ({ 
     | 
|
| 
       9119 
9177 
     | 
    
         
             
                      finishReason: context.finishReason
         
     | 
| 
       9120 
9178 
     | 
    
         
             
                    });
         
     | 
| 
       9121 
9179 
     | 
    
         
             
                  }
         
     | 
| 
       9122 
     | 
    
         
            -
                  const  
     | 
| 
       9123 
     | 
    
         
            -
             
     | 
| 
       9124 
     | 
    
         
            -
                    schema
         
     | 
| 
       9125 
     | 
    
         
            -
                  });
         
     | 
| 
       9126 
     | 
    
         
            -
                  if (!validationResult.success) {
         
     | 
| 
      
 9180 
     | 
    
         
            +
                  const outerValue = parseResult.value;
         
     | 
| 
      
 9181 
     | 
    
         
            +
                  if (outerValue == null || typeof outerValue !== "object" || !("elements" in outerValue) || !Array.isArray(outerValue.elements)) {
         
     | 
| 
       9127 
9182 
     | 
    
         
             
                    throw new NoObjectGeneratedError({
         
     | 
| 
       9128 
9183 
     | 
    
         
             
                      message: "No object generated: response did not match schema.",
         
     | 
| 
       9129 
     | 
    
         
            -
                      cause:  
     | 
| 
      
 9184 
     | 
    
         
            +
                      cause: new TypeValidationError5({
         
     | 
| 
      
 9185 
     | 
    
         
            +
                        value: outerValue,
         
     | 
| 
      
 9186 
     | 
    
         
            +
                        cause: "response must be an object with an elements array"
         
     | 
| 
      
 9187 
     | 
    
         
            +
                      }),
         
     | 
| 
       9130 
9188 
     | 
    
         
             
                      text: text2,
         
     | 
| 
       9131 
9189 
     | 
    
         
             
                      response: context.response,
         
     | 
| 
       9132 
9190 
     | 
    
         
             
                      usage: context.usage,
         
     | 
| 
       9133 
9191 
     | 
    
         
             
                      finishReason: context.finishReason
         
     | 
| 
       9134 
9192 
     | 
    
         
             
                    });
         
     | 
| 
       9135 
9193 
     | 
    
         
             
                  }
         
     | 
| 
       9136 
     | 
    
         
            -
                   
     | 
| 
      
 9194 
     | 
    
         
            +
                  for (const element of outerValue.elements) {
         
     | 
| 
      
 9195 
     | 
    
         
            +
                    const validationResult = await safeValidateTypes4({
         
     | 
| 
      
 9196 
     | 
    
         
            +
                      value: element,
         
     | 
| 
      
 9197 
     | 
    
         
            +
                      schema: elementSchema
         
     | 
| 
      
 9198 
     | 
    
         
            +
                    });
         
     | 
| 
      
 9199 
     | 
    
         
            +
                    if (!validationResult.success) {
         
     | 
| 
      
 9200 
     | 
    
         
            +
                      throw new NoObjectGeneratedError({
         
     | 
| 
      
 9201 
     | 
    
         
            +
                        message: "No object generated: response did not match schema.",
         
     | 
| 
      
 9202 
     | 
    
         
            +
                        cause: validationResult.error,
         
     | 
| 
      
 9203 
     | 
    
         
            +
                        text: text2,
         
     | 
| 
      
 9204 
     | 
    
         
            +
                        response: context.response,
         
     | 
| 
      
 9205 
     | 
    
         
            +
                        usage: context.usage,
         
     | 
| 
      
 9206 
     | 
    
         
            +
                        finishReason: context.finishReason
         
     | 
| 
      
 9207 
     | 
    
         
            +
                      });
         
     | 
| 
      
 9208 
     | 
    
         
            +
                    }
         
     | 
| 
      
 9209 
     | 
    
         
            +
                  }
         
     | 
| 
      
 9210 
     | 
    
         
            +
                  return outerValue.elements;
         
     | 
| 
      
 9211 
     | 
    
         
            +
                },
         
     | 
| 
      
 9212 
     | 
    
         
            +
                async parsePartial({ text: text2 }) {
         
     | 
| 
      
 9213 
     | 
    
         
            +
                  const result = await parsePartialJson(text2);
         
     | 
| 
      
 9214 
     | 
    
         
            +
                  switch (result.state) {
         
     | 
| 
      
 9215 
     | 
    
         
            +
                    case "failed-parse":
         
     | 
| 
      
 9216 
     | 
    
         
            +
                    case "undefined-input": {
         
     | 
| 
      
 9217 
     | 
    
         
            +
                      return void 0;
         
     | 
| 
      
 9218 
     | 
    
         
            +
                    }
         
     | 
| 
      
 9219 
     | 
    
         
            +
                    case "repaired-parse":
         
     | 
| 
      
 9220 
     | 
    
         
            +
                    case "successful-parse": {
         
     | 
| 
      
 9221 
     | 
    
         
            +
                      const outerValue = result.value;
         
     | 
| 
      
 9222 
     | 
    
         
            +
                      if (outerValue == null || typeof outerValue !== "object" || !("elements" in outerValue) || !Array.isArray(outerValue.elements)) {
         
     | 
| 
      
 9223 
     | 
    
         
            +
                        return void 0;
         
     | 
| 
      
 9224 
     | 
    
         
            +
                      }
         
     | 
| 
      
 9225 
     | 
    
         
            +
                      const rawElements = result.state === "repaired-parse" && outerValue.elements.length > 0 ? outerValue.elements.slice(0, -1) : outerValue.elements;
         
     | 
| 
      
 9226 
     | 
    
         
            +
                      const parsedElements = [];
         
     | 
| 
      
 9227 
     | 
    
         
            +
                      for (const rawElement of rawElements) {
         
     | 
| 
      
 9228 
     | 
    
         
            +
                        const validationResult = await safeValidateTypes4({
         
     | 
| 
      
 9229 
     | 
    
         
            +
                          value: rawElement,
         
     | 
| 
      
 9230 
     | 
    
         
            +
                          schema: elementSchema
         
     | 
| 
      
 9231 
     | 
    
         
            +
                        });
         
     | 
| 
      
 9232 
     | 
    
         
            +
                        if (validationResult.success) {
         
     | 
| 
      
 9233 
     | 
    
         
            +
                          parsedElements.push(validationResult.value);
         
     | 
| 
      
 9234 
     | 
    
         
            +
                        }
         
     | 
| 
      
 9235 
     | 
    
         
            +
                      }
         
     | 
| 
      
 9236 
     | 
    
         
            +
                      return { partial: parsedElements };
         
     | 
| 
      
 9237 
     | 
    
         
            +
                    }
         
     | 
| 
      
 9238 
     | 
    
         
            +
                    default: {
         
     | 
| 
      
 9239 
     | 
    
         
            +
                      const _exhaustiveCheck = result.state;
         
     | 
| 
      
 9240 
     | 
    
         
            +
                      throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
         
     | 
| 
      
 9241 
     | 
    
         
            +
                    }
         
     | 
| 
      
 9242 
     | 
    
         
            +
                  }
         
     | 
| 
       9137 
9243 
     | 
    
         
             
                }
         
     | 
| 
       9138 
9244 
     | 
    
         
             
              };
         
     | 
| 
       9139 
9245 
     | 
    
         
             
            };
         
     |