ai 6.0.0-beta.54 → 6.0.0-beta.56
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/dist/index.js +113 -42
 - package/dist/index.js.map +1 -1
 - package/dist/index.mjs +114 -45
 - 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/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,5 +1,21 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # ai
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            ## 6.0.0-beta.56
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            ### Patch Changes
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - 3794514: feat: flexible tool output content support
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Updated dependencies [3794514]
         
     | 
| 
      
 9 
     | 
    
         
            +
              - @ai-sdk/provider-utils@4.0.0-beta.19
         
     | 
| 
      
 10 
     | 
    
         
            +
              - @ai-sdk/provider@3.0.0-beta.8
         
     | 
| 
      
 11 
     | 
    
         
            +
              - @ai-sdk/gateway@2.0.0-beta.35
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            ## 6.0.0-beta.55
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            ### Patch Changes
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            - 42cf7ed: fix(agent): use tool.toModelOutput when available
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       3 
19 
     | 
    
         
             
            ## 6.0.0-beta.54
         
     | 
| 
       4 
20 
     | 
    
         | 
| 
       5 
21 
     | 
    
         
             
            ### Patch Changes
         
     | 
    
        package/dist/index.js
    CHANGED
    
    | 
         @@ -870,7 +870,7 @@ function detectMediaType({ 
     | 
|
| 
       870 
870 
     | 
    
         
             
            var import_provider_utils2 = require("@ai-sdk/provider-utils");
         
     | 
| 
       871 
871 
     | 
    
         | 
| 
       872 
872 
     | 
    
         
             
            // src/version.ts
         
     | 
| 
       873 
     | 
    
         
            -
            var VERSION = true ? "6.0.0-beta. 
     | 
| 
      
 873 
     | 
    
         
            +
            var VERSION = true ? "6.0.0-beta.56" : "0.0.0-test";
         
     | 
| 
       874 
874 
     | 
    
         | 
| 
       875 
875 
     | 
    
         
             
            // src/util/download/download.ts
         
     | 
| 
       876 
876 
     | 
    
         
             
            var download = async ({ url }) => {
         
     | 
| 
         @@ -1120,7 +1120,7 @@ function convertToLanguageModelMessage({ 
     | 
|
| 
       1120 
1120 
     | 
    
         
             
                            type: "tool-result",
         
     | 
| 
       1121 
1121 
     | 
    
         
             
                            toolCallId: part.toolCallId,
         
     | 
| 
       1122 
1122 
     | 
    
         
             
                            toolName: part.toolName,
         
     | 
| 
       1123 
     | 
    
         
            -
                            output: part.output,
         
     | 
| 
      
 1123 
     | 
    
         
            +
                            output: mapToolResultOutput(part.output),
         
     | 
| 
       1124 
1124 
     | 
    
         
             
                            providerOptions
         
     | 
| 
       1125 
1125 
     | 
    
         
             
                          };
         
     | 
| 
       1126 
1126 
     | 
    
         
             
                        }
         
     | 
| 
         @@ -1136,7 +1136,7 @@ function convertToLanguageModelMessage({ 
     | 
|
| 
       1136 
1136 
     | 
    
         
             
                      type: "tool-result",
         
     | 
| 
       1137 
1137 
     | 
    
         
             
                      toolCallId: part.toolCallId,
         
     | 
| 
       1138 
1138 
     | 
    
         
             
                      toolName: part.toolName,
         
     | 
| 
       1139 
     | 
    
         
            -
                      output: part.output,
         
     | 
| 
      
 1139 
     | 
    
         
            +
                      output: mapToolResultOutput(part.output),
         
     | 
| 
       1140 
1140 
     | 
    
         
             
                      providerOptions: part.providerOptions
         
     | 
| 
       1141 
1141 
     | 
    
         
             
                    })),
         
     | 
| 
       1142 
1142 
     | 
    
         
             
                    providerOptions: message.providerOptions
         
     | 
| 
         @@ -1243,6 +1243,31 @@ function convertPartToLanguageModelPart(part, downloadedAssets) { 
     | 
|
| 
       1243 
1243 
     | 
    
         
             
                }
         
     | 
| 
       1244 
1244 
     | 
    
         
             
              }
         
     | 
| 
       1245 
1245 
     | 
    
         
             
            }
         
     | 
