@ai-sdk/provider 3.0.0-beta.6 → 3.0.0-beta.8

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/provider
2
2
 
3
+ ## 3.0.0-beta.8
4
+
5
+ ### Patch Changes
6
+
7
+ - 3794514: feat: flexible tool output content support
8
+
9
+ ## 3.0.0-beta.7
10
+
11
+ ### Patch Changes
12
+
13
+ - 81d4308: feat: provider-executed dynamic tools
14
+
3
15
  ## 3.0.0-beta.6
4
16
 
5
17
  ### Major Changes
package/dist/index.d.mts CHANGED
@@ -1020,11 +1020,22 @@ interface LanguageModelV3ToolResultPart {
1020
1020
  * Result of a tool call.
1021
1021
  */
1022
1022
  type LanguageModelV3ToolResultOutput = {
1023
+ /**
1024
+ * Text tool output that should be directly sent to the API.
1025
+ */
1023
1026
  type: 'text';
1024
1027
  value: string;
1028
+ /**
1029
+ * Provider-specific options.
1030
+ */
1031
+ providerOptions?: SharedV3ProviderOptions;
1025
1032
  } | {
1026
1033
  type: 'json';
1027
1034
  value: JSONValue;
1035
+ /**
1036
+ * Provider-specific options.
1037
+ */
1038
+ providerOptions?: SharedV3ProviderOptions;
1028
1039
  } | {
1029
1040
  /**
1030
1041
  * Type when the user has denied the execution of the tool call.
@@ -1034,12 +1045,24 @@ type LanguageModelV3ToolResultOutput = {
1034
1045
  * Optional reason for the execution denial.
1035
1046
  */
1036
1047
  reason?: string;
1048
+ /**
1049
+ * Provider-specific options.
1050
+ */
1051
+ providerOptions?: SharedV3ProviderOptions;
1037
1052
  } | {
1038
1053
  type: 'error-text';
1039
1054
  value: string;
1055
+ /**
1056
+ * Provider-specific options.
1057
+ */
1058
+ providerOptions?: SharedV3ProviderOptions;
1040
1059
  } | {
1041
1060
  type: 'error-json';
1042
1061
  value: JSONValue;
1062
+ /**
1063
+ * Provider-specific options.
1064
+ */
1065
+ providerOptions?: SharedV3ProviderOptions;
1043
1066
  } | {
1044
1067
  type: 'content';
1045
1068
  value: Array<{
@@ -1048,8 +1071,12 @@ type LanguageModelV3ToolResultOutput = {
1048
1071
  Text content.
1049
1072
  */
1050
1073
  text: string;
1074
+ /**
1075
+ * Provider-specific options.
1076
+ */
1077
+ providerOptions?: SharedV3ProviderOptions;
1051
1078
  } | {
1052
- type: 'media';
1079
+ type: 'file-data';
1053
1080
  /**
1054
1081
  Base-64 encoded media data.
1055
1082
  */
@@ -1059,28 +1086,120 @@ IANA media type.
1059
1086
  @see https://www.iana.org/assignments/media-types/media-types.xhtml
1060
1087
  */
1061
1088
  mediaType: string;
1089
+ /**
1090
+ * Optional filename of the file.
1091
+ */
1092
+ filename?: string;
1093
+ /**
1094
+ * Provider-specific options.
1095
+ */
1096
+ providerOptions?: SharedV3ProviderOptions;
1097
+ } | {
1098
+ type: 'file-url';
1099
+ /**
1100
+ * URL of the file.
1101
+ */
1102
+ url: string;
1103
+ /**
1104
+ * Provider-specific options.
1105
+ */
1106
+ providerOptions?: SharedV3ProviderOptions;
1107
+ } | {
1108
+ type: 'file-id';
1109
+ /**
1110
+ * ID of the file.
1111
+ *
1112
+ * If you use multiple providers, you need to
1113
+ * specify the provider specific ids using
1114
+ * the Record option. The key is the provider
1115
+ * name, e.g. 'openai' or 'anthropic'.
1116
+ */
1117
+ fileId: string | Record<string, string>;
1118
+ /**
1119
+ * Provider-specific options.
1120
+ */
1121
+ providerOptions?: SharedV3ProviderOptions;
1122
+ } | {
1123
+ /**
1124
+ * Images that are referenced using base64 encoded data.
1125
+ */
1126
+ type: 'image-data';
1127
+ /**
1128
+ Base-64 encoded image data.
1129
+ */
1130
+ data: string;
1131
+ /**
1132
+ IANA media type.
1133
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
1134
+ */
1135
+ mediaType: string;
1136
+ /**
1137
+ * Provider-specific options.
1138
+ */
1139
+ providerOptions?: SharedV3ProviderOptions;
1140
+ } | {
1141
+ /**
1142
+ * Images that are referenced using a URL.
1143
+ */
1144
+ type: 'image-url';
1145
+ /**
1146
+ * URL of the image.
1147
+ */
1148
+ url: string;
1149
+ /**
1150
+ * Provider-specific options.
1151
+ */
1152
+ providerOptions?: SharedV3ProviderOptions;
1153
+ } | {
1154
+ /**
1155
+ * Images that are referenced using a provider file id.
1156
+ */
1157
+ type: 'image-file-id';
1158
+ /**
1159
+ * Image that is referenced using a provider file id.
1160
+ *
1161
+ * If you use multiple providers, you need to
1162
+ * specify the provider specific ids using
1163
+ * the Record option. The key is the provider
1164
+ * name, e.g. 'openai' or 'anthropic'.
1165
+ */
1166
+ fileId: string | Record<string, string>;
1167
+ /**
1168
+ * Provider-specific options.
1169
+ */
1170
+ providerOptions?: SharedV3ProviderOptions;
1171
+ } | {
1172
+ /**
1173
+ * Custom content part. This can be used to implement
1174
+ * provider-specific content parts.
1175
+ */
1176
+ type: 'custom';
1177
+ /**
1178
+ * Provider-specific options.
1179
+ */
1180
+ providerOptions?: SharedV3ProviderOptions;
1062
1181
  }>;
1063
1182
  };
1064
1183
 
1065
1184
  /**
1066
- The configuration of a tool that is defined by the provider.
1185
+ * The configuration of a tool that is defined by the provider.
1067
1186
  */
1068
1187
  type LanguageModelV3ProviderDefinedTool = {
1069
1188
  /**
1070
- The type of the tool (always 'provider-defined').
1189
+ * The type of the tool (always 'provider-defined').
1071
1190
  */
1072
1191
  type: 'provider-defined';
1073
1192
  /**
1074
- The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
1193
+ * The ID of the tool. Should follow the format `<provider-id>.<unique-tool-name>`.
1075
1194
  */
1076
1195
  id: `${string}.${string}`;
1077
1196
  /**
1078
- The name of the tool that the user must use in the tool set.
1197
+ * The name of the tool that the user must use in the tool set.
1079
1198
  */
1080
1199
  name: string;
1081
1200
  /**
1082
- The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1083
- */
1201
+ * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1202
+ */
1084
1203
  args: Record<string, unknown>;
1085
1204
  };
1086
1205
 
@@ -1337,6 +1456,11 @@ type LanguageModelV3ToolCall = {
1337
1456
  * If this flag is not set or is false, the tool call will be executed by the client.
1338
1457
  */
1339
1458
  providerExecuted?: boolean;
1459
+ /**
1460
+ * Whether the tool is dynamic, i.e. defined at runtime.
1461
+ * For example, MCP (Model Context Protocol) tools that are executed by the provider.
1462
+ */
1463
+ dynamic?: boolean;
1340
1464
  /**
1341
1465
  * Additional provider-specific metadata for the tool call.
1342
1466
  */
@@ -1381,6 +1505,11 @@ type LanguageModelV3ToolResult = {
1381
1505
  * If this flag is not set or is false, the tool result is not preliminary.
1382
1506
  */
1383
1507
  preliminary?: boolean;
1508
+ /**
1509
+ * Whether the tool is dynamic, i.e. defined at runtime.
1510
+ * For example, MCP (Model Context Protocol) tools that are executed by the provider.
1511
+ */
1512
+ dynamic?: boolean;
1384
1513
  /**
1385
1514
  * Additional provider-specific metadata for the tool result.
1386
1515
  */
@@ -1481,6 +1610,7 @@ type LanguageModelV3StreamPart = {
1481
1610
  toolName: string;
1482
1611
  providerMetadata?: SharedV3ProviderMetadata;
1483
1612
  providerExecuted?: boolean;
1613
+ dynamic?: boolean;
1484
1614
  } | {
1485
1615
  type: 'tool-input-delta';
1486
1616
  id: string;
@@ -1517,11 +1647,11 @@ type LanguageModelV3 = {
1517
1647
  */
1518
1648
  readonly specificationVersion: 'v3';
1519
1649
  /**
1520
- Name of the provider for logging purposes.
1650
+ Provider ID.
1521
1651
  */
1522
1652
  readonly provider: string;
1523
1653
  /**
1524
- Provider-specific model ID for logging purposes.
1654
+ Provider-specific model ID.
1525
1655
  */
1526
1656
  readonly modelId: string;
1527
1657
  /**
package/dist/index.d.ts CHANGED
@@ -1020,11 +1020,22 @@ interface LanguageModelV3ToolResultPart {
1020
1020
  * Result of a tool call.
1021
1021
  */
1022
1022
  type LanguageModelV3ToolResultOutput = {
1023
+ /**
1024
+ * Text tool output that should be directly sent to the API.
1025
+ */
1023
1026
  type: 'text';
1024
1027
  value: string;
1028
+ /**
1029
+ * Provider-specific options.
1030
+ */
1031
+ providerOptions?: SharedV3ProviderOptions;
1025
1032
  } | {
1026
1033
  type: 'json';
1027
1034
  value: JSONValue;
1035
+ /**
1036
+ * Provider-specific options.
1037
+ */
1038
+ providerOptions?: SharedV3ProviderOptions;
1028
1039
  } | {
1029
1040
  /**
1030
1041
  * Type when the user has denied the execution of the tool call.
@@ -1034,12 +1045,24 @@ type LanguageModelV3ToolResultOutput = {
1034
1045
  * Optional reason for the execution denial.
1035
1046
  */
1036
1047
  reason?: string;
1048
+ /**
1049
+ * Provider-specific options.
1050
+ */
1051
+ providerOptions?: SharedV3ProviderOptions;
1037
1052
  } | {
1038
1053
  type: 'error-text';
1039
1054
  value: string;
1055
+ /**
1056
+ * Provider-specific options.
1057
+ */
1058
+ providerOptions?: SharedV3ProviderOptions;
1040
1059
  } | {
1041
1060
  type: 'error-json';
1042
1061
  value: JSONValue;
1062
+ /**
1063
+ * Provider-specific options.
1064
+ */
1065
+ providerOptions?: SharedV3ProviderOptions;
1043
1066
  } | {
1044
1067
  type: 'content';
1045
1068
  value: Array<{
@@ -1048,8 +1071,12 @@ type LanguageModelV3ToolResultOutput = {
1048
1071
  Text content.
1049
1072
  */
1050
1073
  text: string;
1074
+ /**
1075
+ * Provider-specific options.
1076
+ */
1077
+ providerOptions?: SharedV3ProviderOptions;
1051
1078
  } | {
1052
- type: 'media';
1079
+ type: 'file-data';
1053
1080
  /**
1054
1081
  Base-64 encoded media data.
1055
1082
  */
@@ -1059,28 +1086,120 @@ IANA media type.
1059
1086
  @see https://www.iana.org/assignments/media-types/media-types.xhtml
1060
1087
  */
1061
1088
  mediaType: string;
1089
+ /**
1090
+ * Optional filename of the file.
1091
+ */
1092
+ filename?: string;
1093
+ /**
1094
+ * Provider-specific options.
1095
+ */
1096
+ providerOptions?: SharedV3ProviderOptions;
1097
+ } | {
1098
+ type: 'file-url';
1099
+ /**
1100
+ * URL of the file.
1101
+ */
1102
+ url: string;
1103
+ /**
1104
+ * Provider-specific options.
1105
+ */
1106
+ providerOptions?: SharedV3ProviderOptions;
1107
+ } | {
1108
+ type: 'file-id';
1109
+ /**
1110
+ * ID of the file.
1111
+ *
1112
+ * If you use multiple providers, you need to
1113
+ * specify the provider specific ids using
1114
+ * the Record option. The key is the provider
1115
+ * name, e.g. 'openai' or 'anthropic'.
1116
+ */
1117
+ fileId: string | Record<string, string>;
1118
+ /**
1119
+ * Provider-specific options.
1120
+ */
1121
+ providerOptions?: SharedV3ProviderOptions;
1122
+ } | {
1123
+ /**
1124
+ * Images that are referenced using base64 encoded data.
1125
+ */
1126
+ type: 'image-data';
1127
+ /**
1128
+ Base-64 encoded image data.
1129
+ */
1130
+ data: string;
1131
+ /**
1132
+ IANA media type.
1133
+ @see https://www.iana.org/assignments/media-types/media-types.xhtml
1134
+ */
1135
+ mediaType: string;
1136
+ /**
1137
+ * Provider-specific options.
1138
+ */
1139
+ providerOptions?: SharedV3ProviderOptions;
1140
+ } | {
1141
+ /**
1142
+ * Images that are referenced using a URL.
1143
+ */
1144
+ type: 'image-url';
1145
+ /**
1146
+ * URL of the image.
1147
+ */
1148
+ url: string;
1149
+ /**
1150
+ * Provider-specific options.
1151
+ */
1152
+ providerOptions?: SharedV3ProviderOptions;
1153
+ } | {
1154
+ /**
1155
+ * Images that are referenced using a provider file id.
1156
+ */
1157
+ type: 'image-file-id';
1158
+ /**
1159
+ * Image that is referenced using a provider file id.
1160
+ *
1161
+ * If you use multiple providers, you need to
1162
+ * specify the provider specific ids using
1163
+ * the Record option. The key is the provider
1164
+ * name, e.g. 'openai' or 'anthropic'.
1165
+ */
1166
+ fileId: string | Record<string, string>;
1167
+ /**
1168
+ * Provider-specific options.
1169
+ */
1170
+ providerOptions?: SharedV3ProviderOptions;
1171
+ } | {
1172
+ /**
1173
+ * Custom content part. This can be used to implement
1174
+ * provider-specific content parts.
1175
+ */
1176
+ type: 'custom';
1177
+ /**
1178
+ * Provider-specific options.
1179
+ */
1180
+ providerOptions?: SharedV3ProviderOptions;
1062
1181
  }>;
1063
1182
  };
1064
1183
 
1065
1184
  /**
1066
- The configuration of a tool that is defined by the provider.
1185
+ * The configuration of a tool that is defined by the provider.
1067
1186
  */
1068
1187
  type LanguageModelV3ProviderDefinedTool = {
1069
1188
  /**
1070
- The type of the tool (always 'provider-defined').
1189
+ * The type of the tool (always 'provider-defined').
1071
1190
  */
1072
1191
  type: 'provider-defined';
1073
1192
  /**
1074
- The ID of the tool. Should follow the format `<provider-name>.<unique-tool-name>`.
1193
+ * The ID of the tool. Should follow the format `<provider-id>.<unique-tool-name>`.
1075
1194
  */
1076
1195
  id: `${string}.${string}`;
1077
1196
  /**
1078
- The name of the tool that the user must use in the tool set.
1197
+ * The name of the tool that the user must use in the tool set.
1079
1198
  */
1080
1199
  name: string;
1081
1200
  /**
1082
- The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1083
- */
1201
+ * The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.
1202
+ */
1084
1203
  args: Record<string, unknown>;
1085
1204
  };
1086
1205
 
@@ -1337,6 +1456,11 @@ type LanguageModelV3ToolCall = {
1337
1456
  * If this flag is not set or is false, the tool call will be executed by the client.
1338
1457
  */
1339
1458
  providerExecuted?: boolean;
1459
+ /**
1460
+ * Whether the tool is dynamic, i.e. defined at runtime.
1461
+ * For example, MCP (Model Context Protocol) tools that are executed by the provider.
1462
+ */
1463
+ dynamic?: boolean;
1340
1464
  /**
1341
1465
  * Additional provider-specific metadata for the tool call.
1342
1466
  */
@@ -1381,6 +1505,11 @@ type LanguageModelV3ToolResult = {
1381
1505
  * If this flag is not set or is false, the tool result is not preliminary.
1382
1506
  */
1383
1507
  preliminary?: boolean;
1508
+ /**
1509
+ * Whether the tool is dynamic, i.e. defined at runtime.
1510
+ * For example, MCP (Model Context Protocol) tools that are executed by the provider.
1511
+ */
1512
+ dynamic?: boolean;
1384
1513
  /**
1385
1514
  * Additional provider-specific metadata for the tool result.
1386
1515
  */
@@ -1481,6 +1610,7 @@ type LanguageModelV3StreamPart = {
1481
1610
  toolName: string;
1482
1611
  providerMetadata?: SharedV3ProviderMetadata;
1483
1612
  providerExecuted?: boolean;
1613
+ dynamic?: boolean;
1484
1614
  } | {
1485
1615
  type: 'tool-input-delta';
1486
1616
  id: string;
@@ -1517,11 +1647,11 @@ type LanguageModelV3 = {
1517
1647
  */
1518
1648
  readonly specificationVersion: 'v3';
1519
1649
  /**
1520
- Name of the provider for logging purposes.
1650
+ Provider ID.
1521
1651
  */
1522
1652
  readonly provider: string;
1523
1653
  /**
1524
- Provider-specific model ID for logging purposes.
1654
+ Provider-specific model ID.
1525
1655
  */
1526
1656
  readonly modelId: string;
1527
1657
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider",
3
- "version": "3.0.0-beta.6",
3
+ "version": "3.0.0-beta.8",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",