ai 6.0.0-beta.55 → 6.0.0-beta.57
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 +16 -0
 - package/README.md +4 -4
 - package/dist/index.d.mts +21 -16
 - package/dist/index.d.ts +21 -16
 - package/dist/index.js +118 -49
 - package/dist/index.js.map +1 -1
 - package/dist/index.mjs +118 -51
 - package/dist/index.mjs.map +1 -1
 - package/dist/internal/index.js +112 -41
 - package/dist/internal/index.js.map +1 -1
 - package/dist/internal/index.mjs +112 -41
 - package/dist/internal/index.mjs.map +1 -1
 - package/package.json +4 -4
 
    
        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.57" : "0.0.0-test";
         
     | 
| 
       779 
779 
     | 
    
         | 
| 
       780 
780 
     | 
    
         
             
            // src/util/download/download.ts
         
     | 
| 
       781 
781 
     | 
    
         
             
            var download = async ({ url }) => {
         
     | 
| 
         @@ -1028,7 +1028,7 @@ function convertToLanguageModelMessage({ 
     | 
|
| 
       1028 
1028 
     | 
    
         
             
                            type: "tool-result",
         
     | 
| 
       1029 
1029 
     | 
    
         
             
                            toolCallId: part.toolCallId,
         
     | 
| 
       1030 
1030 
     | 
    
         
             
                            toolName: part.toolName,
         
     | 
| 
       1031 
     | 
    
         
            -
                            output: part.output,
         
     | 
| 
      
 1031 
     | 
    
         
            +
                            output: mapToolResultOutput(part.output),
         
     | 
| 
       1032 
1032 
     | 
    
         
             
                            providerOptions
         
     | 
| 
       1033 
1033 
     | 
    
         
             
                          };
         
     | 
| 
       1034 
1034 
     | 
    
         
             
                        }
         
     | 
| 
         @@ -1044,7 +1044,7 @@ function convertToLanguageModelMessage({ 
     | 
|
| 
       1044 
1044 
     | 
    
         
             
                      type: "tool-result",
         
     | 
| 
       1045 
1045 
     | 
    
         
             
                      toolCallId: part.toolCallId,
         
     | 
| 
       1046 
1046 
     | 
    
         
             
                      toolName: part.toolName,
         
     | 
| 
       1047 
     | 
    
         
            -
                      output: part.output,
         
     | 
| 
      
 1047 
     | 
    
         
            +
                      output: mapToolResultOutput(part.output),
         
     | 
| 
       1048 
1048 
     | 
    
         
             
                      providerOptions: part.providerOptions
         
     | 
| 
       1049 
1049 
     | 
    
         
             
                    })),
         
     | 
| 
       1050 
1050 
     | 
    
         
             
                    providerOptions: message.providerOptions
         
     | 
| 
         @@ -1151,11 +1151,34 @@ function convertPartToLanguageModelPart(part, downloadedAssets) { 
     | 
|
| 
       1151 
1151 
     | 
    
         
             
                }
         
     | 
| 
       1152 
1152 
     | 
    
         
             
              }
         
     | 
| 
       1153 
1153 
     | 
    
         
             
            }
         
     | 
| 
      
 1154 
     | 
    
         
            +
            function mapToolResultOutput(output) {
         
     | 
| 
      
 1155 
     | 
    
         
            +
              if (output.type !== "content") {
         
     | 
| 
      
 1156 
     | 
    
         
            +
                return output;
         
     | 
| 
      
 1157 
     | 
    
         
            +
              }
         
     | 
| 
      
 1158 
     | 
    
         
            +
              return {
         
     | 
| 
      
 1159 
     | 
    
         
            +
                type: "content",
         
     | 
| 
      
 1160 
     | 
    
         
            +
                value: output.value.map((item) => {
         
     | 
| 
      
 1161 
     | 
    
         
            +
                  if (item.type !== "media") {
         
     | 
| 
      
 1162 
     | 
    
         
            +
                    return item;
         
     | 
| 
      
 1163 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1164 
     | 
    
         
            +
                  if (item.mediaType.startsWith("image/")) {
         
     | 
| 
      
 1165 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 1166 
     | 
    
         
            +
                      type: "image-data",
         
     | 
| 
      
 1167 
     | 
    
         
            +
                      data: item.data,
         
     | 
| 
      
 1168 
     | 
    
         
            +
                      mediaType: item.mediaType
         
     | 
| 
      
 1169 
     | 
    
         
            +
                    };
         
     | 
| 
      
 1170 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1171 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 1172 
     | 
    
         
            +
                    type: "file-data",
         
     | 
| 
      
 1173 
     | 
    
         
            +
                    data: item.data,
         
     | 
| 
      
 1174 
     | 
    
         
            +
                    mediaType: item.mediaType
         
     | 
| 
      
 1175 
     | 
    
         
            +
                  };
         
     | 
| 
      
 1176 
     | 
    
         
            +
                })
         
     | 
| 
      
 1177 
     | 
    
         
            +
              };
         
     | 
| 
      
 1178 
     | 
    
         
            +
            }
         
     | 