| 
      
 1246 
     | 
    
         
            +
            function mapToolResultOutput(output) {
         
     | 
| 
      
 1247 
     | 
    
         
            +
              if (output.type !== "content") {
         
     | 
| 
      
 1248 
     | 
    
         
            +
                return output;
         
     | 
| 
      
 1249 
     | 
    
         
            +
              }
         
     | 
| 
      
 1250 
     | 
    
         
            +
              return {
         
     | 
| 
      
 1251 
     | 
    
         
            +
                type: "content",
         
     | 
| 
      
 1252 
     | 
    
         
            +
                value: output.value.map((item) => {
         
     | 
| 
      
 1253 
     | 
    
         
            +
                  if (item.type !== "media") {
         
     | 
| 
      
 1254 
     | 
    
         
            +
                    return item;
         
     | 
| 
      
 1255 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1256 
     | 
    
         
            +
                  if (item.mediaType.startsWith("image/")) {
         
     | 
| 
      
 1257 
     | 
    
         
            +
                    return {
         
     | 
| 
      
 1258 
     | 
    
         
            +
                      type: "image-data",
         
     | 
| 
      
 1259 
     | 
    
         
            +
                      data: item.data,
         
     | 
| 
      
 1260 
     | 
    
         
            +
                      mediaType: item.mediaType
         
     | 
| 
      
 1261 
     | 
    
         
            +
                    };
         
     | 
| 
      
 1262 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1263 
     | 
    
         
            +
                  return {
         
     | 
| 
      
 1264 
     | 
    
         
            +
                    type: "file-data",
         
     | 
| 
      
 1265 
     | 
    
         
            +
                    data: item.data,
         
     | 
| 
      
 1266 
     | 
    
         
            +
                    mediaType: item.mediaType
         
     | 
| 
      
 1267 
     | 
    
         
            +
                  };
         
     | 
| 
      
 1268 
     | 
    
         
            +
                })
         
     | 
| 
      
 1269 
     | 
    
         
            +
              };
         
     | 
| 
      
 1270 
     | 
    
         
            +
            }
         
     | 
| 
       1246 
1271 
     | 
    
         | 
| 
       1247 
1272 
     | 
    
         
             
            // src/prompt/create-tool-model-output.ts
         
     | 
| 
       1248 
1273 
     | 
    
         
             
            var import_provider20 = require("@ai-sdk/provider");
         
     | 
| 
         @@ -1479,44 +1504,90 @@ var toolCallPartSchema = import_v44.z.object({ 
     | 
|
| 
       1479 
1504 
     | 
    
         
             
              providerOptions: providerMetadataSchema.optional(),
         
     | 
| 
       1480 
1505 
     | 
    
         
             
              providerExecuted: import_v44.z.boolean().optional()
         
     | 
| 
       1481 
1506 
     | 
    
         
             
            });
         
     | 
| 
       1482 
     | 
    
         
            -
            var outputSchema = import_v44.z.discriminatedUnion( 
     | 
| 
       1483 
     | 
    
         
            -
               
     | 
| 
       1484 
     | 
    
         
            -
             
     | 
| 
       1485 
     | 
    
         
            -
                 
     | 
| 
       1486 
     | 
    
         
            -
             
     | 
| 
       1487 
     | 
    
         
            -
             
     | 
| 
       1488 
     | 
    
         
            -
             
     | 
| 
       1489 
     | 
    
         
            -
                 
     | 
| 
       1490 
     | 
    
         
            -
             
     | 
| 
       1491 
     | 
    
         
            -
             
     | 
| 
       1492 
     | 
    
         
            -
             
     | 
| 
       1493 
     | 
    
         
            -
             
     | 
| 
       1494 
     | 
    
         
            -
             
     | 
| 
       1495 
     | 
    
         
            -
             
     | 
| 
       1496 
     | 
    
         
            -
             
     | 
| 
       1497 
     | 
    
         
            -
             
     | 
| 
       1498 
     | 
    
         
            -
             
     | 
| 
       1499 
     | 
    
         
            -
             
     | 
| 
       1500 
     | 
    
         
            -
                 
     | 
| 
       1501 
     | 
    
         
            -
             
     | 
| 
       1502 
     | 
    
         
            -
             
     | 
| 
       1503 
     | 
    
         
            -
             
     | 
| 
       1504 
     | 
    
         
            -
                 
     | 
| 
       1505 
     | 
    
         
            -
                 
     | 
| 
       1506 
     | 
    
         
            -
                  import_v44.z. 
     | 
| 
       1507 
     | 
    
         
            -
             
     | 
| 
       1508 
     | 
    
         
            -
             
     | 
| 
       1509 
     | 
    
         
            -
             
     | 
| 
       1510 
     | 
    
         
            -
             
     | 
| 
       1511 
     | 
    
         
            -
             
     | 
| 
       1512 
     | 
    
         
            -
             
     | 
| 
       1513 
     | 
    
         
            -
             
     | 
| 
       1514 
     | 
    
         
            -
                       
     | 
| 
       1515 
     | 
    
         
            -
             
     | 
| 
       1516 
     | 
    
         
            -
             
     | 
| 
       1517 
     | 
    
         
            -
             
     | 
| 
       1518 
     | 
    
         
            -
             
     | 
| 
       1519 
     | 
    
         
            -
             
     | 
| 
      
 1507 
     | 
    
         
            +
            var outputSchema = import_v44.z.discriminatedUnion(
         
     | 
| 
      
 1508 
     | 
    
         
            +
              "type",
         
     | 
| 
      
 1509 
     | 
    
         
            +
              [
         
     | 
| 
      
 1510 
     | 
    
         
            +
                import_v44.z.object({
         
     | 
| 
      
 1511 
     | 
    
         
            +
                  type: import_v44.z.literal("text"),
         
     | 
| 
      
 1512 
     | 
    
         
            +
                  value: import_v44.z.string(),
         
     | 
| 
      
 1513 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1514 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1515 
     | 
    
         
            +
                import_v44.z.object({
         
     | 
| 
      
 1516 
     | 
    
         
            +
                  type: import_v44.z.literal("json"),
         
     | 
| 
      
 1517 
     | 
    
         
            +
                  value: jsonValueSchema,
         
     | 
| 
      
 1518 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1519 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1520 
     | 
    
         
            +
                import_v44.z.object({
         
     | 
| 
      
 1521 
     | 
    
         
            +
                  type: import_v44.z.literal("execution-denied"),
         
     | 
| 
      
 1522 
     | 
    
         
            +
                  reason: import_v44.z.string().optional(),
         
     | 
| 
      
 1523 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1524 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1525 
     | 
    
         
            +
                import_v44.z.object({
         
     | 
| 
      
 1526 
     | 
    
         
            +
                  type: import_v44.z.literal("error-text"),
         
     | 
| 
      
 1527 
     | 
    
         
            +
                  value: import_v44.z.string(),
         
     | 
| 
      
 1528 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1529 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1530 
     | 
    
         
            +
                import_v44.z.object({
         
     | 
| 
      
 1531 
     | 
    
         
            +
                  type: import_v44.z.literal("error-json"),
         
     | 
| 
      
 1532 
     | 
    
         
            +
                  value: jsonValueSchema,
         
     | 
| 
      
 1533 
     | 
    
         
            +
                  providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1534 
     | 
    
         
            +
                }),
         
     | 
| 
      
 1535 
     | 
    
         
            +
                import_v44.z.object({
         
     | 
| 
      
 1536 
     | 
    
         
            +
                  type: import_v44.z.literal("content"),
         
     | 
| 
      
 1537 
     | 
    
         
            +
                  value: import_v44.z.array(
         
     | 
| 
      
 1538 
     | 
    
         
            +
                    import_v44.z.union([
         
     | 
| 
      
 1539 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1540 
     | 
    
         
            +
                        type: import_v44.z.literal("text"),
         
     | 
| 
      
 1541 
     | 
    
         
            +
                        text: import_v44.z.string(),
         
     | 
| 
      
 1542 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1543 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1544 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1545 
     | 
    
         
            +
                        type: import_v44.z.literal("media"),
         
     | 
| 
      
 1546 
     | 
    
         
            +
                        data: import_v44.z.string(),
         
     | 
| 
      
 1547 
     | 
    
         
            +
                        mediaType: import_v44.z.string()
         
     | 
| 
      
 1548 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1549 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1550 
     | 
    
         
            +
                        type: import_v44.z.literal("file-data"),
         
     | 
| 
      
 1551 
     | 
    
         
            +
                        data: import_v44.z.string(),
         
     | 
| 
      
 1552 
     | 
    
         
            +
                        mediaType: import_v44.z.string(),
         
     | 
| 
      
 1553 
     | 
    
         
            +
                        filename: import_v44.z.string().optional(),
         
     | 
| 
      
 1554 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1555 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1556 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1557 
     | 
    
         
            +
                        type: import_v44.z.literal("file-url"),
         
     | 
| 
      
 1558 
     | 
    
         
            +
                        url: import_v44.z.string(),
         
     | 
| 
      
 1559 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1560 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1561 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1562 
     | 
    
         
            +
                        type: import_v44.z.literal("file-id"),
         
     | 
| 
      
 1563 
     | 
    
         
            +
                        fileId: import_v44.z.union([import_v44.z.string(), import_v44.z.record(import_v44.z.string(), import_v44.z.string())]),
         
     | 
| 
      
 1564 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1565 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1566 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1567 
     | 
    
         
            +
                        type: import_v44.z.literal("image-data"),
         
     | 
| 
      
 1568 
     | 
    
         
            +
                        data: import_v44.z.string(),
         
     | 
| 
      
 1569 
     | 
    
         
            +
                        mediaType: import_v44.z.string(),
         
     | 
| 
      
 1570 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1571 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1572 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1573 
     | 
    
         
            +
                        type: import_v44.z.literal("image-url"),
         
     | 
| 
      
 1574 
     | 
    
         
            +
                        url: import_v44.z.string(),
         
     | 
| 
      
 1575 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1576 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1577 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1578 
     | 
    
         
            +
                        type: import_v44.z.literal("image-file-id"),
         
     | 
| 
      
 1579 
     | 
    
         
            +
                        fileId: import_v44.z.union([import_v44.z.string(), import_v44.z.record(import_v44.z.string(), import_v44.z.string())]),
         
     | 
| 
      
 1580 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1581 
     | 
    
         
            +
                      }),
         
     | 
| 
      
 1582 
     | 
    
         
            +
                      import_v44.z.object({
         
     | 
| 
      
 1583 
     | 
    
         
            +
                        type: import_v44.z.literal("custom"),
         
     | 
| 
      
 1584 
     | 
    
         
            +
                        providerOptions: providerMetadataSchema.optional()
         
     | 
| 
      
 1585 
     | 
    
         
            +
                      })
         
     | 
| 
      
 1586 
     | 
    
         
            +
                    ])
         
     | 
| 
      
 1587 
     | 
    
         
            +
                  )
         
     | 
| 
      
 1588 
     | 
    
         
            +
                })
         
     | 
| 
      
 1589 
     | 
    
         
            +
              ]
         
     | 
| 
      
 1590 
     | 
    
         
            +
            );
         
     | 
| 
       1520 
1591 
     | 
    
         
             
            var toolResultPartSchema = import_v44.z.object({
         
     | 
| 
       1521 
1592 
     | 
    
         
             
              type: import_v44.z.literal("tool-result"),
         
     | 
| 
       1522 
1593 
     | 
    
         
             
              toolCallId: import_v44.z.string(),
         
     | 
| 
         @@ -6498,7 +6569,7 @@ var BasicAgent = class { 
     | 
|
| 
       6498 
6569 
     | 
    
         
             
               */
         
     | 
| 
       6499 
6570 
     | 
    
         
             
              respond(options) {
         
     | 
| 
       6500 
6571 
     | 
    
         
             
                return this.stream({
         
     | 
| 
       6501 
     | 
    
         
            -
                  prompt: convertToModelMessages(options.messages)
         
     | 
| 
      
 6572 
     | 
    
         
            +
                  prompt: convertToModelMessages(options.messages, { tools: this.tools })
         
     | 
| 
       6502 
6573 
     | 
    
         
             
                }).toUIMessageStreamResponse();
         
     | 
| 
       6503 
6574 
     | 
    
         
             
              }
         
     | 
| 
       6504 
6575 
     | 
    
         
             
            };
         
     |