| 
       1154 
1179 
     | 
    
         | 
| 
       1155 
1180 
     | 
    
         
             
            // src/prompt/create-tool-model-output.ts
         
     | 
| 
       1156 
     | 
    
         
            -
            import {
         
     | 
| 
       1157 
     | 
    
         
            -
              getErrorMessage as getErrorMessage3
         
     | 
| 
       1158 
     | 
    
         
            -
            } from "@ai-sdk/provider";
         
     | 
| 
      
 1181 
     | 
    
         
            +
            import { getErrorMessage as getErrorMessage3 } from "@ai-sdk/provider";
         
     | 
| 
       1159 
1182 
     | 
    
         
             
            function createToolModelOutput({
         
     | 
| 
       1160 
1183 
     | 
    
         
             
              output,
         
     | 
| 
       1161 
1184 
     | 
    
         
             
              tool: tool3,
         
     | 
| 
         @@ -1389,44 +1412,90 @@ var toolCallPartSchema = z4.object({ 
     | 
|
| 
       1389 
1412 
     | 
    
         
             
              providerOptions: providerMetadataSchema.optional(),
         
     | 
| 
       1390 
1413 
     | 
    
         
             
              providerExecuted: z4.boolean().optional()
         
     | 
| 
       1391 
1414 
     | 
    
         
             
            });
         
     | 
| 
       1392 
     | 
    
         
            -
            var outputSchema = z4.discriminatedUnion( 
     | 
| 
       1393 
     | 
    
         
            -
               
     | 
| 
       1394 
     | 
    
         
            -
             
     | 
| 
       1395 
     | 
    
         
            -
                 
     | 
| 
       1396 
     | 
    
         
            -
             
     | 
| 
       1397 
     | 
    
         
            -
             
     | 
| 
       1398 
     | 
    
         
            -
             
     | 
| 
       1399 
     | 
    
         
            -
                 
     | 
| 
       1400 
     | 
    
         
            -
             
     | 
| 
       1401 
     | 
    
         
            -
             
     | 
| 
       1402 
     | 
    
         
            -
             
     | 
| 
       1403 
     | 
    
         
            -
             
     | 
| 
       1404 
     | 
    
         
            -
             
     | 
| 
       1405 
     | 
    
         
            -
             
     | 
| 
       1406 
     | 
    
         
            -
             
     | 
| 
       1407 
     | 
    
         
            -
             
     | 
| 
       1408 
     | 
    
         
            -
             
     | 
| 
       1409 
     | 
    
         
            -
             
     | 
| 
       1410 
     | 
    
         
            -
                 
     | 
| 
       1411 
     | 
    
         
            -
             
     | 
| 
       1412 
     | 
    
         
            -
             
     | 
| 
       1413 
     | 
    
         
            -
             
     | 
| 
       1414 
     | 
    
         
            -
                 
     | 
| 
       1415 
     | 
    
         
            -
                 
     | 
| 
       1416 
     | 
    
         
            -
                  z4. 
     | 
| 
       1417 
     | 
    
         
            -
             
     | 
| 
       1418 
     | 
    
         
            -
             
     | 
| 
       1419 
     | 
    
         
            -
             
     | 
| 
       1420 
     | 
    
         
            -
             
     | 
| 
       1421 
     | 
    
         
            -
             
     | 
| 
       1422 
     | 
    
         
            -
             
     | 
| 
       1423 
     | 
    
         
            -
             
     | 
| 
       1424 
     | 
    
         
            -
                       
     | 
| 
       1425 
     | 
    
         
            -
             
     | 
| 
       1426 
     | 
    
         
            -
             
     | 
| 
       1427 
     | 
    
         
            -
             
     | 
| 
       1428 
     | 
    
         
            -
             
     | 
| 
       1429 
     | 
    
         
            -
             
     | 
| 
      
 1415 
     | 
    
         
            +
            var outputSchema = z4.discriminatedUnion(
         
     | 
| 
      
 1416 
     | 
    
         
            +
              "type",
         
     | 
| 
      
 1417 
     | 
    
         
            +
              [
         
     | 
| 
      
 1418 
     | 
    
         
            +
                z4.object({
         
     | 
| 
      
 1419 
     | 
    
         
            +
                  type: z4.literal("text"),
         
     | 
| 
      
 1420 
     | 
    
         
            +
                  value: z4.string(),
         
     | 
| 
      
 1421 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1422 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1423 
     | 
    
         
            +
                z4.object({
         
     | 
| 
      
 1424 
     | 
    
         
            +
                  type: z4.literal("json"),
         
     | 
| 
      
 1425 
     | 
    
         
            +
                  value: jsonValueSchema,
         
     | 
| 
      
 1426 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1427 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1428 
     | 
    
         
            +
                z4.object({
         
     | 
| 
      
 1429 
     | 
    
         
            +
                  type: z4.literal("execution-denied"),
         
     | 
| 
      
 1430 
     | 
    
         
            +
                  reason: z4.string().optional(),
         
     | 
| 
      
 1431 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1432 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1433 
     | 
    
         
            +
                z4.object({
         
     | 
| 
      
 1434 
     | 
    
         
            +
                  type: z4.literal("error-text"),
         
     | 
| 
      
 1435 
     | 
    
         
            +
                  value: z4.string(),
         
     | 
| 
      
 1436 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1437 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1438 
     | 
    
         
            +
                z4.object({
         
     | 
| 
      
 1439 
     | 
    
         
            +
                  type: z4.literal("error-json"),
         
     | 
| 
      
 1440 
     | 
    
         
            +
                  value: jsonValueSchema,
         
     | 
| 
      
 1441 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1442 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1443 
     | 
    
         
            +
                z4.object({
         
     | 
| 
      
 1444 
     | 
    
         
            +
                  type: z4.literal("content"),
         
     | 
| 
      
 1445 
     | 
    
         
            +
                  value: z4.array(
         
     | 
| 
      
 1446 
     | 
    
         
            +
                    z4.union([
         
     | 
| 
      
 1447 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1448 
     | 
    
         
            +
                        type: z4.literal("text"),
         
     | 
| 
      
 1449 
     | 
    
         
            +
                        text: z4.string(),
         
     | 
| 
      
 1450 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1451 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1452 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1453 
     | 
    
         
            +
                        type: z4.literal("media"),
         
     | 
| 
      
 1454 
     | 
    
         
            +
                        data: z4.string(),
         
     | 
| 
      
 1455 
     | 
    
         
            +
                        mediaType: z4.string()
         
     | 
| 
      
 1456 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1457 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1458 
     | 
    
         
            +
                        type: z4.literal("file-data"),
         
     | 
| 
      
 1459 
     | 
    
         
            +
                        data: z4.string(),
         
     | 
| 
      
 1460 
     | 
    
         
            +
                        mediaType: z4.string(),
         
     | 
| 
      
 1461 
     | 
    
         
            +
                        filename: z4.string().optional(),
         
     | 
| 
      
 1462 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1463 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1464 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1465 
     | 
    
         
            +
                        type: z4.literal("file-url"),
         
     | 
| 
      
 1466 
     | 
    
         
            +
                        url: z4.string(),
         
     | 
| 
      
 1467 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1468 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1469 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1470 
     | 
    
         
            +
                        type: z4.literal("file-id"),
         
     | 
| 
      
 1471 
     | 
    
         
            +
                        fileId: z4.union([z4.string(), z4.record(z4.string(), z4.string())]),
         
     | 
| 
      
 1472 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1473 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1474 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1475 
     | 
    
         
            +
                        type: z4.literal("image-data"),
         
     | 
| 
      
 1476 
     | 
    
         
            +
                        data: z4.string(),
         
     | 
| 
      
 1477 
     | 
    
         
            +
                        mediaType: z4.string(),
         
     | 
| 
      
 1478 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1479 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1480 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1481 
     | 
    
         
            +
                        type: z4.literal("image-url"),
         
     | 
| 
      
 1482 
     | 
    
         
            +
                        url: z4.string(),
         
     | 
| 
      
 1483 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1484 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1485 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1486 
     | 
    
         
            +
                        type: z4.literal("image-file-id"),
         
     | 
| 
      
 1487 
     | 
    
         
            +
                        fileId: z4.union([z4.string(), z4.record(z4.string(), z4.string())]),
         
     | 
| 
      
 1488 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1489 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1490 
     | 
    
         
            +
                      z4.object({
         
     | 
| 
      
 1491 
     | 
    
         
            +
                        type: z4.literal("custom"),
         
     | 
| 
      
 1492 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1493 
     | 
    
         
            +
                      })
         
     | 
| 
      
 1494 
     | 
    
         
            +
                    ])
         
     | 
| 
      
 1495 
     | 
    
         
            +
                  )
         
     | 
| 
      
 1496 
     | 
    
         
            +
                })
         
     | 
| 
      
 1497 
     | 
    
         
            +
              ]
         
     | 
| 
      
 1498 
     | 
    
         
            +
            );
         
     | 
| 
       1430 
1499 
     | 
    
         
             
            var toolResultPartSchema = z4.object({
         
     | 
| 
       1431 
1500 
     | 
    
         
             
              type: z4.literal("tool-result"),
         
     | 
| 
       1432 
1501 
     | 
    
         
             
              toolCallId: z4.string(),
         
     | 
| 
         @@ -6381,8 +6450,8 @@ function convertToModelMessages(messages, options) { 
     | 
|
| 
       6381 
6450 
     | 
    
         
             
            }
         
     | 
| 
       6382 
6451 
     | 
    
         
             
            var convertToCoreMessages = convertToModelMessages;
         
     | 
| 
       6383 
6452 
     | 
    
         | 
| 
       6384 
     | 
    
         
            -
            // src/agent/ 
     | 
| 
       6385 
     | 
    
         
            -
            var  
     | 
| 
      
 6453 
     | 
    
         
            +
            // src/agent/tool-loop-agent.ts
         
     | 
| 
      
 6454 
     | 
    
         
            +
            var ToolLoopAgent = class {
         
     | 
| 
       6386 
6455 
     | 
    
         
             
              constructor(settings) {
         
     | 
| 
       6387 
6456 
     | 
    
         
             
                this.settings = settings;
         
     | 
| 
       6388 
6457 
     | 
    
         
             
              }
         
     | 
| 
         @@ -6425,9 +6494,7 @@ var BasicAgent = class { 
     | 
|
| 
       6425 
6494 
     | 
    
         
             
               */
         
     | 
| 
       6426 
6495 
     | 
    
         
             
              respond(options) {
         
     | 
| 
       6427 
6496 
     | 
    
         
             
                return this.stream({
         
     | 
| 
       6428 
     | 
    
         
            -
                  prompt: convertToModelMessages(options.messages, {
         
     | 
| 
       6429 
     | 
    
         
            -
                    tools: this.tools
         
     | 
| 
       6430 
     | 
    
         
            -
                  })
         
     | 
| 
      
 6497 
     | 
    
         
            +
                  prompt: convertToModelMessages(options.messages, { tools: this.tools })
         
     | 
| 
       6431 
6498 
     | 
    
         
             
                }).toUIMessageStreamResponse();
         
     | 
| 
       6432 
6499 
     | 
    
         
             
              }
         
     | 
| 
       6433 
6500 
     | 
    
         
             
            };
         
     | 
| 
         @@ -11097,11 +11164,10 @@ export { 
     | 
|
| 
       11097 
11164 
     | 
    
         
             
              AISDKError18 as AISDKError,
         
     | 
| 
       11098 
11165 
     | 
    
         
             
              APICallError,
         
     | 
| 
       11099 
11166 
     | 
    
         
             
              AbstractChat,
         
     | 
| 
       11100 
     | 
    
         
            -
              BasicAgent,
         
     | 
| 
       11101 
11167 
     | 
    
         
             
              DefaultChatTransport,
         
     | 
| 
       11102 
11168 
     | 
    
         
             
              DownloadError,
         
     | 
| 
       11103 
11169 
     | 
    
         
             
              EmptyResponseBodyError,
         
     | 
| 
       11104 
     | 
    
         
            -
               
     | 
| 
      
 11170 
     | 
    
         
            +
              ToolLoopAgent as Experimental_Agent,
         
     | 
| 
       11105 
11171 
     | 
    
         
             
              HttpChatTransport,
         
     | 
| 
       11106 
11172 
     | 
    
         
             
              InvalidArgumentError,
         
     | 
| 
       11107 
11173 
     | 
    
         
             
              InvalidDataContentError,
         
     | 
| 
         @@ -11131,6 +11197,7 @@ export { 
     | 
|
| 
       11131 
11197 
     | 
    
         
             
              TextStreamChatTransport,
         
     | 
| 
       11132 
11198 
     | 
    
         
             
              TooManyEmbeddingValuesForCallError,
         
     | 
| 
       11133 
11199 
     | 
    
         
             
              ToolCallRepairError,
         
     | 
| 
      
 11200 
     | 
    
         
            +
              ToolLoopAgent,
         
     | 
| 
       11134 
11201 
     | 
    
         
             
              TypeValidationError,
         
     | 
| 
       11135 
11202 
     | 
    
         
             
              UI_MESSAGE_STREAM_HEADERS,
         
     | 
| 
       11136 
11203 
     | 
    
         
             
              UnsupportedFunctionalityError,
         
     |