ai 7.0.0-beta.113 → 7.0.0-beta.115
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 +32 -0
- package/dist/index.d.ts +1506 -1468
- package/dist/index.js +889 -979
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +273 -273
- package/dist/internal/index.js +367 -405
- package/dist/internal/index.js.map +1 -1
- package/dist/test/index.d.ts +18 -18
- package/dist/test/index.js +22 -22
- package/dist/test/index.js.map +1 -1
- package/docs/02-foundations/03-prompts.mdx +13 -11
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +2 -1
- package/docs/03-ai-sdk-core/39-file-uploads.mdx +1 -1
- package/docs/03-ai-sdk-core/45-provider-management.mdx +1 -1
- package/docs/03-ai-sdk-core/60-telemetry.mdx +87 -13
- package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +2 -2
- package/docs/07-reference/01-ai-sdk-core/20-tool.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +7 -0
- package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +9 -1
- package/docs/07-reference/01-ai-sdk-core/40-provider-registry.mdx +104 -0
- package/docs/07-reference/01-ai-sdk-core/42-custom-provider.mdx +56 -10
- package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +1 -1
- package/docs/08-migration-guides/23-migration-guide-7-0.mdx +42 -0
- package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +2 -2
- package/package.json +5 -5
- package/src/agent/agent.ts +13 -9
- package/src/agent/create-agent-ui-stream-response.ts +8 -8
- package/src/agent/create-agent-ui-stream.ts +9 -9
- package/src/agent/infer-agent-tools.ts +1 -1
- package/src/agent/infer-agent-ui-message.ts +2 -2
- package/src/agent/pipe-agent-ui-stream-to-response.ts +9 -9
- package/src/agent/tool-loop-agent-settings.ts +17 -19
- package/src/agent/tool-loop-agent.ts +16 -8
- package/src/embed/embed-many-result.ts +3 -4
- package/src/embed/embed-many.ts +5 -5
- package/src/embed/embed-result.ts +3 -4
- package/src/embed/embed.ts +4 -4
- package/src/error/invalid-stream-part-error.ts +1 -1
- package/src/error/no-image-generated-error.ts +1 -1
- package/src/error/no-object-generated-error.ts +3 -3
- package/src/error/no-speech-generated-error.ts +1 -1
- package/src/error/no-transcript-generated-error.ts +1 -1
- package/src/error/no-video-generated-error.ts +1 -1
- package/src/error/tool-call-repair-error.ts +2 -2
- package/src/error/verify-no-object-generated-error.ts +1 -1
- package/src/generate-image/generate-image-result.ts +5 -5
- package/src/generate-image/generate-image.ts +12 -15
- package/src/generate-image/index.ts +3 -2
- package/src/generate-object/generate-object-result.ts +2 -2
- package/src/generate-object/generate-object.ts +14 -14
- package/src/generate-object/inject-json-instruction.ts +1 -1
- package/src/generate-object/output-strategy.ts +10 -10
- package/src/generate-object/parse-and-validate-object-result.ts +1 -1
- package/src/generate-object/repair-text.ts +1 -1
- package/src/generate-object/stream-object-result.ts +4 -4
- package/src/generate-object/stream-object.ts +22 -19
- package/src/generate-object/validate-object-generation-input.ts +1 -1
- package/src/generate-speech/generate-speech-result.ts +4 -4
- package/src/generate-speech/generate-speech.ts +12 -13
- package/src/generate-speech/generated-audio-file.ts +1 -2
- package/src/generate-text/collect-tool-approvals.ts +4 -4
- package/src/generate-text/content-part.ts +9 -9
- package/src/generate-text/create-execute-tools-transformation.ts +9 -7
- package/src/generate-text/execute-tool-call.ts +11 -13
- package/src/generate-text/extract-reasoning-content.ts +1 -1
- package/src/generate-text/extract-text-content.ts +4 -1
- package/src/generate-text/generate-text-events.ts +2 -2
- package/src/generate-text/generate-text-result.ts +18 -14
- package/src/generate-text/generate-text.ts +42 -38
- package/src/generate-text/invoke-tool-callbacks-from-stream.ts +2 -3
- package/src/generate-text/output-utils.ts +1 -1
- package/src/generate-text/output.ts +8 -8
- package/src/generate-text/parse-tool-call.ts +36 -9
- package/src/generate-text/prepare-step.ts +3 -5
- package/src/generate-text/prune-messages.ts +1 -1
- package/src/generate-text/reasoning-output.ts +26 -9
- package/src/generate-text/reasoning.ts +1 -1
- package/src/generate-text/resolve-tool-approval.ts +3 -3
- package/src/generate-text/response-message.ts +1 -1
- package/src/generate-text/restricted-telemetry-dispatcher.ts +1 -1
- package/src/generate-text/smooth-stream.ts +6 -5
- package/src/generate-text/step-result.ts +16 -11
- package/src/generate-text/stop-condition.ts +1 -1
- package/src/generate-text/stream-language-model-call.ts +26 -21
- package/src/generate-text/stream-text-result.ts +29 -26
- package/src/generate-text/stream-text.ts +48 -46
- package/src/generate-text/to-response-messages.ts +2 -2
- package/src/generate-text/tool-approval-configuration.ts +2 -2
- package/src/generate-text/tool-approval-request-output.ts +1 -1
- package/src/generate-text/tool-approval-response-output.ts +1 -1
- package/src/generate-text/tool-call-repair-function.ts +4 -4
- package/src/generate-text/tool-call.ts +3 -4
- package/src/generate-text/tool-error.ts +3 -4
- package/src/generate-text/tool-execution-events.ts +2 -2
- package/src/generate-text/tool-output-denied.ts +1 -1
- package/src/generate-text/tool-output.ts +2 -2
- package/src/generate-text/tool-result.ts +7 -4
- package/src/generate-text/tools-context-parameter.ts +1 -1
- package/src/generate-text/validate-tool-context.ts +1 -2
- package/src/generate-video/generate-video-result.ts +4 -4
- package/src/generate-video/generate-video.ts +6 -10
- package/src/global.ts +2 -2
- package/src/index.ts +3 -3
- package/src/logger/log-warnings.ts +1 -1
- package/src/middleware/add-tool-input-examples-middleware.ts +2 -2
- package/src/middleware/default-embedding-settings-middleware.ts +2 -2
- package/src/middleware/default-settings-middleware.ts +2 -2
- package/src/middleware/extract-json-middleware.ts +1 -1
- package/src/middleware/extract-reasoning-middleware.ts +1 -1
- package/src/middleware/simulate-streaming-middleware.ts +1 -1
- package/src/middleware/wrap-embedding-model.ts +2 -2
- package/src/middleware/wrap-image-model.ts +2 -2
- package/src/middleware/wrap-language-model.ts +2 -2
- package/src/middleware/wrap-provider.ts +2 -2
- package/src/model/as-embedding-model-v3.ts +1 -1
- package/src/model/as-embedding-model-v4.ts +1 -1
- package/src/model/as-image-model-v3.ts +1 -1
- package/src/model/as-image-model-v4.ts +5 -1
- package/src/model/as-language-model-v3.ts +1 -1
- package/src/model/as-language-model-v4.ts +1 -1
- package/src/model/as-provider-v3.ts +1 -1
- package/src/model/as-provider-v4.ts +1 -1
- package/src/model/as-reranking-model-v4.ts +1 -1
- package/src/model/as-speech-model-v3.ts +1 -1
- package/src/model/as-speech-model-v4.ts +5 -1
- package/src/model/as-transcription-model-v3.ts +4 -1
- package/src/model/as-transcription-model-v4.ts +1 -1
- package/src/model/as-video-model-v4.ts +1 -1
- package/src/model/resolve-model.ts +8 -8
- package/src/prompt/content-part.ts +45 -15
- package/src/prompt/convert-to-language-model-prompt.ts +108 -122
- package/src/prompt/create-tool-model-output.ts +2 -2
- package/src/prompt/data-content.ts +1 -78
- package/src/prompt/file-part-data.ts +125 -0
- package/src/prompt/index.ts +3 -2
- package/src/prompt/language-model-call-options.ts +1 -1
- package/src/prompt/message-conversion-error.ts +1 -1
- package/src/prompt/message.ts +1 -1
- package/src/prompt/prepare-language-model-call-options.ts +1 -1
- package/src/prompt/prepare-tool-choice.ts +2 -2
- package/src/prompt/prepare-tools.ts +2 -2
- package/src/prompt/prompt.ts +1 -1
- package/src/prompt/standardize-prompt.ts +3 -3
- package/src/registry/custom-provider.ts +127 -92
- package/src/registry/index.ts +1 -1
- package/src/registry/provider-registry.ts +91 -87
- package/src/rerank/rerank-result.ts +1 -1
- package/src/rerank/rerank.ts +8 -5
- package/src/telemetry/create-telemetry-dispatcher.ts +11 -1
- package/src/telemetry/diagnostic-channel-publisher.ts +50 -0
- package/src/telemetry/diagnostic-channel.ts +24 -0
- package/src/telemetry/index.ts +5 -0
- package/src/telemetry/telemetry.ts +1 -1
- package/src/test/mock-embedding-model-v2.ts +1 -1
- package/src/test/mock-embedding-model-v3.ts +1 -1
- package/src/test/mock-embedding-model-v4.ts +1 -1
- package/src/test/mock-image-model-v2.ts +1 -1
- package/src/test/mock-image-model-v3.ts +1 -1
- package/src/test/mock-image-model-v4.ts +1 -1
- package/src/test/mock-language-model-v2.ts +1 -1
- package/src/test/mock-language-model-v3.ts +1 -1
- package/src/test/mock-language-model-v4.ts +1 -1
- package/src/test/mock-provider-v2.ts +6 -7
- package/src/test/mock-provider-v3.ts +7 -8
- package/src/test/mock-provider-v4.ts +7 -8
- package/src/test/mock-reranking-model-v3.ts +1 -1
- package/src/test/mock-reranking-model-v4.ts +1 -1
- package/src/test/mock-server-response.ts +1 -1
- package/src/test/mock-speech-model-v2.ts +1 -1
- package/src/test/mock-speech-model-v3.ts +1 -1
- package/src/test/mock-speech-model-v4.ts +1 -1
- package/src/test/mock-transcription-model-v2.ts +1 -1
- package/src/test/mock-transcription-model-v3.ts +1 -1
- package/src/test/mock-transcription-model-v4.ts +1 -1
- package/src/test/mock-video-model-v3.ts +1 -1
- package/src/test/mock-video-model-v4.ts +1 -1
- package/src/text-stream/pipe-text-stream-to-response.ts +1 -1
- package/src/transcribe/transcribe-result.ts +3 -3
- package/src/transcribe/transcribe.ts +12 -12
- package/src/types/embedding-model-middleware.ts +1 -1
- package/src/types/embedding-model.ts +1 -1
- package/src/types/image-model-middleware.ts +1 -1
- package/src/types/image-model.ts +1 -1
- package/src/types/json-value.ts +1 -1
- package/src/types/language-model-middleware.ts +1 -1
- package/src/types/language-model.ts +2 -2
- package/src/types/provider-metadata.ts +1 -1
- package/src/types/provider-reference.ts +1 -1
- package/src/types/provider.ts +4 -4
- package/src/types/reranking-model.ts +1 -1
- package/src/types/speech-model.ts +5 -1
- package/src/types/transcription-model.ts +1 -1
- package/src/types/usage.ts +1 -1
- package/src/types/video-model.ts +1 -1
- package/src/types/warning.ts +1 -1
- package/src/ui/call-completion-api.ts +2 -2
- package/src/ui/chat-transport.ts +3 -3
- package/src/ui/chat.ts +10 -11
- package/src/ui/convert-file-list-to-file-ui-parts.ts +1 -1
- package/src/ui/convert-to-model-messages.ts +34 -23
- package/src/ui/default-chat-transport.ts +4 -4
- package/src/ui/direct-chat-transport.ts +6 -6
- package/src/ui/http-chat-transport.ts +5 -5
- package/src/ui/last-assistant-message-is-complete-with-approval-responses.ts +0 -1
- package/src/ui/last-assistant-message-is-complete-with-tool-calls.ts +0 -1
- package/src/ui/process-ui-message-stream.ts +20 -21
- package/src/ui/text-stream-chat-transport.ts +3 -3
- package/src/ui/transform-text-to-ui-message-stream.ts +1 -1
- package/src/ui/ui-messages.ts +13 -6
- package/src/ui/use-completion.ts +1 -1
- package/src/ui/validate-ui-messages.ts +3 -3
- package/src/ui-message-stream/create-ui-message-stream-response.ts +2 -2
- package/src/ui-message-stream/create-ui-message-stream.ts +6 -6
- package/src/ui-message-stream/get-response-ui-message-id.ts +2 -2
- package/src/ui-message-stream/handle-ui-message-stream-finish.ts +6 -6
- package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +3 -3
- package/src/ui-message-stream/read-ui-message-stream.ts +4 -4
- package/src/ui-message-stream/ui-message-chunks.ts +4 -4
- package/src/ui-message-stream/ui-message-stream-on-finish-callback.ts +2 -2
- package/src/ui-message-stream/ui-message-stream-on-step-finish-callback.ts +1 -1
- package/src/ui-message-stream/ui-message-stream-writer.ts +3 -3
- package/src/upload-file/upload-file-result.ts +3 -3
- package/src/upload-file/upload-file.ts +34 -56
- package/src/upload-skill/upload-skill-result.ts +3 -3
- package/src/upload-skill/upload-skill.ts +27 -8
- package/src/util/create-resolvable-promise.ts +1 -1
- package/src/util/deep-partial.ts +1 -1
- package/src/util/download/download.ts +0 -2
- package/src/util/extract-literal-union.ts +18 -0
- package/src/util/is-node-runtime.ts +3 -0
- package/src/util/notify.ts +1 -1
- package/src/util/parse-partial-json.ts +1 -1
- package/src/util/prepare-retries.ts +1 -2
- package/src/util/serial-job-executor.ts +1 -1
- package/src/util/write-to-server-response.ts +1 -1
- package/src/util/detect-media-type.ts +0 -235
package/dist/index.js
CHANGED
|
@@ -18,7 +18,9 @@ import {
|
|
|
18
18
|
} from "@ai-sdk/provider-utils";
|
|
19
19
|
|
|
20
20
|
// src/agent/tool-loop-agent.ts
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
validateTypes as validateTypes3
|
|
23
|
+
} from "@ai-sdk/provider-utils";
|
|
22
24
|
|
|
23
25
|
// src/generate-text/generate-text.ts
|
|
24
26
|
import {
|
|
@@ -1015,258 +1017,23 @@ function getGlobalProvider() {
|
|
|
1015
1017
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
1016
1018
|
import {
|
|
1017
1019
|
asArray,
|
|
1018
|
-
|
|
1020
|
+
detectMediaType,
|
|
1021
|
+
isFullMediaType,
|
|
1019
1022
|
isUrlSupported
|
|
1020
1023
|
} from "@ai-sdk/provider-utils";
|
|
1021
1024
|
|
|
1022
|
-
// src/util/detect-media-type.ts
|
|
1023
|
-
import { convertBase64ToUint8Array } from "@ai-sdk/provider-utils";
|
|
1024
|
-
var imageMediaTypeSignatures = [
|
|
1025
|
-
{
|
|
1026
|
-
mediaType: "image/gif",
|
|
1027
|
-
bytesPrefix: [71, 73, 70]
|
|
1028
|
-
// GIF
|
|
1029
|
-
},
|
|
1030
|
-
{
|
|
1031
|
-
mediaType: "image/png",
|
|
1032
|
-
bytesPrefix: [137, 80, 78, 71]
|
|
1033
|
-
// PNG
|
|
1034
|
-
},
|
|
1035
|
-
{
|
|
1036
|
-
mediaType: "image/jpeg",
|
|
1037
|
-
bytesPrefix: [255, 216]
|
|
1038
|
-
// JPEG
|
|
1039
|
-
},
|
|
1040
|
-
{
|
|
1041
|
-
mediaType: "image/webp",
|
|
1042
|
-
bytesPrefix: [
|
|
1043
|
-
82,
|
|
1044
|
-
73,
|
|
1045
|
-
70,
|
|
1046
|
-
70,
|
|
1047
|
-
// "RIFF"
|
|
1048
|
-
null,
|
|
1049
|
-
null,
|
|
1050
|
-
null,
|
|
1051
|
-
null,
|
|
1052
|
-
// file size (variable)
|
|
1053
|
-
87,
|
|
1054
|
-
69,
|
|
1055
|
-
66,
|
|
1056
|
-
80
|
|
1057
|
-
// "WEBP"
|
|
1058
|
-
]
|
|
1059
|
-
},
|
|
1060
|
-
{
|
|
1061
|
-
mediaType: "image/bmp",
|
|
1062
|
-
bytesPrefix: [66, 77]
|
|
1063
|
-
},
|
|
1064
|
-
{
|
|
1065
|
-
mediaType: "image/tiff",
|
|
1066
|
-
bytesPrefix: [73, 73, 42, 0]
|
|
1067
|
-
},
|
|
1068
|
-
{
|
|
1069
|
-
mediaType: "image/tiff",
|
|
1070
|
-
bytesPrefix: [77, 77, 0, 42]
|
|
1071
|
-
},
|
|
1072
|
-
{
|
|
1073
|
-
mediaType: "image/avif",
|
|
1074
|
-
bytesPrefix: [
|
|
1075
|
-
0,
|
|
1076
|
-
0,
|
|
1077
|
-
0,
|
|
1078
|
-
32,
|
|
1079
|
-
102,
|
|
1080
|
-
116,
|
|
1081
|
-
121,
|
|
1082
|
-
112,
|
|
1083
|
-
97,
|
|
1084
|
-
118,
|
|
1085
|
-
105,
|
|
1086
|
-
102
|
|
1087
|
-
]
|
|
1088
|
-
},
|
|
1089
|
-
{
|
|
1090
|
-
mediaType: "image/heic",
|
|
1091
|
-
bytesPrefix: [
|
|
1092
|
-
0,
|
|
1093
|
-
0,
|
|
1094
|
-
0,
|
|
1095
|
-
32,
|
|
1096
|
-
102,
|
|
1097
|
-
116,
|
|
1098
|
-
121,
|
|
1099
|
-
112,
|
|
1100
|
-
104,
|
|
1101
|
-
101,
|
|
1102
|
-
105,
|
|
1103
|
-
99
|
|
1104
|
-
]
|
|
1105
|
-
}
|
|
1106
|
-
];
|
|
1107
|
-
var documentMediaTypeSignatures = [
|
|
1108
|
-
{
|
|
1109
|
-
mediaType: "application/pdf",
|
|
1110
|
-
bytesPrefix: [37, 80, 68, 70]
|
|
1111
|
-
// %PDF
|
|
1112
|
-
}
|
|
1113
|
-
];
|
|
1114
|
-
var audioMediaTypeSignatures = [
|
|
1115
|
-
{
|
|
1116
|
-
mediaType: "audio/mpeg",
|
|
1117
|
-
bytesPrefix: [255, 251]
|
|
1118
|
-
},
|
|
1119
|
-
{
|
|
1120
|
-
mediaType: "audio/mpeg",
|
|
1121
|
-
bytesPrefix: [255, 250]
|
|
1122
|
-
},
|
|
1123
|
-
{
|
|
1124
|
-
mediaType: "audio/mpeg",
|
|
1125
|
-
bytesPrefix: [255, 243]
|
|
1126
|
-
},
|
|
1127
|
-
{
|
|
1128
|
-
mediaType: "audio/mpeg",
|
|
1129
|
-
bytesPrefix: [255, 242]
|
|
1130
|
-
},
|
|
1131
|
-
{
|
|
1132
|
-
mediaType: "audio/mpeg",
|
|
1133
|
-
bytesPrefix: [255, 227]
|
|
1134
|
-
},
|
|
1135
|
-
{
|
|
1136
|
-
mediaType: "audio/mpeg",
|
|
1137
|
-
bytesPrefix: [255, 226]
|
|
1138
|
-
},
|
|
1139
|
-
{
|
|
1140
|
-
mediaType: "audio/wav",
|
|
1141
|
-
bytesPrefix: [
|
|
1142
|
-
82,
|
|
1143
|
-
// R
|
|
1144
|
-
73,
|
|
1145
|
-
// I
|
|
1146
|
-
70,
|
|
1147
|
-
// F
|
|
1148
|
-
70,
|
|
1149
|
-
// F
|
|
1150
|
-
null,
|
|
1151
|
-
null,
|
|
1152
|
-
null,
|
|
1153
|
-
null,
|
|
1154
|
-
87,
|
|
1155
|
-
// W
|
|
1156
|
-
65,
|
|
1157
|
-
// A
|
|
1158
|
-
86,
|
|
1159
|
-
// V
|
|
1160
|
-
69
|
|
1161
|
-
// E
|
|
1162
|
-
]
|
|
1163
|
-
},
|
|
1164
|
-
{
|
|
1165
|
-
mediaType: "audio/ogg",
|
|
1166
|
-
bytesPrefix: [79, 103, 103, 83]
|
|
1167
|
-
},
|
|
1168
|
-
{
|
|
1169
|
-
mediaType: "audio/flac",
|
|
1170
|
-
bytesPrefix: [102, 76, 97, 67]
|
|
1171
|
-
},
|
|
1172
|
-
{
|
|
1173
|
-
mediaType: "audio/aac",
|
|
1174
|
-
bytesPrefix: [64, 21, 0, 0]
|
|
1175
|
-
},
|
|
1176
|
-
{
|
|
1177
|
-
mediaType: "audio/mp4",
|
|
1178
|
-
bytesPrefix: [102, 116, 121, 112]
|
|
1179
|
-
},
|
|
1180
|
-
{
|
|
1181
|
-
mediaType: "audio/webm",
|
|
1182
|
-
bytesPrefix: [26, 69, 223, 163]
|
|
1183
|
-
}
|
|
1184
|
-
];
|
|
1185
|
-
var videoMediaTypeSignatures = [
|
|
1186
|
-
{
|
|
1187
|
-
mediaType: "video/mp4",
|
|
1188
|
-
bytesPrefix: [
|
|
1189
|
-
0,
|
|
1190
|
-
0,
|
|
1191
|
-
0,
|
|
1192
|
-
null,
|
|
1193
|
-
102,
|
|
1194
|
-
116,
|
|
1195
|
-
121,
|
|
1196
|
-
112
|
|
1197
|
-
// ftyp
|
|
1198
|
-
]
|
|
1199
|
-
},
|
|
1200
|
-
{
|
|
1201
|
-
mediaType: "video/webm",
|
|
1202
|
-
bytesPrefix: [26, 69, 223, 163]
|
|
1203
|
-
// EBML
|
|
1204
|
-
},
|
|
1205
|
-
{
|
|
1206
|
-
mediaType: "video/quicktime",
|
|
1207
|
-
bytesPrefix: [
|
|
1208
|
-
0,
|
|
1209
|
-
0,
|
|
1210
|
-
0,
|
|
1211
|
-
20,
|
|
1212
|
-
102,
|
|
1213
|
-
116,
|
|
1214
|
-
121,
|
|
1215
|
-
112,
|
|
1216
|
-
113,
|
|
1217
|
-
116
|
|
1218
|
-
// ftypqt
|
|
1219
|
-
]
|
|
1220
|
-
},
|
|
1221
|
-
{
|
|
1222
|
-
mediaType: "video/x-msvideo",
|
|
1223
|
-
bytesPrefix: [82, 73, 70, 70]
|
|
1224
|
-
// RIFF (AVI)
|
|
1225
|
-
}
|
|
1226
|
-
];
|
|
1227
|
-
var stripID3 = (data) => {
|
|
1228
|
-
const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
|
|
1229
|
-
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
1230
|
-
return bytes.slice(id3Size + 10);
|
|
1231
|
-
};
|
|
1232
|
-
function stripID3TagsIfPresent(data) {
|
|
1233
|
-
const hasId3 = typeof data === "string" && data.startsWith("SUQz") || typeof data !== "string" && data.length > 10 && data[0] === 73 && // 'I'
|
|
1234
|
-
data[1] === 68 && // 'D'
|
|
1235
|
-
data[2] === 51;
|
|
1236
|
-
return hasId3 ? stripID3(data) : data;
|
|
1237
|
-
}
|
|
1238
|
-
function detectMediaType({
|
|
1239
|
-
data,
|
|
1240
|
-
signatures
|
|
1241
|
-
}) {
|
|
1242
|
-
const processedData = stripID3TagsIfPresent(data);
|
|
1243
|
-
const bytes = typeof processedData === "string" ? convertBase64ToUint8Array(
|
|
1244
|
-
processedData.substring(0, Math.min(processedData.length, 24))
|
|
1245
|
-
) : processedData;
|
|
1246
|
-
for (const signature of signatures) {
|
|
1247
|
-
if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every(
|
|
1248
|
-
(byte, index) => byte === null || bytes[index] === byte
|
|
1249
|
-
)) {
|
|
1250
|
-
return signature.mediaType;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
|
-
return void 0;
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
1025
|
// src/util/download/download.ts
|
|
1257
1026
|
import {
|
|
1258
1027
|
DownloadError as DownloadError2,
|
|
1259
1028
|
readResponseWithSizeLimit,
|
|
1260
1029
|
DEFAULT_MAX_DOWNLOAD_SIZE,
|
|
1261
|
-
validateDownloadUrl
|
|
1262
|
-
} from "@ai-sdk/provider-utils";
|
|
1263
|
-
import {
|
|
1030
|
+
validateDownloadUrl,
|
|
1264
1031
|
withUserAgentSuffix,
|
|
1265
1032
|
getRuntimeEnvironmentUserAgent
|
|
1266
1033
|
} from "@ai-sdk/provider-utils";
|
|
1267
1034
|
|
|
1268
1035
|
// src/version.ts
|
|
1269
|
-
var VERSION = true ? "7.0.0-beta.
|
|
1036
|
+
var VERSION = true ? "7.0.0-beta.115" : "0.0.0-test";
|
|
1270
1037
|
|
|
1271
1038
|
// src/util/download/download.ts
|
|
1272
1039
|
var download = async ({
|
|
@@ -1320,13 +1087,11 @@ var createDefaultDownloadFunction = (download2 = download) => (requestedDownload
|
|
|
1320
1087
|
)
|
|
1321
1088
|
);
|
|
1322
1089
|
|
|
1323
|
-
// src/prompt/data
|
|
1324
|
-
import { AISDKError as AISDKError22 } from "@ai-sdk/provider";
|
|
1090
|
+
// src/prompt/file-part-data.ts
|
|
1325
1091
|
import {
|
|
1326
|
-
|
|
1327
|
-
|
|
1092
|
+
isBuffer,
|
|
1093
|
+
isProviderReference
|
|
1328
1094
|
} from "@ai-sdk/provider-utils";
|
|
1329
|
-
import { z } from "zod/v4";
|
|
1330
1095
|
|
|
1331
1096
|
// src/prompt/split-data-url.ts
|
|
1332
1097
|
function splitDataUrl(dataUrl) {
|
|
@@ -1344,75 +1109,89 @@ function splitDataUrl(dataUrl) {
|
|
|
1344
1109
|
}
|
|
1345
1110
|
}
|
|
1346
1111
|
|
|
1347
|
-
// src/prompt/data
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
function convertToLanguageModelV4DataContent(content) {
|
|
1362
|
-
if (content instanceof Uint8Array) {
|
|
1363
|
-
return { data: content, mediaType: void 0 };
|
|
1364
|
-
}
|
|
1365
|
-
if (content instanceof ArrayBuffer) {
|
|
1366
|
-
return { data: new Uint8Array(content), mediaType: void 0 };
|
|
1367
|
-
}
|
|
1368
|
-
if (typeof content === "string") {
|
|
1369
|
-
try {
|
|
1370
|
-
content = new URL(content);
|
|
1371
|
-
} catch (e) {
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
if (content instanceof URL && content.protocol === "data:") {
|
|
1375
|
-
const { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(
|
|
1376
|
-
content.toString()
|
|
1377
|
-
);
|
|
1378
|
-
if (dataUrlMediaType == null || base64Content == null) {
|
|
1379
|
-
throw new AISDKError22({
|
|
1380
|
-
name: "InvalidDataContentError",
|
|
1381
|
-
message: `Invalid data URL format in content ${content.toString()}`
|
|
1112
|
+
// src/prompt/file-part-data.ts
|
|
1113
|
+
function isTaggedFileData(value) {
|
|
1114
|
+
if (typeof value !== "object" || value === null)
|
|
1115
|
+
return false;
|
|
1116
|
+
const type = value.type;
|
|
1117
|
+
return type === "data" || type === "url" || type === "reference" || type === "text";
|
|
1118
|
+
}
|
|
1119
|
+
function convertUrlToFilePartData(url) {
|
|
1120
|
+
if (url.protocol === "data:") {
|
|
1121
|
+
const { mediaType, base64Content } = splitDataUrl(url.toString());
|
|
1122
|
+
if (mediaType == null || base64Content == null) {
|
|
1123
|
+
throw new InvalidDataContentError({
|
|
1124
|
+
content: url,
|
|
1125
|
+
message: `Invalid data URL format in content ${url.toString()}`
|
|
1382
1126
|
});
|
|
1383
1127
|
}
|
|
1384
|
-
return { data:
|
|
1128
|
+
return { data: { type: "data", data: base64Content }, mediaType };
|
|
1385
1129
|
}
|
|
1386
|
-
return { data:
|
|
1130
|
+
return { data: { type: "url", url }, mediaType: void 0 };
|
|
1387
1131
|
}
|
|
1388
|
-
function
|
|
1389
|
-
if (
|
|
1390
|
-
return content;
|
|
1132
|
+
function convertInlineDataToFilePartData(content) {
|
|
1133
|
+
if (content instanceof Uint8Array) {
|
|
1134
|
+
return { data: { type: "data", data: content }, mediaType: void 0 };
|
|
1391
1135
|
}
|
|
1392
1136
|
if (content instanceof ArrayBuffer) {
|
|
1393
|
-
return
|
|
1137
|
+
return {
|
|
1138
|
+
data: { type: "data", data: new Uint8Array(content) },
|
|
1139
|
+
mediaType: void 0
|
|
1140
|
+
};
|
|
1394
1141
|
}
|
|
1395
|
-
|
|
1142
|
+
if (isBuffer(content)) {
|
|
1143
|
+
return {
|
|
1144
|
+
data: { type: "data", data: new Uint8Array(content) },
|
|
1145
|
+
mediaType: void 0
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
return {
|
|
1149
|
+
data: { type: "data", data: content },
|
|
1150
|
+
mediaType: void 0
|
|
1151
|
+
};
|
|
1396
1152
|
}
|
|
1397
|
-
function
|
|
1398
|
-
if (content
|
|
1399
|
-
|
|
1153
|
+
function convertToLanguageModelV4FilePart(content) {
|
|
1154
|
+
if (isTaggedFileData(content)) {
|
|
1155
|
+
switch (content.type) {
|
|
1156
|
+
case "data":
|
|
1157
|
+
if (typeof content.data === "string" && content.data.startsWith("data:")) {
|
|
1158
|
+
throw new InvalidDataContentError({
|
|
1159
|
+
content: content.data,
|
|
1160
|
+
message: 'Data URLs are not valid inline data. Pass them as { type: "url", url } instead.'
|
|
1161
|
+
});
|
|
1162
|
+
}
|
|
1163
|
+
return convertInlineDataToFilePartData(content.data);
|
|
1164
|
+
case "url":
|
|
1165
|
+
return convertUrlToFilePartData(content.url);
|
|
1166
|
+
case "reference":
|
|
1167
|
+
return {
|
|
1168
|
+
data: { type: "reference", reference: content.reference },
|
|
1169
|
+
mediaType: void 0
|
|
1170
|
+
};
|
|
1171
|
+
case "text":
|
|
1172
|
+
return {
|
|
1173
|
+
data: { type: "text", text: content.text },
|
|
1174
|
+
mediaType: void 0
|
|
1175
|
+
};
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
if (content instanceof URL) {
|
|
1179
|
+
return convertUrlToFilePartData(content);
|
|
1400
1180
|
}
|
|
1401
1181
|
if (typeof content === "string") {
|
|
1402
1182
|
try {
|
|
1403
|
-
return
|
|
1404
|
-
} catch (
|
|
1405
|
-
|
|
1406
|
-
message: "Invalid data content. Content string is not a base64-encoded media.",
|
|
1407
|
-
content,
|
|
1408
|
-
cause: error
|
|
1409
|
-
});
|
|
1183
|
+
return convertUrlToFilePartData(new URL(content));
|
|
1184
|
+
} catch (e) {
|
|
1185
|
+
return convertInlineDataToFilePartData(content);
|
|
1410
1186
|
}
|
|
1411
1187
|
}
|
|
1412
|
-
if (content
|
|
1413
|
-
return
|
|
1188
|
+
if (isProviderReference(content)) {
|
|
1189
|
+
return {
|
|
1190
|
+
data: { type: "reference", reference: content },
|
|
1191
|
+
mediaType: void 0
|
|
1192
|
+
};
|
|
1414
1193
|
}
|
|
1415
|
-
|
|
1194
|
+
return convertInlineDataToFilePartData(content);
|
|
1416
1195
|
}
|
|
1417
1196
|
|
|
1418
1197
|
// src/prompt/convert-to-language-model-prompt.ts
|
|
@@ -1551,7 +1330,16 @@ function convertToLanguageModelMessage({
|
|
|
1551
1330
|
}
|
|
1552
1331
|
const converted = {
|
|
1553
1332
|
role: "user",
|
|
1554
|
-
content: message.content.map((part) =>
|
|
1333
|
+
content: message.content.map((part) => {
|
|
1334
|
+
if (part.type === "image") {
|
|
1335
|
+
warnings.push({
|
|
1336
|
+
type: "deprecated",
|
|
1337
|
+
setting: '"image" content part',
|
|
1338
|
+
message: `The "image" content part type is deprecated. Use a "file" part with mediaType: 'image' (or a more specific image/* subtype) instead.`
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
return convertImagePartToFilePart(part);
|
|
1342
|
+
}).map((part) => convertPartToLanguageModelPart(part, downloadedAssets)).filter((part) => part.type !== "text" || part.text !== ""),
|
|
1555
1343
|
providerOptions: message.providerOptions
|
|
1556
1344
|
};
|
|
1557
1345
|
if (warnings.length > 0) {
|
|
@@ -1585,16 +1373,7 @@ function convertToLanguageModelMessage({
|
|
|
1585
1373
|
};
|
|
1586
1374
|
}
|
|
1587
1375
|
case "file": {
|
|
1588
|
-
|
|
1589
|
-
return {
|
|
1590
|
-
type: "file",
|
|
1591
|
-
data: part.data,
|
|
1592
|
-
filename: part.filename,
|
|
1593
|
-
mediaType: part.mediaType,
|
|
1594
|
-
providerOptions
|
|
1595
|
-
};
|
|
1596
|
-
}
|
|
1597
|
-
const { data, mediaType } = convertToLanguageModelV4DataContent(
|
|
1376
|
+
const { data, mediaType } = convertToLanguageModelV4FilePart(
|
|
1598
1377
|
part.data
|
|
1599
1378
|
);
|
|
1600
1379
|
return {
|
|
@@ -1613,9 +1392,14 @@ function convertToLanguageModelMessage({
|
|
|
1613
1392
|
};
|
|
1614
1393
|
}
|
|
1615
1394
|
case "reasoning-file": {
|
|
1616
|
-
const { data, mediaType } =
|
|
1395
|
+
const { data, mediaType } = convertToLanguageModelV4FilePart(
|
|
1617
1396
|
part.data
|
|
1618
1397
|
);
|
|
1398
|
+
if (data.type !== "data" && data.type !== "url") {
|
|
1399
|
+
throw new Error(
|
|
1400
|
+
`Unsupported reasoning-file data type: ${data.type}`
|
|
1401
|
+
);
|
|
1402
|
+
}
|
|
1619
1403
|
return {
|
|
1620
1404
|
type: "reasoning-file",
|
|
1621
1405
|
data,
|
|
@@ -1706,28 +1490,29 @@ function convertToLanguageModelMessage({
|
|
|
1706
1490
|
}
|
|
1707
1491
|
}
|
|
1708
1492
|
}
|
|
1493
|
+
function convertImagePartToFilePart(part) {
|
|
1494
|
+
var _a21;
|
|
1495
|
+
if (part.type !== "image") {
|
|
1496
|
+
return part;
|
|
1497
|
+
}
|
|
1498
|
+
return {
|
|
1499
|
+
type: "file",
|
|
1500
|
+
data: part.image,
|
|
1501
|
+
mediaType: (_a21 = part.mediaType) != null ? _a21 : "image",
|
|
1502
|
+
providerOptions: part.providerOptions
|
|
1503
|
+
};
|
|
1504
|
+
}
|
|
1709
1505
|
async function downloadAssets(messages, download2, supportedUrls) {
|
|
1710
1506
|
const plannedDownloads = messages.filter((message) => message.role === "user").map((message) => message.content).filter(
|
|
1711
1507
|
(content) => Array.isArray(content)
|
|
1712
|
-
).flat().filter(
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
var _a21;
|
|
1716
|
-
const mediaType = (_a21 = part.mediaType) != null ? _a21 : part.type === "image" ? "image/*" : void 0;
|
|
1717
|
-
let data = part.type === "image" ? part.image : part.data;
|
|
1718
|
-
if (typeof data === "string") {
|
|
1719
|
-
try {
|
|
1720
|
-
data = new URL(data);
|
|
1721
|
-
} catch (e) {
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1508
|
+
).flat().map((part) => convertImagePartToFilePart(part)).filter((part) => part.type === "file").map((part) => {
|
|
1509
|
+
const mediaType = part.mediaType;
|
|
1510
|
+
const { data } = convertToLanguageModelV4FilePart(part.data);
|
|
1724
1511
|
return { mediaType, data };
|
|
1725
|
-
}).filter(
|
|
1726
|
-
|
|
1727
|
-
).map((part) => ({
|
|
1728
|
-
url: part.data,
|
|
1512
|
+
}).filter((part) => part.data.type === "url").map((part) => ({
|
|
1513
|
+
url: part.data.url,
|
|
1729
1514
|
isUrlSupportedByModel: part.mediaType != null && isUrlSupported({
|
|
1730
|
-
url: part.data.toString(),
|
|
1515
|
+
url: part.data.url.toString(),
|
|
1731
1516
|
mediaType: part.mediaType,
|
|
1732
1517
|
supportedUrls
|
|
1733
1518
|
})
|
|
@@ -1743,7 +1528,6 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
1743
1528
|
);
|
|
1744
1529
|
}
|
|
1745
1530
|
function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
1746
|
-
var _a21, _b;
|
|
1747
1531
|
if (part.type === "text") {
|
|
1748
1532
|
return {
|
|
1749
1533
|
type: "text",
|
|
@@ -1751,55 +1535,37 @@ function convertPartToLanguageModelPart(part, downloadedAssets) {
|
|
|
1751
1535
|
providerOptions: part.providerOptions
|
|
1752
1536
|
};
|
|
1753
1537
|
}
|
|
1754
|
-
const
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
mediaType: (_a21 = part.mediaType) != null ? _a21 : type === "image" ? "image/*" : "",
|
|
1760
|
-
filename: type === "file" ? part.filename : void 0,
|
|
1761
|
-
data: rawData,
|
|
1762
|
-
providerOptions: part.providerOptions
|
|
1763
|
-
};
|
|
1764
|
-
}
|
|
1765
|
-
const originalData = rawData;
|
|
1766
|
-
const { data: convertedData, mediaType: convertedMediaType } = convertToLanguageModelV4DataContent(originalData);
|
|
1767
|
-
let mediaType = convertedMediaType != null ? convertedMediaType : part.mediaType;
|
|
1768
|
-
let data = convertedData;
|
|
1769
|
-
if (data instanceof URL) {
|
|
1770
|
-
const downloadedFile = downloadedAssets[data.toString()];
|
|
1538
|
+
const { data: normalizedData, mediaType: dataUrlMediaType } = convertToLanguageModelV4FilePart(part.data);
|
|
1539
|
+
let mediaType = dataUrlMediaType != null ? dataUrlMediaType : part.mediaType;
|
|
1540
|
+
let data = normalizedData;
|
|
1541
|
+
if (data.type === "url") {
|
|
1542
|
+
const downloadedFile = downloadedAssets[data.url.toString()];
|
|
1771
1543
|
if (downloadedFile) {
|
|
1772
|
-
data = downloadedFile.data;
|
|
1773
|
-
mediaType != null
|
|
1774
|
-
|
|
1775
|
-
}
|
|
1776
|
-
switch (type) {
|
|
1777
|
-
case "image": {
|
|
1778
|
-
if (data instanceof Uint8Array || typeof data === "string") {
|
|
1779
|
-
mediaType = (_b = detectMediaType({ data, signatures: imageMediaTypeSignatures })) != null ? _b : mediaType;
|
|
1544
|
+
data = { type: "data", data: downloadedFile.data };
|
|
1545
|
+
if (downloadedFile.mediaType != null && (mediaType == null || !isFullMediaType(mediaType))) {
|
|
1546
|
+
mediaType = downloadedFile.mediaType;
|
|
1780
1547
|
}
|
|
1781
|
-
return {
|
|
1782
|
-
type: "file",
|
|
1783
|
-
mediaType: mediaType != null ? mediaType : "image/*",
|
|
1784
|
-
// any image
|
|
1785
|
-
filename: void 0,
|
|
1786
|
-
data,
|
|
1787
|
-
providerOptions: part.providerOptions
|
|
1788
|
-
};
|
|
1789
1548
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
data,
|
|
1799
|
-
providerOptions: part.providerOptions
|
|
1800
|
-
};
|
|
1549
|
+
}
|
|
1550
|
+
if (data.type === "data" && (data.data instanceof Uint8Array || typeof data.data === "string")) {
|
|
1551
|
+
const imageMediaType = detectMediaType({
|
|
1552
|
+
data: data.data,
|
|
1553
|
+
topLevelType: "image"
|
|
1554
|
+
});
|
|
1555
|
+
if (imageMediaType != null) {
|
|
1556
|
+
mediaType = imageMediaType;
|
|
1801
1557
|
}
|
|
1802
1558
|
}
|
|
1559
|
+
if (mediaType == null) {
|
|
1560
|
+
throw new Error(`Media type is missing for file part`);
|
|
1561
|
+
}
|
|
1562
|
+
return {
|
|
1563
|
+
type: "file",
|
|
1564
|
+
mediaType,
|
|
1565
|
+
filename: part.filename,
|
|
1566
|
+
data,
|
|
1567
|
+
providerOptions: part.providerOptions
|
|
1568
|
+
};
|
|
1803
1569
|
}
|
|
1804
1570
|
function mapToolResultOutput({
|
|
1805
1571
|
output,
|
|
@@ -2163,170 +1929,197 @@ import {
|
|
|
2163
1929
|
asArray as asArray2,
|
|
2164
1930
|
safeValidateTypes
|
|
2165
1931
|
} from "@ai-sdk/provider-utils";
|
|
2166
|
-
import { z as
|
|
1932
|
+
import { z as z5 } from "zod/v4";
|
|
2167
1933
|
|
|
2168
1934
|
// src/prompt/message.ts
|
|
2169
|
-
import { z as
|
|
1935
|
+
import { z as z4 } from "zod/v4";
|
|
2170
1936
|
|
|
2171
1937
|
// src/types/provider-metadata.ts
|
|
2172
|
-
import { z as
|
|
1938
|
+
import { z as z2 } from "zod/v4";
|
|
2173
1939
|
|
|
2174
1940
|
// src/types/json-value.ts
|
|
2175
|
-
import { z
|
|
2176
|
-
var jsonValueSchema =
|
|
2177
|
-
() =>
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
1941
|
+
import { z } from "zod/v4";
|
|
1942
|
+
var jsonValueSchema = z.lazy(
|
|
1943
|
+
() => z.union([
|
|
1944
|
+
z.null(),
|
|
1945
|
+
z.string(),
|
|
1946
|
+
z.number(),
|
|
1947
|
+
z.boolean(),
|
|
1948
|
+
z.record(z.string(), jsonValueSchema.optional()),
|
|
1949
|
+
z.array(jsonValueSchema)
|
|
2184
1950
|
])
|
|
2185
1951
|
);
|
|
2186
1952
|
|
|
2187
1953
|
// src/types/provider-metadata.ts
|
|
2188
|
-
var providerMetadataSchema =
|
|
2189
|
-
|
|
2190
|
-
|
|
1954
|
+
var providerMetadataSchema = z2.record(
|
|
1955
|
+
z2.string(),
|
|
1956
|
+
z2.record(z2.string(), jsonValueSchema.optional())
|
|
2191
1957
|
);
|
|
2192
1958
|
|
|
2193
1959
|
// src/prompt/content-part.ts
|
|
2194
|
-
import {
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
1960
|
+
import {
|
|
1961
|
+
isBuffer as isBuffer2
|
|
1962
|
+
} from "@ai-sdk/provider-utils";
|
|
1963
|
+
import { z as z3 } from "zod/v4";
|
|
1964
|
+
var fileInlineDataSchema = z3.union([
|
|
1965
|
+
z3.string(),
|
|
1966
|
+
z3.instanceof(Uint8Array),
|
|
1967
|
+
z3.instanceof(ArrayBuffer),
|
|
1968
|
+
z3.custom(isBuffer2, { message: "Must be a Buffer" })
|
|
1969
|
+
]);
|
|
1970
|
+
var providerReferenceSchema = z3.record(z3.string(), z3.string());
|
|
1971
|
+
var textPartSchema = z3.object({
|
|
1972
|
+
type: z3.literal("text"),
|
|
1973
|
+
text: z3.string(),
|
|
2199
1974
|
providerOptions: providerMetadataSchema.optional()
|
|
2200
1975
|
});
|
|
2201
|
-
var imagePartSchema =
|
|
2202
|
-
type:
|
|
2203
|
-
image:
|
|
2204
|
-
|
|
2205
|
-
|
|
1976
|
+
var imagePartSchema = z3.object({
|
|
1977
|
+
type: z3.literal("image"),
|
|
1978
|
+
image: z3.union([
|
|
1979
|
+
fileInlineDataSchema,
|
|
1980
|
+
z3.instanceof(URL),
|
|
2206
1981
|
providerReferenceSchema
|
|
2207
1982
|
]),
|
|
2208
|
-
mediaType:
|
|
1983
|
+
mediaType: z3.string().optional(),
|
|
2209
1984
|
providerOptions: providerMetadataSchema.optional()
|
|
2210
1985
|
});
|
|
2211
|
-
var
|
|
2212
|
-
type:
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
1986
|
+
var taggedFileDataSchema = z3.discriminatedUnion("type", [
|
|
1987
|
+
z3.object({ type: z3.literal("data"), data: fileInlineDataSchema }),
|
|
1988
|
+
z3.object({ type: z3.literal("url"), url: z3.instanceof(URL) }),
|
|
1989
|
+
z3.object({
|
|
1990
|
+
type: z3.literal("reference"),
|
|
1991
|
+
reference: providerReferenceSchema
|
|
1992
|
+
}),
|
|
1993
|
+
z3.object({ type: z3.literal("text"), text: z3.string() })
|
|
1994
|
+
]);
|
|
1995
|
+
var taggedReasoningFileDataSchema = z3.discriminatedUnion("type", [
|
|
1996
|
+
z3.object({ type: z3.literal("data"), data: fileInlineDataSchema }),
|
|
1997
|
+
z3.object({ type: z3.literal("url"), url: z3.instanceof(URL) })
|
|
1998
|
+
]);
|
|
1999
|
+
var filePartSchema = z3.object({
|
|
2000
|
+
type: z3.literal("file"),
|
|
2001
|
+
data: z3.union([
|
|
2002
|
+
taggedFileDataSchema,
|
|
2003
|
+
fileInlineDataSchema,
|
|
2004
|
+
z3.instanceof(URL),
|
|
2216
2005
|
providerReferenceSchema
|
|
2217
2006
|
]),
|
|
2218
|
-
filename:
|
|
2219
|
-
mediaType:
|
|
2007
|
+
filename: z3.string().optional(),
|
|
2008
|
+
mediaType: z3.string(),
|
|
2220
2009
|
providerOptions: providerMetadataSchema.optional()
|
|
2221
2010
|
});
|
|
2222
|
-
var reasoningPartSchema =
|
|
2223
|
-
type:
|
|
2224
|
-
text:
|
|
2011
|
+
var reasoningPartSchema = z3.object({
|
|
2012
|
+
type: z3.literal("reasoning"),
|
|
2013
|
+
text: z3.string(),
|
|
2225
2014
|
providerOptions: providerMetadataSchema.optional()
|
|
2226
2015
|
});
|
|
2227
|
-
var customPartSchema =
|
|
2228
|
-
type:
|
|
2229
|
-
kind:
|
|
2016
|
+
var customPartSchema = z3.object({
|
|
2017
|
+
type: z3.literal("custom"),
|
|
2018
|
+
kind: z3.string().transform((value) => value),
|
|
2230
2019
|
providerOptions: providerMetadataSchema.optional()
|
|
2231
2020
|
});
|
|
2232
|
-
var reasoningFilePartSchema =
|
|
2233
|
-
type:
|
|
2234
|
-
data:
|
|
2235
|
-
|
|
2021
|
+
var reasoningFilePartSchema = z3.object({
|
|
2022
|
+
type: z3.literal("reasoning-file"),
|
|
2023
|
+
data: z3.union([
|
|
2024
|
+
taggedReasoningFileDataSchema,
|
|
2025
|
+
fileInlineDataSchema,
|
|
2026
|
+
z3.instanceof(URL)
|
|
2027
|
+
]),
|
|
2028
|
+
mediaType: z3.string(),
|
|
2236
2029
|
providerOptions: providerMetadataSchema.optional()
|
|
2237
2030
|
});
|
|
2238
|
-
var toolCallPartSchema =
|
|
2239
|
-
type:
|
|
2240
|
-
toolCallId:
|
|
2241
|
-
toolName:
|
|
2242
|
-
input:
|
|
2031
|
+
var toolCallPartSchema = z3.object({
|
|
2032
|
+
type: z3.literal("tool-call"),
|
|
2033
|
+
toolCallId: z3.string(),
|
|
2034
|
+
toolName: z3.string(),
|
|
2035
|
+
input: z3.unknown(),
|
|
2243
2036
|
providerOptions: providerMetadataSchema.optional(),
|
|
2244
|
-
providerExecuted:
|
|
2037
|
+
providerExecuted: z3.boolean().optional()
|
|
2245
2038
|
});
|
|
2246
|
-
var outputSchema =
|
|
2039
|
+
var outputSchema = z3.discriminatedUnion(
|
|
2247
2040
|
"type",
|
|
2248
2041
|
[
|
|
2249
|
-
|
|
2250
|
-
type:
|
|
2251
|
-
value:
|
|
2042
|
+
z3.object({
|
|
2043
|
+
type: z3.literal("text"),
|
|
2044
|
+
value: z3.string(),
|
|
2252
2045
|
providerOptions: providerMetadataSchema.optional()
|
|
2253
2046
|
}),
|
|
2254
|
-
|
|
2255
|
-
type:
|
|
2047
|
+
z3.object({
|
|
2048
|
+
type: z3.literal("json"),
|
|
2256
2049
|
value: jsonValueSchema,
|
|
2257
2050
|
providerOptions: providerMetadataSchema.optional()
|
|
2258
2051
|
}),
|
|
2259
|
-
|
|
2260
|
-
type:
|
|
2261
|
-
reason:
|
|
2052
|
+
z3.object({
|
|
2053
|
+
type: z3.literal("execution-denied"),
|
|
2054
|
+
reason: z3.string().optional(),
|
|
2262
2055
|
providerOptions: providerMetadataSchema.optional()
|
|
2263
2056
|
}),
|
|
2264
|
-
|
|
2265
|
-
type:
|
|
2266
|
-
value:
|
|
2057
|
+
z3.object({
|
|
2058
|
+
type: z3.literal("error-text"),
|
|
2059
|
+
value: z3.string(),
|
|
2267
2060
|
providerOptions: providerMetadataSchema.optional()
|
|
2268
2061
|
}),
|
|
2269
|
-
|
|
2270
|
-
type:
|
|
2062
|
+
z3.object({
|
|
2063
|
+
type: z3.literal("error-json"),
|
|
2271
2064
|
value: jsonValueSchema,
|
|
2272
2065
|
providerOptions: providerMetadataSchema.optional()
|
|
2273
2066
|
}),
|
|
2274
|
-
|
|
2275
|
-
type:
|
|
2276
|
-
value:
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
type:
|
|
2280
|
-
text:
|
|
2067
|
+
z3.object({
|
|
2068
|
+
type: z3.literal("content"),
|
|
2069
|
+
value: z3.array(
|
|
2070
|
+
z3.union([
|
|
2071
|
+
z3.object({
|
|
2072
|
+
type: z3.literal("text"),
|
|
2073
|
+
text: z3.string(),
|
|
2281
2074
|
providerOptions: providerMetadataSchema.optional()
|
|
2282
2075
|
}),
|
|
2283
|
-
|
|
2284
|
-
type:
|
|
2285
|
-
data:
|
|
2286
|
-
mediaType:
|
|
2287
|
-
filename:
|
|
2076
|
+
z3.object({
|
|
2077
|
+
type: z3.literal("file-data"),
|
|
2078
|
+
data: z3.string(),
|
|
2079
|
+
mediaType: z3.string(),
|
|
2080
|
+
filename: z3.string().optional(),
|
|
2288
2081
|
providerOptions: providerMetadataSchema.optional()
|
|
2289
2082
|
}),
|
|
2290
|
-
|
|
2291
|
-
type:
|
|
2292
|
-
url:
|
|
2083
|
+
z3.object({
|
|
2084
|
+
type: z3.literal("file-url"),
|
|
2085
|
+
url: z3.string(),
|
|
2293
2086
|
// Temporarily optional. TODO: make required in v8, after migration period.
|
|
2294
|
-
mediaType:
|
|
2087
|
+
mediaType: z3.string().optional(),
|
|
2295
2088
|
providerOptions: providerMetadataSchema.optional()
|
|
2296
2089
|
}),
|
|
2297
|
-
|
|
2298
|
-
type:
|
|
2299
|
-
fileId:
|
|
2090
|
+
z3.object({
|
|
2091
|
+
type: z3.literal("file-id"),
|
|
2092
|
+
fileId: z3.union([z3.string(), z3.record(z3.string(), z3.string())]),
|
|
2300
2093
|
providerOptions: providerMetadataSchema.optional()
|
|
2301
2094
|
}),
|
|
2302
|
-
|
|
2303
|
-
type:
|
|
2304
|
-
providerReference:
|
|
2095
|
+
z3.object({
|
|
2096
|
+
type: z3.literal("file-reference"),
|
|
2097
|
+
providerReference: z3.record(z3.string(), z3.string()),
|
|
2305
2098
|
providerOptions: providerMetadataSchema.optional()
|
|
2306
2099
|
}),
|
|
2307
|
-
|
|
2308
|
-
type:
|
|
2309
|
-
data:
|
|
2310
|
-
mediaType:
|
|
2100
|
+
z3.object({
|
|
2101
|
+
type: z3.literal("image-data"),
|
|
2102
|
+
data: z3.string(),
|
|
2103
|
+
mediaType: z3.string(),
|
|
2311
2104
|
providerOptions: providerMetadataSchema.optional()
|
|
2312
2105
|
}),
|
|
2313
|
-
|
|
2314
|
-
type:
|
|
2315
|
-
url:
|
|
2106
|
+
z3.object({
|
|
2107
|
+
type: z3.literal("image-url"),
|
|
2108
|
+
url: z3.string(),
|
|
2316
2109
|
providerOptions: providerMetadataSchema.optional()
|
|
2317
2110
|
}),
|
|
2318
|
-
|
|
2319
|
-
type:
|
|
2320
|
-
fileId:
|
|
2111
|
+
z3.object({
|
|
2112
|
+
type: z3.literal("image-file-id"),
|
|
2113
|
+
fileId: z3.union([z3.string(), z3.record(z3.string(), z3.string())]),
|
|
2321
2114
|
providerOptions: providerMetadataSchema.optional()
|
|
2322
2115
|
}),
|
|
2323
|
-
|
|
2324
|
-
type:
|
|
2325
|
-
providerReference:
|
|
2116
|
+
z3.object({
|
|
2117
|
+
type: z3.literal("image-file-reference"),
|
|
2118
|
+
providerReference: z3.record(z3.string(), z3.string()),
|
|
2326
2119
|
providerOptions: providerMetadataSchema.optional()
|
|
2327
2120
|
}),
|
|
2328
|
-
|
|
2329
|
-
type:
|
|
2121
|
+
z3.object({
|
|
2122
|
+
type: z3.literal("custom"),
|
|
2330
2123
|
providerOptions: providerMetadataSchema.optional()
|
|
2331
2124
|
})
|
|
2332
2125
|
])
|
|
@@ -2334,47 +2127,47 @@ var outputSchema = z4.discriminatedUnion(
|
|
|
2334
2127
|
})
|
|
2335
2128
|
]
|
|
2336
2129
|
);
|
|
2337
|
-
var toolResultPartSchema =
|
|
2338
|
-
type:
|
|
2339
|
-
toolCallId:
|
|
2340
|
-
toolName:
|
|
2130
|
+
var toolResultPartSchema = z3.object({
|
|
2131
|
+
type: z3.literal("tool-result"),
|
|
2132
|
+
toolCallId: z3.string(),
|
|
2133
|
+
toolName: z3.string(),
|
|
2341
2134
|
output: outputSchema,
|
|
2342
2135
|
providerOptions: providerMetadataSchema.optional()
|
|
2343
2136
|
});
|
|
2344
|
-
var toolApprovalRequestSchema =
|
|
2345
|
-
type:
|
|
2346
|
-
approvalId:
|
|
2347
|
-
toolCallId:
|
|
2137
|
+
var toolApprovalRequestSchema = z3.object({
|
|
2138
|
+
type: z3.literal("tool-approval-request"),
|
|
2139
|
+
approvalId: z3.string(),
|
|
2140
|
+
toolCallId: z3.string()
|
|
2348
2141
|
});
|
|
2349
|
-
var toolApprovalResponseSchema =
|
|
2350
|
-
type:
|
|
2351
|
-
approvalId:
|
|
2352
|
-
approved:
|
|
2353
|
-
reason:
|
|
2142
|
+
var toolApprovalResponseSchema = z3.object({
|
|
2143
|
+
type: z3.literal("tool-approval-response"),
|
|
2144
|
+
approvalId: z3.string(),
|
|
2145
|
+
approved: z3.boolean(),
|
|
2146
|
+
reason: z3.string().optional()
|
|
2354
2147
|
});
|
|
2355
2148
|
|
|
2356
2149
|
// src/prompt/message.ts
|
|
2357
|
-
var systemModelMessageSchema =
|
|
2150
|
+
var systemModelMessageSchema = z4.object(
|
|
2358
2151
|
{
|
|
2359
|
-
role:
|
|
2360
|
-
content:
|
|
2152
|
+
role: z4.literal("system"),
|
|
2153
|
+
content: z4.string(),
|
|
2361
2154
|
providerOptions: providerMetadataSchema.optional()
|
|
2362
2155
|
}
|
|
2363
2156
|
);
|
|
2364
|
-
var userModelMessageSchema =
|
|
2365
|
-
role:
|
|
2366
|
-
content:
|
|
2367
|
-
|
|
2368
|
-
|
|
2157
|
+
var userModelMessageSchema = z4.object({
|
|
2158
|
+
role: z4.literal("user"),
|
|
2159
|
+
content: z4.union([
|
|
2160
|
+
z4.string(),
|
|
2161
|
+
z4.array(z4.union([textPartSchema, imagePartSchema, filePartSchema]))
|
|
2369
2162
|
]),
|
|
2370
2163
|
providerOptions: providerMetadataSchema.optional()
|
|
2371
2164
|
});
|
|
2372
|
-
var assistantModelMessageSchema =
|
|
2373
|
-
role:
|
|
2374
|
-
content:
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2165
|
+
var assistantModelMessageSchema = z4.object({
|
|
2166
|
+
role: z4.literal("assistant"),
|
|
2167
|
+
content: z4.union([
|
|
2168
|
+
z4.string(),
|
|
2169
|
+
z4.array(
|
|
2170
|
+
z4.union([
|
|
2378
2171
|
textPartSchema,
|
|
2379
2172
|
customPartSchema,
|
|
2380
2173
|
filePartSchema,
|
|
@@ -2388,12 +2181,12 @@ var assistantModelMessageSchema = z5.object({
|
|
|
2388
2181
|
]),
|
|
2389
2182
|
providerOptions: providerMetadataSchema.optional()
|
|
2390
2183
|
});
|
|
2391
|
-
var toolModelMessageSchema =
|
|
2392
|
-
role:
|
|
2393
|
-
content:
|
|
2184
|
+
var toolModelMessageSchema = z4.object({
|
|
2185
|
+
role: z4.literal("tool"),
|
|
2186
|
+
content: z4.array(z4.union([toolResultPartSchema, toolApprovalResponseSchema])),
|
|
2394
2187
|
providerOptions: providerMetadataSchema.optional()
|
|
2395
2188
|
});
|
|
2396
|
-
var modelMessageSchema =
|
|
2189
|
+
var modelMessageSchema = z4.union([
|
|
2397
2190
|
systemModelMessageSchema,
|
|
2398
2191
|
userModelMessageSchema,
|
|
2399
2192
|
assistantModelMessageSchema,
|
|
@@ -2449,7 +2242,7 @@ async function standardizePrompt({
|
|
|
2449
2242
|
}
|
|
2450
2243
|
const validationResult = await safeValidateTypes({
|
|
2451
2244
|
value: messages,
|
|
2452
|
-
schema:
|
|
2245
|
+
schema: z5.array(modelMessageSchema)
|
|
2453
2246
|
});
|
|
2454
2247
|
if (!validationResult.success) {
|
|
2455
2248
|
throw new InvalidPromptError2({
|
|
@@ -2463,14 +2256,14 @@ async function standardizePrompt({
|
|
|
2463
2256
|
|
|
2464
2257
|
// src/prompt/wrap-gateway-error.ts
|
|
2465
2258
|
import { GatewayAuthenticationError } from "@ai-sdk/gateway";
|
|
2466
|
-
import { AISDKError as
|
|
2259
|
+
import { AISDKError as AISDKError22 } from "@ai-sdk/provider";
|
|
2467
2260
|
function wrapGatewayError(error) {
|
|
2468
2261
|
if (!GatewayAuthenticationError.isInstance(error))
|
|
2469
2262
|
return error;
|
|
2470
2263
|
const isProductionEnv = (process == null ? void 0 : process.env.NODE_ENV) === "production";
|
|
2471
2264
|
const moreInfoURL = "https://ai-sdk.dev/unauthenticated-ai-gateway";
|
|
2472
2265
|
if (isProductionEnv) {
|
|
2473
|
-
return new
|
|
2266
|
+
return new AISDKError22({
|
|
2474
2267
|
name: "GatewayError",
|
|
2475
2268
|
message: `Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${moreInfoURL}`
|
|
2476
2269
|
});
|
|
@@ -3001,8 +2794,8 @@ function filterActiveTools({
|
|
|
3001
2794
|
|
|
3002
2795
|
// src/generate-text/generated-file.ts
|
|
3003
2796
|
import {
|
|
3004
|
-
convertBase64ToUint8Array
|
|
3005
|
-
convertUint8ArrayToBase64
|
|
2797
|
+
convertBase64ToUint8Array,
|
|
2798
|
+
convertUint8ArrayToBase64
|
|
3006
2799
|
} from "@ai-sdk/provider-utils";
|
|
3007
2800
|
var DefaultGeneratedFile = class {
|
|
3008
2801
|
constructor({
|
|
@@ -3017,14 +2810,14 @@ var DefaultGeneratedFile = class {
|
|
|
3017
2810
|
// lazy conversion with caching to avoid unnecessary conversion overhead:
|
|
3018
2811
|
get base64() {
|
|
3019
2812
|
if (this.base64Data == null) {
|
|
3020
|
-
this.base64Data =
|
|
2813
|
+
this.base64Data = convertUint8ArrayToBase64(this.uint8ArrayData);
|
|
3021
2814
|
}
|
|
3022
2815
|
return this.base64Data;
|
|
3023
2816
|
}
|
|
3024
2817
|
// lazy conversion with caching to avoid unnecessary conversion overhead:
|
|
3025
2818
|
get uint8Array() {
|
|
3026
2819
|
if (this.uint8ArrayData == null) {
|
|
3027
|
-
this.uint8ArrayData =
|
|
2820
|
+
this.uint8ArrayData = convertBase64ToUint8Array(this.base64Data);
|
|
3028
2821
|
}
|
|
3029
2822
|
return this.uint8ArrayData;
|
|
3030
2823
|
}
|
|
@@ -3710,6 +3503,15 @@ import {
|
|
|
3710
3503
|
safeParseJSON as safeParseJSON3,
|
|
3711
3504
|
safeValidateTypes as safeValidateTypes3
|
|
3712
3505
|
} from "@ai-sdk/provider-utils";
|
|
3506
|
+
function mergeToolProviderMetadata(toolMetadata, callMetadata) {
|
|
3507
|
+
if (toolMetadata == null) {
|
|
3508
|
+
return callMetadata;
|
|
3509
|
+
}
|
|
3510
|
+
if (callMetadata == null) {
|
|
3511
|
+
return toolMetadata;
|
|
3512
|
+
}
|
|
3513
|
+
return { ...toolMetadata, ...callMetadata };
|
|
3514
|
+
}
|
|
3713
3515
|
async function parseToolCall({
|
|
3714
3516
|
toolCall,
|
|
3715
3517
|
tools,
|
|
@@ -3717,7 +3519,7 @@ async function parseToolCall({
|
|
|
3717
3519
|
system,
|
|
3718
3520
|
messages
|
|
3719
3521
|
}) {
|
|
3720
|
-
var _a21;
|
|
3522
|
+
var _a21, _b;
|
|
3721
3523
|
try {
|
|
3722
3524
|
if (tools == null) {
|
|
3723
3525
|
if (toolCall.providerExecuted && toolCall.dynamic) {
|
|
@@ -3768,7 +3570,10 @@ async function parseToolCall({
|
|
|
3768
3570
|
error,
|
|
3769
3571
|
title: (_a21 = tools == null ? void 0 : tools[toolCall.toolName]) == null ? void 0 : _a21.title,
|
|
3770
3572
|
providerExecuted: toolCall.providerExecuted,
|
|
3771
|
-
providerMetadata:
|
|
3573
|
+
providerMetadata: mergeToolProviderMetadata(
|
|
3574
|
+
(_b = tools == null ? void 0 : tools[toolCall.toolName]) == null ? void 0 : _b.providerMetadata,
|
|
3575
|
+
toolCall.providerMetadata
|
|
3576
|
+
)
|
|
3772
3577
|
};
|
|
3773
3578
|
}
|
|
3774
3579
|
}
|
|
@@ -3815,13 +3620,17 @@ async function doParseToolCall({
|
|
|
3815
3620
|
cause: parseResult.error
|
|
3816
3621
|
});
|
|
3817
3622
|
}
|
|
3623
|
+
const mergedProviderMetadata = mergeToolProviderMetadata(
|
|
3624
|
+
tool2.providerMetadata,
|
|
3625
|
+
toolCall.providerMetadata
|
|
3626
|
+
);
|
|
3818
3627
|
return tool2.type === "dynamic" ? {
|
|
3819
3628
|
type: "tool-call",
|
|
3820
3629
|
toolCallId: toolCall.toolCallId,
|
|
3821
3630
|
toolName: toolCall.toolName,
|
|
3822
3631
|
input: parseResult.value,
|
|
3823
3632
|
providerExecuted: toolCall.providerExecuted,
|
|
3824
|
-
providerMetadata:
|
|
3633
|
+
providerMetadata: mergedProviderMetadata,
|
|
3825
3634
|
dynamic: true,
|
|
3826
3635
|
title: tool2.title
|
|
3827
3636
|
} : {
|
|
@@ -3830,12 +3639,18 @@ async function doParseToolCall({
|
|
|
3830
3639
|
toolName,
|
|
3831
3640
|
input: parseResult.value,
|
|
3832
3641
|
providerExecuted: toolCall.providerExecuted,
|
|
3833
|
-
providerMetadata:
|
|
3642
|
+
providerMetadata: mergedProviderMetadata,
|
|
3834
3643
|
title: tool2.title
|
|
3835
3644
|
};
|
|
3836
3645
|
}
|
|
3837
3646
|
|
|
3838
3647
|
// src/generate-text/reasoning-output.ts
|
|
3648
|
+
function unwrapReasoningFileData(data) {
|
|
3649
|
+
if (typeof data === "object" && data !== null && "type" in data) {
|
|
3650
|
+
return data.type === "data" ? data.data : data.url;
|
|
3651
|
+
}
|
|
3652
|
+
return data;
|
|
3653
|
+
}
|
|
3839
3654
|
function convertFromReasoningOutputs(parts) {
|
|
3840
3655
|
return parts.map((part) => {
|
|
3841
3656
|
if (part.type === "reasoning") {
|
|
@@ -3862,10 +3677,12 @@ function convertToReasoningOutputs(parts) {
|
|
|
3862
3677
|
...part.providerOptions != null ? { providerMetadata: part.providerOptions } : {}
|
|
3863
3678
|
};
|
|
3864
3679
|
}
|
|
3680
|
+
const rawData = unwrapReasoningFileData(part.data);
|
|
3681
|
+
const fileData = rawData instanceof ArrayBuffer ? new Uint8Array(rawData) : rawData instanceof URL ? rawData.toString() : rawData;
|
|
3865
3682
|
return {
|
|
3866
3683
|
type: "reasoning-file",
|
|
3867
3684
|
file: new DefaultGeneratedFile({
|
|
3868
|
-
data:
|
|
3685
|
+
data: fileData,
|
|
3869
3686
|
mediaType: part.mediaType
|
|
3870
3687
|
}),
|
|
3871
3688
|
...part.providerOptions != null ? { providerMetadata: part.providerOptions } : {}
|
|
@@ -3887,6 +3704,40 @@ function mergeCallbacks(...callbacks) {
|
|
|
3887
3704
|
};
|
|
3888
3705
|
}
|
|
3889
3706
|
|
|
3707
|
+
// src/telemetry/diagnostic-channel.ts
|
|
3708
|
+
var AI_SDK_TELEMETRY_DIAGNOSTIC_CHANNEL = "aisdk:telemetry";
|
|
3709
|
+
|
|
3710
|
+
// src/util/is-node-runtime.ts
|
|
3711
|
+
function isNodeRuntime() {
|
|
3712
|
+
var _a21;
|
|
3713
|
+
return typeof process !== "undefined" && ((_a21 = process.release) == null ? void 0 : _a21.name) === "node";
|
|
3714
|
+
}
|
|
3715
|
+
|
|
3716
|
+
// src/telemetry/diagnostic-channel-publisher.ts
|
|
3717
|
+
var diagnosticsChannelPromise;
|
|
3718
|
+
async function loadDiagnosticsChannel() {
|
|
3719
|
+
if (!isNodeRuntime()) {
|
|
3720
|
+
return void 0;
|
|
3721
|
+
}
|
|
3722
|
+
if (diagnosticsChannelPromise == null) {
|
|
3723
|
+
diagnosticsChannelPromise = import(
|
|
3724
|
+
/* webpackIgnore: true */
|
|
3725
|
+
"diagnostics_channel"
|
|
3726
|
+
).catch(() => void 0);
|
|
3727
|
+
}
|
|
3728
|
+
return diagnosticsChannelPromise;
|
|
3729
|
+
}
|
|
3730
|
+
async function publishTelemetryDiagnosticChannelMessage(message) {
|
|
3731
|
+
const diagnosticsChannel = await loadDiagnosticsChannel();
|
|
3732
|
+
if ((diagnosticsChannel == null ? void 0 : diagnosticsChannel.hasSubscribers(AI_SDK_TELEMETRY_DIAGNOSTIC_CHANNEL)) !== true) {
|
|
3733
|
+
return;
|
|
3734
|
+
}
|
|
3735
|
+
try {
|
|
3736
|
+
diagnosticsChannel.channel(AI_SDK_TELEMETRY_DIAGNOSTIC_CHANNEL).publish(message);
|
|
3737
|
+
} catch (e) {
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3890
3741
|
// src/telemetry/telemetry-registry.ts
|
|
3891
3742
|
function registerTelemetry(...integrations) {
|
|
3892
3743
|
if (!globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) {
|
|
@@ -3921,7 +3772,12 @@ function createTelemetryDispatcher({
|
|
|
3921
3772
|
functionId: telemetry == null ? void 0 : telemetry.functionId
|
|
3922
3773
|
};
|
|
3923
3774
|
const mergeTelemetryCallback = (key) => {
|
|
3775
|
+
const publishDiagnosticChannelMessage = (event) => publishTelemetryDiagnosticChannelMessage({
|
|
3776
|
+
type: key,
|
|
3777
|
+
event: augmentEvent(event, telemetryMetadata)
|
|
3778
|
+
});
|
|
3924
3779
|
return mergeCallbacks(
|
|
3780
|
+
publishDiagnosticChannelMessage,
|
|
3925
3781
|
...integrations.map((integration) => {
|
|
3926
3782
|
var _a21;
|
|
3927
3783
|
return (_a21 = integration[key]) == null ? void 0 : _a21.bind(integration);
|
|
@@ -5199,7 +5055,10 @@ function asContent({
|
|
|
5199
5055
|
case "reasoning-file": {
|
|
5200
5056
|
contentParts.push({
|
|
5201
5057
|
type: part.type,
|
|
5202
|
-
file: new DefaultGeneratedFile(
|
|
5058
|
+
file: new DefaultGeneratedFile({
|
|
5059
|
+
data: part.data.type === "data" ? part.data.data : part.data.url.toString(),
|
|
5060
|
+
mediaType: part.mediaType
|
|
5061
|
+
}),
|
|
5203
5062
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
5204
5063
|
});
|
|
5205
5064
|
break;
|
|
@@ -5466,172 +5325,172 @@ function getResponseUIMessageId({
|
|
|
5466
5325
|
import { validateTypes as validateTypes2 } from "@ai-sdk/provider-utils";
|
|
5467
5326
|
|
|
5468
5327
|
// src/ui-message-stream/ui-message-chunks.ts
|
|
5469
|
-
import { z as
|
|
5328
|
+
import { z as z6 } from "zod/v4";
|
|
5470
5329
|
import { lazySchema, zodSchema } from "@ai-sdk/provider-utils";
|
|
5471
5330
|
var uiMessageChunkSchema = lazySchema(
|
|
5472
5331
|
() => zodSchema(
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
type:
|
|
5476
|
-
id:
|
|
5332
|
+
z6.union([
|
|
5333
|
+
z6.strictObject({
|
|
5334
|
+
type: z6.literal("text-start"),
|
|
5335
|
+
id: z6.string(),
|
|
5477
5336
|
providerMetadata: providerMetadataSchema.optional()
|
|
5478
5337
|
}),
|
|
5479
|
-
|
|
5480
|
-
type:
|
|
5481
|
-
id:
|
|
5482
|
-
delta:
|
|
5338
|
+
z6.strictObject({
|
|
5339
|
+
type: z6.literal("text-delta"),
|
|
5340
|
+
id: z6.string(),
|
|
5341
|
+
delta: z6.string(),
|
|
5483
5342
|
providerMetadata: providerMetadataSchema.optional()
|
|
5484
5343
|
}),
|
|
5485
|
-
|
|
5486
|
-
type:
|
|
5487
|
-
id:
|
|
5344
|
+
z6.strictObject({
|
|
5345
|
+
type: z6.literal("text-end"),
|
|
5346
|
+
id: z6.string(),
|
|
5488
5347
|
providerMetadata: providerMetadataSchema.optional()
|
|
5489
5348
|
}),
|
|
5490
|
-
|
|
5491
|
-
type:
|
|
5492
|
-
errorText:
|
|
5349
|
+
z6.strictObject({
|
|
5350
|
+
type: z6.literal("error"),
|
|
5351
|
+
errorText: z6.string()
|
|
5493
5352
|
}),
|
|
5494
|
-
|
|
5495
|
-
type:
|
|
5496
|
-
toolCallId:
|
|
5497
|
-
toolName:
|
|
5498
|
-
providerExecuted:
|
|
5353
|
+
z6.strictObject({
|
|
5354
|
+
type: z6.literal("tool-input-start"),
|
|
5355
|
+
toolCallId: z6.string(),
|
|
5356
|
+
toolName: z6.string(),
|
|
5357
|
+
providerExecuted: z6.boolean().optional(),
|
|
5499
5358
|
providerMetadata: providerMetadataSchema.optional(),
|
|
5500
|
-
dynamic:
|
|
5501
|
-
title:
|
|
5359
|
+
dynamic: z6.boolean().optional(),
|
|
5360
|
+
title: z6.string().optional()
|
|
5502
5361
|
}),
|
|
5503
|
-
|
|
5504
|
-
type:
|
|
5505
|
-
toolCallId:
|
|
5506
|
-
inputTextDelta:
|
|
5362
|
+
z6.strictObject({
|
|
5363
|
+
type: z6.literal("tool-input-delta"),
|
|
5364
|
+
toolCallId: z6.string(),
|
|
5365
|
+
inputTextDelta: z6.string()
|
|
5507
5366
|
}),
|
|
5508
|
-
|
|
5509
|
-
type:
|
|
5510
|
-
toolCallId:
|
|
5511
|
-
toolName:
|
|
5512
|
-
input:
|
|
5513
|
-
providerExecuted:
|
|
5367
|
+
z6.strictObject({
|
|
5368
|
+
type: z6.literal("tool-input-available"),
|
|
5369
|
+
toolCallId: z6.string(),
|
|
5370
|
+
toolName: z6.string(),
|
|
5371
|
+
input: z6.unknown(),
|
|
5372
|
+
providerExecuted: z6.boolean().optional(),
|
|
5514
5373
|
providerMetadata: providerMetadataSchema.optional(),
|
|
5515
|
-
dynamic:
|
|
5516
|
-
title:
|
|
5374
|
+
dynamic: z6.boolean().optional(),
|
|
5375
|
+
title: z6.string().optional()
|
|
5517
5376
|
}),
|
|
5518
|
-
|
|
5519
|
-
type:
|
|
5520
|
-
toolCallId:
|
|
5521
|
-
toolName:
|
|
5522
|
-
input:
|
|
5523
|
-
providerExecuted:
|
|
5377
|
+
z6.strictObject({
|
|
5378
|
+
type: z6.literal("tool-input-error"),
|
|
5379
|
+
toolCallId: z6.string(),
|
|
5380
|
+
toolName: z6.string(),
|
|
5381
|
+
input: z6.unknown(),
|
|
5382
|
+
providerExecuted: z6.boolean().optional(),
|
|
5524
5383
|
providerMetadata: providerMetadataSchema.optional(),
|
|
5525
|
-
dynamic:
|
|
5526
|
-
errorText:
|
|
5527
|
-
title:
|
|
5384
|
+
dynamic: z6.boolean().optional(),
|
|
5385
|
+
errorText: z6.string(),
|
|
5386
|
+
title: z6.string().optional()
|
|
5528
5387
|
}),
|
|
5529
|
-
|
|
5530
|
-
type:
|
|
5531
|
-
approvalId:
|
|
5532
|
-
toolCallId:
|
|
5533
|
-
isAutomatic:
|
|
5388
|
+
z6.strictObject({
|
|
5389
|
+
type: z6.literal("tool-approval-request"),
|
|
5390
|
+
approvalId: z6.string(),
|
|
5391
|
+
toolCallId: z6.string(),
|
|
5392
|
+
isAutomatic: z6.boolean().optional()
|
|
5534
5393
|
}),
|
|
5535
|
-
|
|
5536
|
-
type:
|
|
5537
|
-
approvalId:
|
|
5538
|
-
approved:
|
|
5539
|
-
reason:
|
|
5540
|
-
providerExecuted:
|
|
5394
|
+
z6.strictObject({
|
|
5395
|
+
type: z6.literal("tool-approval-response"),
|
|
5396
|
+
approvalId: z6.string(),
|
|
5397
|
+
approved: z6.boolean(),
|
|
5398
|
+
reason: z6.string().optional(),
|
|
5399
|
+
providerExecuted: z6.boolean().optional(),
|
|
5541
5400
|
providerMetadata: providerMetadataSchema.optional()
|
|
5542
5401
|
}),
|
|
5543
|
-
|
|
5544
|
-
type:
|
|
5545
|
-
toolCallId:
|
|
5546
|
-
output:
|
|
5547
|
-
providerExecuted:
|
|
5402
|
+
z6.strictObject({
|
|
5403
|
+
type: z6.literal("tool-output-available"),
|
|
5404
|
+
toolCallId: z6.string(),
|
|
5405
|
+
output: z6.unknown(),
|
|
5406
|
+
providerExecuted: z6.boolean().optional(),
|
|
5548
5407
|
providerMetadata: providerMetadataSchema.optional(),
|
|
5549
|
-
dynamic:
|
|
5550
|
-
preliminary:
|
|
5408
|
+
dynamic: z6.boolean().optional(),
|
|
5409
|
+
preliminary: z6.boolean().optional()
|
|
5551
5410
|
}),
|
|
5552
|
-
|
|
5553
|
-
type:
|
|
5554
|
-
toolCallId:
|
|
5555
|
-
errorText:
|
|
5556
|
-
providerExecuted:
|
|
5411
|
+
z6.strictObject({
|
|
5412
|
+
type: z6.literal("tool-output-error"),
|
|
5413
|
+
toolCallId: z6.string(),
|
|
5414
|
+
errorText: z6.string(),
|
|
5415
|
+
providerExecuted: z6.boolean().optional(),
|
|
5557
5416
|
providerMetadata: providerMetadataSchema.optional(),
|
|
5558
|
-
dynamic:
|
|
5417
|
+
dynamic: z6.boolean().optional()
|
|
5559
5418
|
}),
|
|
5560
|
-
|
|
5561
|
-
type:
|
|
5562
|
-
toolCallId:
|
|
5419
|
+
z6.strictObject({
|
|
5420
|
+
type: z6.literal("tool-output-denied"),
|
|
5421
|
+
toolCallId: z6.string()
|
|
5563
5422
|
}),
|
|
5564
|
-
|
|
5565
|
-
type:
|
|
5566
|
-
id:
|
|
5423
|
+
z6.strictObject({
|
|
5424
|
+
type: z6.literal("reasoning-start"),
|
|
5425
|
+
id: z6.string(),
|
|
5567
5426
|
providerMetadata: providerMetadataSchema.optional()
|
|
5568
5427
|
}),
|
|
5569
|
-
|
|
5570
|
-
type:
|
|
5571
|
-
id:
|
|
5572
|
-
delta:
|
|
5428
|
+
z6.strictObject({
|
|
5429
|
+
type: z6.literal("reasoning-delta"),
|
|
5430
|
+
id: z6.string(),
|
|
5431
|
+
delta: z6.string(),
|
|
5573
5432
|
providerMetadata: providerMetadataSchema.optional()
|
|
5574
5433
|
}),
|
|
5575
|
-
|
|
5576
|
-
type:
|
|
5577
|
-
id:
|
|
5434
|
+
z6.strictObject({
|
|
5435
|
+
type: z6.literal("reasoning-end"),
|
|
5436
|
+
id: z6.string(),
|
|
5578
5437
|
providerMetadata: providerMetadataSchema.optional()
|
|
5579
5438
|
}),
|
|
5580
|
-
|
|
5581
|
-
type:
|
|
5582
|
-
kind:
|
|
5439
|
+
z6.strictObject({
|
|
5440
|
+
type: z6.literal("custom"),
|
|
5441
|
+
kind: z6.string().transform((value) => value),
|
|
5583
5442
|
providerMetadata: providerMetadataSchema.optional()
|
|
5584
5443
|
}),
|
|
5585
|
-
|
|
5586
|
-
type:
|
|
5587
|
-
sourceId:
|
|
5588
|
-
url:
|
|
5589
|
-
title:
|
|
5444
|
+
z6.strictObject({
|
|
5445
|
+
type: z6.literal("source-url"),
|
|
5446
|
+
sourceId: z6.string(),
|
|
5447
|
+
url: z6.string(),
|
|
5448
|
+
title: z6.string().optional(),
|
|
5590
5449
|
providerMetadata: providerMetadataSchema.optional()
|
|
5591
5450
|
}),
|
|
5592
|
-
|
|
5593
|
-
type:
|
|
5594
|
-
sourceId:
|
|
5595
|
-
mediaType:
|
|
5596
|
-
title:
|
|
5597
|
-
filename:
|
|
5451
|
+
z6.strictObject({
|
|
5452
|
+
type: z6.literal("source-document"),
|
|
5453
|
+
sourceId: z6.string(),
|
|
5454
|
+
mediaType: z6.string(),
|
|
5455
|
+
title: z6.string(),
|
|
5456
|
+
filename: z6.string().optional(),
|
|
5598
5457
|
providerMetadata: providerMetadataSchema.optional()
|
|
5599
5458
|
}),
|
|
5600
|
-
|
|
5601
|
-
type:
|
|
5602
|
-
url:
|
|
5603
|
-
mediaType:
|
|
5459
|
+
z6.strictObject({
|
|
5460
|
+
type: z6.literal("file"),
|
|
5461
|
+
url: z6.string(),
|
|
5462
|
+
mediaType: z6.string(),
|
|
5604
5463
|
providerMetadata: providerMetadataSchema.optional()
|
|
5605
5464
|
}),
|
|
5606
|
-
|
|
5607
|
-
type:
|
|
5608
|
-
url:
|
|
5609
|
-
mediaType:
|
|
5465
|
+
z6.strictObject({
|
|
5466
|
+
type: z6.literal("reasoning-file"),
|
|
5467
|
+
url: z6.string(),
|
|
5468
|
+
mediaType: z6.string(),
|
|
5610
5469
|
providerMetadata: providerMetadataSchema.optional()
|
|
5611
5470
|
}),
|
|
5612
|
-
|
|
5613
|
-
type:
|
|
5471
|
+
z6.strictObject({
|
|
5472
|
+
type: z6.custom(
|
|
5614
5473
|
(value) => typeof value === "string" && value.startsWith("data-"),
|
|
5615
5474
|
{ message: 'Type must start with "data-"' }
|
|
5616
5475
|
),
|
|
5617
|
-
id:
|
|
5618
|
-
data:
|
|
5619
|
-
transient:
|
|
5476
|
+
id: z6.string().optional(),
|
|
5477
|
+
data: z6.unknown(),
|
|
5478
|
+
transient: z6.boolean().optional()
|
|
5620
5479
|
}),
|
|
5621
|
-
|
|
5622
|
-
type:
|
|
5480
|
+
z6.strictObject({
|
|
5481
|
+
type: z6.literal("start-step")
|
|
5623
5482
|
}),
|
|
5624
|
-
|
|
5625
|
-
type:
|
|
5483
|
+
z6.strictObject({
|
|
5484
|
+
type: z6.literal("finish-step")
|
|
5626
5485
|
}),
|
|
5627
|
-
|
|
5628
|
-
type:
|
|
5629
|
-
messageId:
|
|
5630
|
-
messageMetadata:
|
|
5486
|
+
z6.strictObject({
|
|
5487
|
+
type: z6.literal("start"),
|
|
5488
|
+
messageId: z6.string().optional(),
|
|
5489
|
+
messageMetadata: z6.unknown().optional()
|
|
5631
5490
|
}),
|
|
5632
|
-
|
|
5633
|
-
type:
|
|
5634
|
-
finishReason:
|
|
5491
|
+
z6.strictObject({
|
|
5492
|
+
type: z6.literal("finish"),
|
|
5493
|
+
finishReason: z6.enum([
|
|
5635
5494
|
"stop",
|
|
5636
5495
|
"length",
|
|
5637
5496
|
"content-filter",
|
|
@@ -5639,15 +5498,15 @@ var uiMessageChunkSchema = lazySchema(
|
|
|
5639
5498
|
"error",
|
|
5640
5499
|
"other"
|
|
5641
5500
|
]).optional(),
|
|
5642
|
-
messageMetadata:
|
|
5501
|
+
messageMetadata: z6.unknown().optional()
|
|
5643
5502
|
}),
|
|
5644
|
-
|
|
5645
|
-
type:
|
|
5646
|
-
reason:
|
|
5503
|
+
z6.strictObject({
|
|
5504
|
+
type: z6.literal("abort"),
|
|
5505
|
+
reason: z6.string().optional()
|
|
5647
5506
|
}),
|
|
5648
|
-
|
|
5649
|
-
type:
|
|
5650
|
-
messageMetadata:
|
|
5507
|
+
z6.strictObject({
|
|
5508
|
+
type: z6.literal("message-metadata"),
|
|
5509
|
+
messageMetadata: z6.unknown()
|
|
5651
5510
|
})
|
|
5652
5511
|
])
|
|
5653
5512
|
)
|
|
@@ -6989,7 +6848,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
|
|
|
6989
6848
|
case "file":
|
|
6990
6849
|
case "reasoning-file": {
|
|
6991
6850
|
const file = new DefaultGeneratedFileWithType({
|
|
6992
|
-
data: chunk.data,
|
|
6851
|
+
data: chunk.data.type === "data" ? chunk.data.data : chunk.data.url.toString(),
|
|
6993
6852
|
mediaType: chunk.mediaType
|
|
6994
6853
|
});
|
|
6995
6854
|
modelCallContent.push({
|
|
@@ -7903,6 +7762,7 @@ var DefaultStreamTextResult = class {
|
|
|
7903
7762
|
toolChoice: (_b2 = prepareStepResult == null ? void 0 : prepareStepResult.toolChoice) != null ? _b2 : toolChoice,
|
|
7904
7763
|
system: stepSystem,
|
|
7905
7764
|
messages: stepMessages,
|
|
7765
|
+
allowSystemInMessages,
|
|
7906
7766
|
repairToolCall,
|
|
7907
7767
|
abortSignal,
|
|
7908
7768
|
headers,
|
|
@@ -9072,7 +8932,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9072
8932
|
modelMessages.push({
|
|
9073
8933
|
role: "user",
|
|
9074
8934
|
content: message.parts.map((part) => {
|
|
9075
|
-
var _a21
|
|
8935
|
+
var _a21;
|
|
9076
8936
|
if (isTextUIPart(part)) {
|
|
9077
8937
|
return {
|
|
9078
8938
|
type: "text",
|
|
@@ -9085,12 +8945,15 @@ async function convertToModelMessages(messages, options) {
|
|
|
9085
8945
|
type: "file",
|
|
9086
8946
|
mediaType: part.mediaType,
|
|
9087
8947
|
filename: part.filename,
|
|
9088
|
-
data:
|
|
8948
|
+
data: part.providerReference != null ? {
|
|
8949
|
+
type: "reference",
|
|
8950
|
+
reference: part.providerReference
|
|
8951
|
+
} : { type: "url", url: new URL(part.url) },
|
|
9089
8952
|
...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}
|
|
9090
8953
|
};
|
|
9091
8954
|
}
|
|
9092
8955
|
if (isDataUIPart(part)) {
|
|
9093
|
-
return (
|
|
8956
|
+
return (_a21 = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _a21.call(
|
|
9094
8957
|
options,
|
|
9095
8958
|
part
|
|
9096
8959
|
);
|
|
@@ -9103,7 +8966,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9103
8966
|
if (message.parts != null) {
|
|
9104
8967
|
let block = [];
|
|
9105
8968
|
async function processBlock() {
|
|
9106
|
-
var _a21, _b, _c, _d, _e, _f, _g, _h
|
|
8969
|
+
var _a21, _b, _c, _d, _e, _f, _g, _h;
|
|
9107
8970
|
if (block.length === 0) {
|
|
9108
8971
|
return;
|
|
9109
8972
|
}
|
|
@@ -9126,13 +8989,16 @@ async function convertToModelMessages(messages, options) {
|
|
|
9126
8989
|
type: "file",
|
|
9127
8990
|
mediaType: part.mediaType,
|
|
9128
8991
|
filename: part.filename,
|
|
9129
|
-
data:
|
|
8992
|
+
data: part.providerReference != null ? {
|
|
8993
|
+
type: "reference",
|
|
8994
|
+
reference: part.providerReference
|
|
8995
|
+
} : { type: "url", url: new URL(part.url) },
|
|
9130
8996
|
...part.providerMetadata != null ? { providerOptions: part.providerMetadata } : {}
|
|
9131
8997
|
});
|
|
9132
8998
|
} else if (isReasoningFileUIPart(part)) {
|
|
9133
8999
|
content.push({
|
|
9134
9000
|
type: "reasoning-file",
|
|
9135
|
-
data: part.url,
|
|
9001
|
+
data: { type: "url", url: new URL(part.url) },
|
|
9136
9002
|
mediaType: part.mediaType,
|
|
9137
9003
|
providerOptions: part.providerMetadata
|
|
9138
9004
|
});
|
|
@@ -9149,7 +9015,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9149
9015
|
type: "tool-call",
|
|
9150
9016
|
toolCallId: part.toolCallId,
|
|
9151
9017
|
toolName,
|
|
9152
|
-
input: part.state === "output-error" ? (
|
|
9018
|
+
input: part.state === "output-error" ? (_a21 = part.input) != null ? _a21 : "rawInput" in part ? part.rawInput : void 0 : part.input,
|
|
9153
9019
|
providerExecuted: part.providerExecuted,
|
|
9154
9020
|
...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
|
|
9155
9021
|
});
|
|
@@ -9162,7 +9028,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9162
9028
|
});
|
|
9163
9029
|
}
|
|
9164
9030
|
if (part.providerExecuted === true && part.state !== "approval-responded" && (part.state === "output-available" || part.state === "output-error")) {
|
|
9165
|
-
const resultProviderMetadata = (
|
|
9031
|
+
const resultProviderMetadata = (_b = part.resultProviderMetadata) != null ? _b : part.callProviderMetadata;
|
|
9166
9032
|
content.push({
|
|
9167
9033
|
type: "tool-result",
|
|
9168
9034
|
toolCallId: part.toolCallId,
|
|
@@ -9171,7 +9037,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9171
9037
|
toolCallId: part.toolCallId,
|
|
9172
9038
|
input: part.input,
|
|
9173
9039
|
output: part.state === "output-error" ? part.errorText : part.output,
|
|
9174
|
-
tool: (
|
|
9040
|
+
tool: (_c = options == null ? void 0 : options.tools) == null ? void 0 : _c[toolName],
|
|
9175
9041
|
errorMode: part.state === "output-error" ? "json" : "none"
|
|
9176
9042
|
}),
|
|
9177
9043
|
...resultProviderMetadata != null ? { providerOptions: resultProviderMetadata } : {}
|
|
@@ -9179,7 +9045,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9179
9045
|
}
|
|
9180
9046
|
}
|
|
9181
9047
|
} else if (isDataUIPart(part)) {
|
|
9182
|
-
const dataPart = (
|
|
9048
|
+
const dataPart = (_d = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _d.call(
|
|
9183
9049
|
options,
|
|
9184
9050
|
part
|
|
9185
9051
|
);
|
|
@@ -9205,7 +9071,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9205
9071
|
{
|
|
9206
9072
|
const content2 = [];
|
|
9207
9073
|
for (const toolPart of toolParts) {
|
|
9208
|
-
if (((
|
|
9074
|
+
if (((_e = toolPart.approval) == null ? void 0 : _e.approved) != null) {
|
|
9209
9075
|
content2.push({
|
|
9210
9076
|
type: "tool-approval-response",
|
|
9211
9077
|
approvalId: toolPart.approval.id,
|
|
@@ -9214,7 +9080,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9214
9080
|
providerExecuted: toolPart.providerExecuted
|
|
9215
9081
|
});
|
|
9216
9082
|
}
|
|
9217
|
-
if (toolPart.state === "approval-responded" && ((
|
|
9083
|
+
if (toolPart.state === "approval-responded" && ((_f = toolPart.approval) == null ? void 0 : _f.approved) === false) {
|
|
9218
9084
|
content2.push({
|
|
9219
9085
|
type: "tool-result",
|
|
9220
9086
|
toolCallId: toolPart.toolCallId,
|
|
@@ -9237,7 +9103,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9237
9103
|
toolName: getToolName(toolPart),
|
|
9238
9104
|
output: {
|
|
9239
9105
|
type: "error-text",
|
|
9240
|
-
value: (
|
|
9106
|
+
value: (_g = toolPart.approval.reason) != null ? _g : "Tool call execution denied."
|
|
9241
9107
|
},
|
|
9242
9108
|
...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}
|
|
9243
9109
|
});
|
|
@@ -9254,7 +9120,7 @@ async function convertToModelMessages(messages, options) {
|
|
|
9254
9120
|
toolCallId: toolPart.toolCallId,
|
|
9255
9121
|
input: toolPart.input,
|
|
9256
9122
|
output: toolPart.state === "output-error" ? toolPart.errorText : toolPart.output,
|
|
9257
|
-
tool: (
|
|
9123
|
+
tool: (_h = options == null ? void 0 : options.tools) == null ? void 0 : _h[toolName],
|
|
9258
9124
|
errorMode: toolPart.state === "output-error" ? "text" : "none"
|
|
9259
9125
|
}),
|
|
9260
9126
|
...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}
|
|
@@ -9304,286 +9170,286 @@ import {
|
|
|
9304
9170
|
validateTypes as validateTypes4,
|
|
9305
9171
|
zodSchema as zodSchema2
|
|
9306
9172
|
} from "@ai-sdk/provider-utils";
|
|
9307
|
-
import { z as
|
|
9173
|
+
import { z as z7 } from "zod/v4";
|
|
9308
9174
|
var uiMessagesSchema = lazySchema2(
|
|
9309
9175
|
() => zodSchema2(
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
id:
|
|
9313
|
-
role:
|
|
9314
|
-
metadata:
|
|
9315
|
-
parts:
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
type:
|
|
9319
|
-
text:
|
|
9320
|
-
state:
|
|
9176
|
+
z7.array(
|
|
9177
|
+
z7.object({
|
|
9178
|
+
id: z7.string(),
|
|
9179
|
+
role: z7.enum(["system", "user", "assistant"]),
|
|
9180
|
+
metadata: z7.unknown().optional(),
|
|
9181
|
+
parts: z7.array(
|
|
9182
|
+
z7.union([
|
|
9183
|
+
z7.object({
|
|
9184
|
+
type: z7.literal("text"),
|
|
9185
|
+
text: z7.string(),
|
|
9186
|
+
state: z7.enum(["streaming", "done"]).optional(),
|
|
9321
9187
|
providerMetadata: providerMetadataSchema.optional()
|
|
9322
9188
|
}),
|
|
9323
|
-
|
|
9324
|
-
type:
|
|
9325
|
-
text:
|
|
9326
|
-
state:
|
|
9189
|
+
z7.object({
|
|
9190
|
+
type: z7.literal("reasoning"),
|
|
9191
|
+
text: z7.string(),
|
|
9192
|
+
state: z7.enum(["streaming", "done"]).optional(),
|
|
9327
9193
|
providerMetadata: providerMetadataSchema.optional()
|
|
9328
9194
|
}),
|
|
9329
|
-
|
|
9330
|
-
type:
|
|
9331
|
-
kind:
|
|
9195
|
+
z7.object({
|
|
9196
|
+
type: z7.literal("custom"),
|
|
9197
|
+
kind: z7.string(),
|
|
9332
9198
|
providerMetadata: providerMetadataSchema.optional()
|
|
9333
9199
|
}),
|
|
9334
|
-
|
|
9335
|
-
type:
|
|
9336
|
-
sourceId:
|
|
9337
|
-
url:
|
|
9338
|
-
title:
|
|
9200
|
+
z7.object({
|
|
9201
|
+
type: z7.literal("source-url"),
|
|
9202
|
+
sourceId: z7.string(),
|
|
9203
|
+
url: z7.string(),
|
|
9204
|
+
title: z7.string().optional(),
|
|
9339
9205
|
providerMetadata: providerMetadataSchema.optional()
|
|
9340
9206
|
}),
|
|
9341
|
-
|
|
9342
|
-
type:
|
|
9343
|
-
sourceId:
|
|
9344
|
-
mediaType:
|
|
9345
|
-
title:
|
|
9346
|
-
filename:
|
|
9207
|
+
z7.object({
|
|
9208
|
+
type: z7.literal("source-document"),
|
|
9209
|
+
sourceId: z7.string(),
|
|
9210
|
+
mediaType: z7.string(),
|
|
9211
|
+
title: z7.string(),
|
|
9212
|
+
filename: z7.string().optional(),
|
|
9347
9213
|
providerMetadata: providerMetadataSchema.optional()
|
|
9348
9214
|
}),
|
|
9349
|
-
|
|
9350
|
-
type:
|
|
9351
|
-
mediaType:
|
|
9352
|
-
filename:
|
|
9353
|
-
url:
|
|
9215
|
+
z7.object({
|
|
9216
|
+
type: z7.literal("file"),
|
|
9217
|
+
mediaType: z7.string(),
|
|
9218
|
+
filename: z7.string().optional(),
|
|
9219
|
+
url: z7.string(),
|
|
9354
9220
|
providerMetadata: providerMetadataSchema.optional()
|
|
9355
9221
|
}),
|
|
9356
|
-
|
|
9357
|
-
type:
|
|
9358
|
-
mediaType:
|
|
9359
|
-
url:
|
|
9222
|
+
z7.object({
|
|
9223
|
+
type: z7.literal("reasoning-file"),
|
|
9224
|
+
mediaType: z7.string(),
|
|
9225
|
+
url: z7.string(),
|
|
9360
9226
|
providerMetadata: providerMetadataSchema.optional()
|
|
9361
9227
|
}),
|
|
9362
|
-
|
|
9363
|
-
type:
|
|
9228
|
+
z7.object({
|
|
9229
|
+
type: z7.literal("step-start")
|
|
9364
9230
|
}),
|
|
9365
|
-
|
|
9366
|
-
type:
|
|
9367
|
-
id:
|
|
9368
|
-
data:
|
|
9231
|
+
z7.object({
|
|
9232
|
+
type: z7.string().startsWith("data-"),
|
|
9233
|
+
id: z7.string().optional(),
|
|
9234
|
+
data: z7.unknown()
|
|
9369
9235
|
}),
|
|
9370
|
-
|
|
9371
|
-
type:
|
|
9372
|
-
toolName:
|
|
9373
|
-
toolCallId:
|
|
9374
|
-
state:
|
|
9375
|
-
input:
|
|
9376
|
-
providerExecuted:
|
|
9236
|
+
z7.object({
|
|
9237
|
+
type: z7.literal("dynamic-tool"),
|
|
9238
|
+
toolName: z7.string(),
|
|
9239
|
+
toolCallId: z7.string(),
|
|
9240
|
+
state: z7.literal("input-streaming"),
|
|
9241
|
+
input: z7.unknown().optional(),
|
|
9242
|
+
providerExecuted: z7.boolean().optional(),
|
|
9377
9243
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9378
|
-
output:
|
|
9379
|
-
errorText:
|
|
9380
|
-
approval:
|
|
9244
|
+
output: z7.never().optional(),
|
|
9245
|
+
errorText: z7.never().optional(),
|
|
9246
|
+
approval: z7.never().optional()
|
|
9381
9247
|
}),
|
|
9382
|
-
|
|
9383
|
-
type:
|
|
9384
|
-
toolName:
|
|
9385
|
-
toolCallId:
|
|
9386
|
-
state:
|
|
9387
|
-
input:
|
|
9388
|
-
providerExecuted:
|
|
9389
|
-
output:
|
|
9390
|
-
errorText:
|
|
9248
|
+
z7.object({
|
|
9249
|
+
type: z7.literal("dynamic-tool"),
|
|
9250
|
+
toolName: z7.string(),
|
|
9251
|
+
toolCallId: z7.string(),
|
|
9252
|
+
state: z7.literal("input-available"),
|
|
9253
|
+
input: z7.unknown(),
|
|
9254
|
+
providerExecuted: z7.boolean().optional(),
|
|
9255
|
+
output: z7.never().optional(),
|
|
9256
|
+
errorText: z7.never().optional(),
|
|
9391
9257
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9392
|
-
approval:
|
|
9258
|
+
approval: z7.never().optional()
|
|
9393
9259
|
}),
|
|
9394
|
-
|
|
9395
|
-
type:
|
|
9396
|
-
toolName:
|
|
9397
|
-
toolCallId:
|
|
9398
|
-
state:
|
|
9399
|
-
input:
|
|
9400
|
-
providerExecuted:
|
|
9401
|
-
output:
|
|
9402
|
-
errorText:
|
|
9260
|
+
z7.object({
|
|
9261
|
+
type: z7.literal("dynamic-tool"),
|
|
9262
|
+
toolName: z7.string(),
|
|
9263
|
+
toolCallId: z7.string(),
|
|
9264
|
+
state: z7.literal("approval-requested"),
|
|
9265
|
+
input: z7.unknown(),
|
|
9266
|
+
providerExecuted: z7.boolean().optional(),
|
|
9267
|
+
output: z7.never().optional(),
|
|
9268
|
+
errorText: z7.never().optional(),
|
|
9403
9269
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9404
|
-
approval:
|
|
9405
|
-
id:
|
|
9406
|
-
approved:
|
|
9407
|
-
reason:
|
|
9408
|
-
isAutomatic:
|
|
9270
|
+
approval: z7.object({
|
|
9271
|
+
id: z7.string(),
|
|
9272
|
+
approved: z7.never().optional(),
|
|
9273
|
+
reason: z7.never().optional(),
|
|
9274
|
+
isAutomatic: z7.boolean().optional()
|
|
9409
9275
|
})
|
|
9410
9276
|
}),
|
|
9411
|
-
|
|
9412
|
-
type:
|
|
9413
|
-
toolName:
|
|
9414
|
-
toolCallId:
|
|
9415
|
-
state:
|
|
9416
|
-
input:
|
|
9417
|
-
providerExecuted:
|
|
9418
|
-
output:
|
|
9419
|
-
errorText:
|
|
9277
|
+
z7.object({
|
|
9278
|
+
type: z7.literal("dynamic-tool"),
|
|
9279
|
+
toolName: z7.string(),
|
|
9280
|
+
toolCallId: z7.string(),
|
|
9281
|
+
state: z7.literal("approval-responded"),
|
|
9282
|
+
input: z7.unknown(),
|
|
9283
|
+
providerExecuted: z7.boolean().optional(),
|
|
9284
|
+
output: z7.never().optional(),
|
|
9285
|
+
errorText: z7.never().optional(),
|
|
9420
9286
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9421
|
-
approval:
|
|
9422
|
-
id:
|
|
9423
|
-
approved:
|
|
9424
|
-
reason:
|
|
9425
|
-
isAutomatic:
|
|
9287
|
+
approval: z7.object({
|
|
9288
|
+
id: z7.string(),
|
|
9289
|
+
approved: z7.boolean(),
|
|
9290
|
+
reason: z7.string().optional(),
|
|
9291
|
+
isAutomatic: z7.boolean().optional()
|
|
9426
9292
|
})
|
|
9427
9293
|
}),
|
|
9428
|
-
|
|
9429
|
-
type:
|
|
9430
|
-
toolName:
|
|
9431
|
-
toolCallId:
|
|
9432
|
-
state:
|
|
9433
|
-
input:
|
|
9434
|
-
providerExecuted:
|
|
9435
|
-
output:
|
|
9436
|
-
errorText:
|
|
9294
|
+
z7.object({
|
|
9295
|
+
type: z7.literal("dynamic-tool"),
|
|
9296
|
+
toolName: z7.string(),
|
|
9297
|
+
toolCallId: z7.string(),
|
|
9298
|
+
state: z7.literal("output-available"),
|
|
9299
|
+
input: z7.unknown(),
|
|
9300
|
+
providerExecuted: z7.boolean().optional(),
|
|
9301
|
+
output: z7.unknown(),
|
|
9302
|
+
errorText: z7.never().optional(),
|
|
9437
9303
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9438
9304
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9439
|
-
preliminary:
|
|
9440
|
-
approval:
|
|
9441
|
-
id:
|
|
9442
|
-
approved:
|
|
9443
|
-
reason:
|
|
9444
|
-
isAutomatic:
|
|
9305
|
+
preliminary: z7.boolean().optional(),
|
|
9306
|
+
approval: z7.object({
|
|
9307
|
+
id: z7.string(),
|
|
9308
|
+
approved: z7.literal(true),
|
|
9309
|
+
reason: z7.string().optional(),
|
|
9310
|
+
isAutomatic: z7.boolean().optional()
|
|
9445
9311
|
}).optional()
|
|
9446
9312
|
}),
|
|
9447
|
-
|
|
9448
|
-
type:
|
|
9449
|
-
toolName:
|
|
9450
|
-
toolCallId:
|
|
9451
|
-
state:
|
|
9452
|
-
input:
|
|
9453
|
-
rawInput:
|
|
9454
|
-
providerExecuted:
|
|
9455
|
-
output:
|
|
9456
|
-
errorText:
|
|
9313
|
+
z7.object({
|
|
9314
|
+
type: z7.literal("dynamic-tool"),
|
|
9315
|
+
toolName: z7.string(),
|
|
9316
|
+
toolCallId: z7.string(),
|
|
9317
|
+
state: z7.literal("output-error"),
|
|
9318
|
+
input: z7.unknown(),
|
|
9319
|
+
rawInput: z7.unknown().optional(),
|
|
9320
|
+
providerExecuted: z7.boolean().optional(),
|
|
9321
|
+
output: z7.never().optional(),
|
|
9322
|
+
errorText: z7.string(),
|
|
9457
9323
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9458
9324
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9459
|
-
approval:
|
|
9460
|
-
id:
|
|
9461
|
-
approved:
|
|
9462
|
-
reason:
|
|
9463
|
-
isAutomatic:
|
|
9325
|
+
approval: z7.object({
|
|
9326
|
+
id: z7.string(),
|
|
9327
|
+
approved: z7.literal(true),
|
|
9328
|
+
reason: z7.string().optional(),
|
|
9329
|
+
isAutomatic: z7.boolean().optional()
|
|
9464
9330
|
}).optional()
|
|
9465
9331
|
}),
|
|
9466
|
-
|
|
9467
|
-
type:
|
|
9468
|
-
toolName:
|
|
9469
|
-
toolCallId:
|
|
9470
|
-
state:
|
|
9471
|
-
input:
|
|
9472
|
-
providerExecuted:
|
|
9473
|
-
output:
|
|
9474
|
-
errorText:
|
|
9332
|
+
z7.object({
|
|
9333
|
+
type: z7.literal("dynamic-tool"),
|
|
9334
|
+
toolName: z7.string(),
|
|
9335
|
+
toolCallId: z7.string(),
|
|
9336
|
+
state: z7.literal("output-denied"),
|
|
9337
|
+
input: z7.unknown(),
|
|
9338
|
+
providerExecuted: z7.boolean().optional(),
|
|
9339
|
+
output: z7.never().optional(),
|
|
9340
|
+
errorText: z7.never().optional(),
|
|
9475
9341
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9476
|
-
approval:
|
|
9477
|
-
id:
|
|
9478
|
-
approved:
|
|
9479
|
-
reason:
|
|
9480
|
-
isAutomatic:
|
|
9342
|
+
approval: z7.object({
|
|
9343
|
+
id: z7.string(),
|
|
9344
|
+
approved: z7.literal(false),
|
|
9345
|
+
reason: z7.string().optional(),
|
|
9346
|
+
isAutomatic: z7.boolean().optional()
|
|
9481
9347
|
})
|
|
9482
9348
|
}),
|
|
9483
|
-
|
|
9484
|
-
type:
|
|
9485
|
-
toolCallId:
|
|
9486
|
-
state:
|
|
9487
|
-
providerExecuted:
|
|
9349
|
+
z7.object({
|
|
9350
|
+
type: z7.string().startsWith("tool-"),
|
|
9351
|
+
toolCallId: z7.string(),
|
|
9352
|
+
state: z7.literal("input-streaming"),
|
|
9353
|
+
providerExecuted: z7.boolean().optional(),
|
|
9488
9354
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9489
|
-
input:
|
|
9490
|
-
output:
|
|
9491
|
-
errorText:
|
|
9492
|
-
approval:
|
|
9355
|
+
input: z7.unknown().optional(),
|
|
9356
|
+
output: z7.never().optional(),
|
|
9357
|
+
errorText: z7.never().optional(),
|
|
9358
|
+
approval: z7.never().optional()
|
|
9493
9359
|
}),
|
|
9494
|
-
|
|
9495
|
-
type:
|
|
9496
|
-
toolCallId:
|
|
9497
|
-
state:
|
|
9498
|
-
providerExecuted:
|
|
9499
|
-
input:
|
|
9500
|
-
output:
|
|
9501
|
-
errorText:
|
|
9360
|
+
z7.object({
|
|
9361
|
+
type: z7.string().startsWith("tool-"),
|
|
9362
|
+
toolCallId: z7.string(),
|
|
9363
|
+
state: z7.literal("input-available"),
|
|
9364
|
+
providerExecuted: z7.boolean().optional(),
|
|
9365
|
+
input: z7.unknown(),
|
|
9366
|
+
output: z7.never().optional(),
|
|
9367
|
+
errorText: z7.never().optional(),
|
|
9502
9368
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9503
|
-
approval:
|
|
9369
|
+
approval: z7.never().optional()
|
|
9504
9370
|
}),
|
|
9505
|
-
|
|
9506
|
-
type:
|
|
9507
|
-
toolCallId:
|
|
9508
|
-
state:
|
|
9509
|
-
input:
|
|
9510
|
-
providerExecuted:
|
|
9511
|
-
output:
|
|
9512
|
-
errorText:
|
|
9371
|
+
z7.object({
|
|
9372
|
+
type: z7.string().startsWith("tool-"),
|
|
9373
|
+
toolCallId: z7.string(),
|
|
9374
|
+
state: z7.literal("approval-requested"),
|
|
9375
|
+
input: z7.unknown(),
|
|
9376
|
+
providerExecuted: z7.boolean().optional(),
|
|
9377
|
+
output: z7.never().optional(),
|
|
9378
|
+
errorText: z7.never().optional(),
|
|
9513
9379
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9514
|
-
approval:
|
|
9515
|
-
id:
|
|
9516
|
-
approved:
|
|
9517
|
-
reason:
|
|
9518
|
-
isAutomatic:
|
|
9380
|
+
approval: z7.object({
|
|
9381
|
+
id: z7.string(),
|
|
9382
|
+
approved: z7.never().optional(),
|
|
9383
|
+
reason: z7.never().optional(),
|
|
9384
|
+
isAutomatic: z7.boolean().optional()
|
|
9519
9385
|
})
|
|
9520
9386
|
}),
|
|
9521
|
-
|
|
9522
|
-
type:
|
|
9523
|
-
toolCallId:
|
|
9524
|
-
state:
|
|
9525
|
-
input:
|
|
9526
|
-
providerExecuted:
|
|
9527
|
-
output:
|
|
9528
|
-
errorText:
|
|
9387
|
+
z7.object({
|
|
9388
|
+
type: z7.string().startsWith("tool-"),
|
|
9389
|
+
toolCallId: z7.string(),
|
|
9390
|
+
state: z7.literal("approval-responded"),
|
|
9391
|
+
input: z7.unknown(),
|
|
9392
|
+
providerExecuted: z7.boolean().optional(),
|
|
9393
|
+
output: z7.never().optional(),
|
|
9394
|
+
errorText: z7.never().optional(),
|
|
9529
9395
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9530
|
-
approval:
|
|
9531
|
-
id:
|
|
9532
|
-
approved:
|
|
9533
|
-
reason:
|
|
9534
|
-
isAutomatic:
|
|
9396
|
+
approval: z7.object({
|
|
9397
|
+
id: z7.string(),
|
|
9398
|
+
approved: z7.boolean(),
|
|
9399
|
+
reason: z7.string().optional(),
|
|
9400
|
+
isAutomatic: z7.boolean().optional()
|
|
9535
9401
|
})
|
|
9536
9402
|
}),
|
|
9537
|
-
|
|
9538
|
-
type:
|
|
9539
|
-
toolCallId:
|
|
9540
|
-
state:
|
|
9541
|
-
providerExecuted:
|
|
9542
|
-
input:
|
|
9543
|
-
output:
|
|
9544
|
-
errorText:
|
|
9403
|
+
z7.object({
|
|
9404
|
+
type: z7.string().startsWith("tool-"),
|
|
9405
|
+
toolCallId: z7.string(),
|
|
9406
|
+
state: z7.literal("output-available"),
|
|
9407
|
+
providerExecuted: z7.boolean().optional(),
|
|
9408
|
+
input: z7.unknown(),
|
|
9409
|
+
output: z7.unknown(),
|
|
9410
|
+
errorText: z7.never().optional(),
|
|
9545
9411
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9546
9412
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9547
|
-
preliminary:
|
|
9548
|
-
approval:
|
|
9549
|
-
id:
|
|
9550
|
-
approved:
|
|
9551
|
-
reason:
|
|
9552
|
-
isAutomatic:
|
|
9413
|
+
preliminary: z7.boolean().optional(),
|
|
9414
|
+
approval: z7.object({
|
|
9415
|
+
id: z7.string(),
|
|
9416
|
+
approved: z7.literal(true),
|
|
9417
|
+
reason: z7.string().optional(),
|
|
9418
|
+
isAutomatic: z7.boolean().optional()
|
|
9553
9419
|
}).optional()
|
|
9554
9420
|
}),
|
|
9555
|
-
|
|
9556
|
-
type:
|
|
9557
|
-
toolCallId:
|
|
9558
|
-
state:
|
|
9559
|
-
providerExecuted:
|
|
9560
|
-
input:
|
|
9561
|
-
rawInput:
|
|
9562
|
-
output:
|
|
9563
|
-
errorText:
|
|
9421
|
+
z7.object({
|
|
9422
|
+
type: z7.string().startsWith("tool-"),
|
|
9423
|
+
toolCallId: z7.string(),
|
|
9424
|
+
state: z7.literal("output-error"),
|
|
9425
|
+
providerExecuted: z7.boolean().optional(),
|
|
9426
|
+
input: z7.unknown(),
|
|
9427
|
+
rawInput: z7.unknown().optional(),
|
|
9428
|
+
output: z7.never().optional(),
|
|
9429
|
+
errorText: z7.string(),
|
|
9564
9430
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9565
9431
|
resultProviderMetadata: providerMetadataSchema.optional(),
|
|
9566
|
-
approval:
|
|
9567
|
-
id:
|
|
9568
|
-
approved:
|
|
9569
|
-
reason:
|
|
9570
|
-
isAutomatic:
|
|
9432
|
+
approval: z7.object({
|
|
9433
|
+
id: z7.string(),
|
|
9434
|
+
approved: z7.literal(true),
|
|
9435
|
+
reason: z7.string().optional(),
|
|
9436
|
+
isAutomatic: z7.boolean().optional()
|
|
9571
9437
|
}).optional()
|
|
9572
9438
|
}),
|
|
9573
|
-
|
|
9574
|
-
type:
|
|
9575
|
-
toolCallId:
|
|
9576
|
-
state:
|
|
9577
|
-
providerExecuted:
|
|
9578
|
-
input:
|
|
9579
|
-
output:
|
|
9580
|
-
errorText:
|
|
9439
|
+
z7.object({
|
|
9440
|
+
type: z7.string().startsWith("tool-"),
|
|
9441
|
+
toolCallId: z7.string(),
|
|
9442
|
+
state: z7.literal("output-denied"),
|
|
9443
|
+
providerExecuted: z7.boolean().optional(),
|
|
9444
|
+
input: z7.unknown(),
|
|
9445
|
+
output: z7.never().optional(),
|
|
9446
|
+
errorText: z7.never().optional(),
|
|
9581
9447
|
callProviderMetadata: providerMetadataSchema.optional(),
|
|
9582
|
-
approval:
|
|
9583
|
-
id:
|
|
9584
|
-
approved:
|
|
9585
|
-
reason:
|
|
9586
|
-
isAutomatic:
|
|
9448
|
+
approval: z7.object({
|
|
9449
|
+
id: z7.string(),
|
|
9450
|
+
approved: z7.literal(false),
|
|
9451
|
+
reason: z7.string().optional(),
|
|
9452
|
+
isAutomatic: z7.boolean().optional()
|
|
9587
9453
|
})
|
|
9588
9454
|
})
|
|
9589
9455
|
])
|
|
@@ -10202,9 +10068,47 @@ var DefaultEmbedManyResult = class {
|
|
|
10202
10068
|
|
|
10203
10069
|
// src/generate-image/generate-image.ts
|
|
10204
10070
|
import {
|
|
10205
|
-
convertBase64ToUint8Array as
|
|
10071
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
|
10072
|
+
detectMediaType as detectMediaType2,
|
|
10206
10073
|
withUserAgentSuffix as withUserAgentSuffix5
|
|
10207
10074
|
} from "@ai-sdk/provider-utils";
|
|
10075
|
+
|
|
10076
|
+
// src/prompt/data-content.ts
|
|
10077
|
+
import {
|
|
10078
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array2,
|
|
10079
|
+
convertUint8ArrayToBase64 as convertUint8ArrayToBase642
|
|
10080
|
+
} from "@ai-sdk/provider-utils";
|
|
10081
|
+
function convertDataContentToBase64String(content) {
|
|
10082
|
+
if (typeof content === "string") {
|
|
10083
|
+
return content;
|
|
10084
|
+
}
|
|
10085
|
+
if (content instanceof ArrayBuffer) {
|
|
10086
|
+
return convertUint8ArrayToBase642(new Uint8Array(content));
|
|
10087
|
+
}
|
|
10088
|
+
return convertUint8ArrayToBase642(content);
|
|
10089
|
+
}
|
|
10090
|
+
function convertDataContentToUint8Array(content) {
|
|
10091
|
+
if (content instanceof Uint8Array) {
|
|
10092
|
+
return content;
|
|
10093
|
+
}
|
|
10094
|
+
if (typeof content === "string") {
|
|
10095
|
+
try {
|
|
10096
|
+
return convertBase64ToUint8Array2(content);
|
|
10097
|
+
} catch (error) {
|
|
10098
|
+
throw new InvalidDataContentError({
|
|
10099
|
+
message: "Invalid data content. Content string is not a base64-encoded media.",
|
|
10100
|
+
content,
|
|
10101
|
+
cause: error
|
|
10102
|
+
});
|
|
10103
|
+
}
|
|
10104
|
+
}
|
|
10105
|
+
if (content instanceof ArrayBuffer) {
|
|
10106
|
+
return new Uint8Array(content);
|
|
10107
|
+
}
|
|
10108
|
+
throw new InvalidDataContentError({ content });
|
|
10109
|
+
}
|
|
10110
|
+
|
|
10111
|
+
// src/generate-image/generate-image.ts
|
|
10208
10112
|
async function generateImage({
|
|
10209
10113
|
model: modelArg,
|
|
10210
10114
|
prompt: promptArg,
|
|
@@ -10272,9 +10176,9 @@ async function generateImage({
|
|
|
10272
10176
|
var _a22;
|
|
10273
10177
|
return new DefaultGeneratedFile({
|
|
10274
10178
|
data: image,
|
|
10275
|
-
mediaType: (_a22 =
|
|
10179
|
+
mediaType: (_a22 = detectMediaType2({
|
|
10276
10180
|
data: image,
|
|
10277
|
-
|
|
10181
|
+
topLevelType: "image"
|
|
10278
10182
|
})) != null ? _a22 : "image/png"
|
|
10279
10183
|
});
|
|
10280
10184
|
}
|
|
@@ -10363,13 +10267,13 @@ function toImageModelV4File(dataContent) {
|
|
|
10363
10267
|
if (typeof dataContent === "string" && dataContent.startsWith("data:")) {
|
|
10364
10268
|
const { mediaType: dataUrlMediaType, base64Content } = splitDataUrl(dataContent);
|
|
10365
10269
|
if (base64Content != null) {
|
|
10366
|
-
const uint8Data2 =
|
|
10270
|
+
const uint8Data2 = convertBase64ToUint8Array3(base64Content);
|
|
10367
10271
|
return {
|
|
10368
10272
|
type: "file",
|
|
10369
10273
|
data: uint8Data2,
|
|
10370
|
-
mediaType: dataUrlMediaType ||
|
|
10274
|
+
mediaType: dataUrlMediaType || detectMediaType2({
|
|
10371
10275
|
data: uint8Data2,
|
|
10372
|
-
|
|
10276
|
+
topLevelType: "image"
|
|
10373
10277
|
}) || "image/png"
|
|
10374
10278
|
};
|
|
10375
10279
|
}
|
|
@@ -10378,9 +10282,9 @@ function toImageModelV4File(dataContent) {
|
|
|
10378
10282
|
return {
|
|
10379
10283
|
type: "file",
|
|
10380
10284
|
data: uint8Data,
|
|
10381
|
-
mediaType:
|
|
10285
|
+
mediaType: detectMediaType2({
|
|
10382
10286
|
data: uint8Data,
|
|
10383
|
-
|
|
10287
|
+
topLevelType: "image"
|
|
10384
10288
|
}) || "image/png"
|
|
10385
10289
|
};
|
|
10386
10290
|
}
|
|
@@ -11733,7 +11637,10 @@ var DefaultStreamObjectResult = class {
|
|
|
11733
11637
|
};
|
|
11734
11638
|
|
|
11735
11639
|
// src/generate-speech/generate-speech.ts
|
|
11736
|
-
import {
|
|
11640
|
+
import {
|
|
11641
|
+
detectMediaType as detectMediaType3,
|
|
11642
|
+
withUserAgentSuffix as withUserAgentSuffix7
|
|
11643
|
+
} from "@ai-sdk/provider-utils";
|
|
11737
11644
|
|
|
11738
11645
|
// src/generate-speech/generated-audio-file.ts
|
|
11739
11646
|
var DefaultGeneratedAudioFile = class extends DefaultGeneratedFile {
|
|
@@ -11811,9 +11718,9 @@ async function generateSpeech({
|
|
|
11811
11718
|
return new DefaultSpeechResult({
|
|
11812
11719
|
audio: new DefaultGeneratedAudioFile({
|
|
11813
11720
|
data: result.audio,
|
|
11814
|
-
mediaType: (_a21 =
|
|
11721
|
+
mediaType: (_a21 = detectMediaType3({
|
|
11815
11722
|
data: result.audio,
|
|
11816
|
-
|
|
11723
|
+
topLevelType: "audio"
|
|
11817
11724
|
})) != null ? _a21 : "audio/mp3"
|
|
11818
11725
|
}),
|
|
11819
11726
|
warnings: result.warnings,
|
|
@@ -11912,7 +11819,9 @@ function pruneMessages({
|
|
|
11912
11819
|
|
|
11913
11820
|
// src/generate-text/smooth-stream.ts
|
|
11914
11821
|
import { delay as originalDelay } from "@ai-sdk/provider-utils";
|
|
11915
|
-
import {
|
|
11822
|
+
import {
|
|
11823
|
+
InvalidArgumentError as InvalidArgumentError2
|
|
11824
|
+
} from "@ai-sdk/provider";
|
|
11916
11825
|
var CHUNKING_REGEXPS = {
|
|
11917
11826
|
word: /\S+\s+/m,
|
|
11918
11827
|
line: /\n+/m
|
|
@@ -12010,8 +11919,9 @@ function smoothStream({
|
|
|
12010
11919
|
|
|
12011
11920
|
// src/generate-video/generate-video.ts
|
|
12012
11921
|
import {
|
|
12013
|
-
convertBase64ToUint8Array as
|
|
12014
|
-
withUserAgentSuffix as withUserAgentSuffix8
|
|
11922
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array4,
|
|
11923
|
+
withUserAgentSuffix as withUserAgentSuffix8,
|
|
11924
|
+
detectMediaType as detectMediaType4
|
|
12015
11925
|
} from "@ai-sdk/provider-utils";
|
|
12016
11926
|
var defaultDownload = createDownload();
|
|
12017
11927
|
async function experimental_generateVideo({
|
|
@@ -12079,9 +11989,9 @@ async function experimental_generateVideo({
|
|
|
12079
11989
|
abortSignal
|
|
12080
11990
|
});
|
|
12081
11991
|
const isUsableMediaType = (type) => !!type && type !== "application/octet-stream";
|
|
12082
|
-
const mediaType = isUsableMediaType(videoData.mediaType) && videoData.mediaType || isUsableMediaType(downloadedMediaType) && downloadedMediaType ||
|
|
11992
|
+
const mediaType = isUsableMediaType(videoData.mediaType) && videoData.mediaType || isUsableMediaType(downloadedMediaType) && downloadedMediaType || detectMediaType4({
|
|
12083
11993
|
data,
|
|
12084
|
-
|
|
11994
|
+
topLevelType: "video"
|
|
12085
11995
|
}) || "video/mp4";
|
|
12086
11996
|
videos.push(
|
|
12087
11997
|
new DefaultGeneratedFile({
|
|
@@ -12101,9 +12011,9 @@ async function experimental_generateVideo({
|
|
|
12101
12011
|
break;
|
|
12102
12012
|
}
|
|
12103
12013
|
case "binary": {
|
|
12104
|
-
const mediaType = videoData.mediaType ||
|
|
12014
|
+
const mediaType = videoData.mediaType || detectMediaType4({
|
|
12105
12015
|
data: videoData.data,
|
|
12106
|
-
|
|
12016
|
+
topLevelType: "video"
|
|
12107
12017
|
}) || "video/mp4";
|
|
12108
12018
|
videos.push(
|
|
12109
12019
|
new DefaultGeneratedFile({
|
|
@@ -12184,13 +12094,13 @@ function normalizePrompt2(promptArg) {
|
|
|
12184
12094
|
image = {
|
|
12185
12095
|
type: "file",
|
|
12186
12096
|
mediaType: mediaType != null ? mediaType : "image/png",
|
|
12187
|
-
data:
|
|
12097
|
+
data: convertBase64ToUint8Array4(base64Content != null ? base64Content : "")
|
|
12188
12098
|
};
|
|
12189
12099
|
} else {
|
|
12190
|
-
const bytes =
|
|
12191
|
-
const mediaType = (_a21 =
|
|
12100
|
+
const bytes = convertBase64ToUint8Array4(dataContent);
|
|
12101
|
+
const mediaType = (_a21 = detectMediaType4({
|
|
12192
12102
|
data: bytes,
|
|
12193
|
-
|
|
12103
|
+
topLevelType: "image"
|
|
12194
12104
|
})) != null ? _a21 : "image/png";
|
|
12195
12105
|
image = {
|
|
12196
12106
|
type: "file",
|
|
@@ -12199,9 +12109,9 @@ function normalizePrompt2(promptArg) {
|
|
|
12199
12109
|
};
|
|
12200
12110
|
}
|
|
12201
12111
|
} else if (dataContent instanceof Uint8Array) {
|
|
12202
|
-
const mediaType = (_b =
|
|
12112
|
+
const mediaType = (_b = detectMediaType4({
|
|
12203
12113
|
data: dataContent,
|
|
12204
|
-
|
|
12114
|
+
topLevelType: "image"
|
|
12205
12115
|
})) != null ? _b : "image/png";
|
|
12206
12116
|
image = {
|
|
12207
12117
|
type: "file",
|
|
@@ -12859,15 +12769,12 @@ function customProvider({
|
|
|
12859
12769
|
skills,
|
|
12860
12770
|
fallbackProvider: fallbackProviderArg
|
|
12861
12771
|
}) {
|
|
12862
|
-
|
|
12863
|
-
const
|
|
12864
|
-
const resolvedFiles = files != null ? files : (_a21 = fallbackProvider == null ? void 0 : fallbackProvider.files) == null ? void 0 : _a21.call(fallbackProvider);
|
|
12865
|
-
const resolvedSkills = skills != null ? skills : (_b = fallbackProvider == null ? void 0 : fallbackProvider.skills) == null ? void 0 : _b.call(fallbackProvider);
|
|
12866
|
-
return {
|
|
12772
|
+
const fallbackProvider = fallbackProviderArg == null ? void 0 : asProviderV4(fallbackProviderArg);
|
|
12773
|
+
const baseProvider = {
|
|
12867
12774
|
specificationVersion: "v4",
|
|
12868
12775
|
languageModel(modelId) {
|
|
12869
12776
|
if (languageModels != null && modelId in languageModels) {
|
|
12870
|
-
return
|
|
12777
|
+
return resolveLanguageModel(languageModels[modelId]);
|
|
12871
12778
|
}
|
|
12872
12779
|
if (fallbackProvider) {
|
|
12873
12780
|
return fallbackProvider.languageModel(modelId);
|
|
@@ -12876,7 +12783,7 @@ function customProvider({
|
|
|
12876
12783
|
},
|
|
12877
12784
|
embeddingModel(modelId) {
|
|
12878
12785
|
if (embeddingModels != null && modelId in embeddingModels) {
|
|
12879
|
-
return
|
|
12786
|
+
return resolveEmbeddingModel(embeddingModels[modelId]);
|
|
12880
12787
|
}
|
|
12881
12788
|
if (fallbackProvider) {
|
|
12882
12789
|
return fallbackProvider.embeddingModel(modelId);
|
|
@@ -12885,7 +12792,7 @@ function customProvider({
|
|
|
12885
12792
|
},
|
|
12886
12793
|
imageModel(modelId) {
|
|
12887
12794
|
if (imageModels != null && modelId in imageModels) {
|
|
12888
|
-
return
|
|
12795
|
+
return resolveImageModel(imageModels[modelId]);
|
|
12889
12796
|
}
|
|
12890
12797
|
if (fallbackProvider == null ? void 0 : fallbackProvider.imageModel) {
|
|
12891
12798
|
return fallbackProvider.imageModel(modelId);
|
|
@@ -12894,7 +12801,10 @@ function customProvider({
|
|
|
12894
12801
|
},
|
|
12895
12802
|
transcriptionModel(modelId) {
|
|
12896
12803
|
if (transcriptionModels != null && modelId in transcriptionModels) {
|
|
12897
|
-
|
|
12804
|
+
const model = resolveTranscriptionModel(transcriptionModels[modelId]);
|
|
12805
|
+
if (model != null) {
|
|
12806
|
+
return model;
|
|
12807
|
+
}
|
|
12898
12808
|
}
|
|
12899
12809
|
if (fallbackProvider == null ? void 0 : fallbackProvider.transcriptionModel) {
|
|
12900
12810
|
return fallbackProvider.transcriptionModel(modelId);
|
|
@@ -12903,7 +12813,10 @@ function customProvider({
|
|
|
12903
12813
|
},
|
|
12904
12814
|
speechModel(modelId) {
|
|
12905
12815
|
if (speechModels != null && modelId in speechModels) {
|
|
12906
|
-
|
|
12816
|
+
const model = resolveSpeechModel(speechModels[modelId]);
|
|
12817
|
+
if (model != null) {
|
|
12818
|
+
return model;
|
|
12819
|
+
}
|
|
12907
12820
|
}
|
|
12908
12821
|
if (fallbackProvider == null ? void 0 : fallbackProvider.speechModel) {
|
|
12909
12822
|
return fallbackProvider.speechModel(modelId);
|
|
@@ -12912,7 +12825,7 @@ function customProvider({
|
|
|
12912
12825
|
},
|
|
12913
12826
|
rerankingModel(modelId) {
|
|
12914
12827
|
if (rerankingModels != null && modelId in rerankingModels) {
|
|
12915
|
-
return
|
|
12828
|
+
return resolveRerankingModel(rerankingModels[modelId]);
|
|
12916
12829
|
}
|
|
12917
12830
|
if (fallbackProvider == null ? void 0 : fallbackProvider.rerankingModel) {
|
|
12918
12831
|
return fallbackProvider.rerankingModel(modelId);
|
|
@@ -12921,22 +12834,32 @@ function customProvider({
|
|
|
12921
12834
|
},
|
|
12922
12835
|
videoModel(modelId) {
|
|
12923
12836
|
if (videoModels != null && modelId in videoModels) {
|
|
12924
|
-
return
|
|
12837
|
+
return resolveVideoModel(videoModels[modelId]);
|
|
12925
12838
|
}
|
|
12926
12839
|
const videoModel = fallbackProvider == null ? void 0 : fallbackProvider.videoModel;
|
|
12927
12840
|
if (videoModel) {
|
|
12928
12841
|
return videoModel(modelId);
|
|
12929
12842
|
}
|
|
12930
12843
|
throw new NoSuchModelError2({ modelId, modelType: "videoModel" });
|
|
12931
|
-
}
|
|
12932
|
-
...resolvedFiles != null ? { files: () => resolvedFiles } : {},
|
|
12933
|
-
...resolvedSkills != null ? { skills: () => resolvedSkills } : {}
|
|
12844
|
+
}
|
|
12934
12845
|
};
|
|
12846
|
+
const filesAndSkills = {
|
|
12847
|
+
...files != null || (fallbackProvider == null ? void 0 : fallbackProvider.files) != null ? {
|
|
12848
|
+
files() {
|
|
12849
|
+
return files != null ? files : fallbackProvider.files();
|
|
12850
|
+
}
|
|
12851
|
+
} : {},
|
|
12852
|
+
...skills != null || (fallbackProvider == null ? void 0 : fallbackProvider.skills) != null ? {
|
|
12853
|
+
skills() {
|
|
12854
|
+
return skills != null ? skills : fallbackProvider.skills();
|
|
12855
|
+
}
|
|
12856
|
+
} : {}
|
|
12857
|
+
};
|
|
12858
|
+
return Object.assign(baseProvider, filesAndSkills);
|
|
12935
12859
|
}
|
|
12936
|
-
var experimental_customProvider = customProvider;
|
|
12937
12860
|
|
|
12938
12861
|
// src/registry/no-such-provider-error.ts
|
|
12939
|
-
import { AISDKError as
|
|
12862
|
+
import { AISDKError as AISDKError23, NoSuchModelError as NoSuchModelError3 } from "@ai-sdk/provider";
|
|
12940
12863
|
var name20 = "AI_NoSuchProviderError";
|
|
12941
12864
|
var marker20 = `vercel.ai.error.${name20}`;
|
|
12942
12865
|
var symbol20 = Symbol.for(marker20);
|
|
@@ -12955,7 +12878,7 @@ var NoSuchProviderError = class extends NoSuchModelError3 {
|
|
|
12955
12878
|
this.availableProviders = availableProviders;
|
|
12956
12879
|
}
|
|
12957
12880
|
static isInstance(error) {
|
|
12958
|
-
return
|
|
12881
|
+
return AISDKError23.hasMarker(error, marker20);
|
|
12959
12882
|
}
|
|
12960
12883
|
};
|
|
12961
12884
|
_a20 = symbol20;
|
|
@@ -12975,7 +12898,7 @@ function createProviderRegistry(providers, {
|
|
|
12975
12898
|
imageModelMiddleware
|
|
12976
12899
|
});
|
|
12977
12900
|
for (const [id, provider] of Object.entries(providers)) {
|
|
12978
|
-
registry.registerProvider({ id, provider
|
|
12901
|
+
registry.registerProvider({ id, provider });
|
|
12979
12902
|
}
|
|
12980
12903
|
return registry;
|
|
12981
12904
|
}
|
|
@@ -12995,7 +12918,13 @@ var DefaultProviderRegistry = class {
|
|
|
12995
12918
|
id,
|
|
12996
12919
|
provider
|
|
12997
12920
|
}) {
|
|
12998
|
-
|
|
12921
|
+
var _a21;
|
|
12922
|
+
const providerV4 = asProviderV4(provider);
|
|
12923
|
+
const videoModel = (_a21 = provider.videoModel) == null ? void 0 : _a21.bind(provider);
|
|
12924
|
+
this.providers[id] = videoModel == null ? providerV4 : Object.assign(Object.create(Object.getPrototypeOf(providerV4)), {
|
|
12925
|
+
...providerV4,
|
|
12926
|
+
videoModel: (modelId) => asVideoModelV4(videoModel(modelId))
|
|
12927
|
+
});
|
|
12999
12928
|
}
|
|
13000
12929
|
getProvider(id, modelType) {
|
|
13001
12930
|
const provider = this.providers[id];
|
|
@@ -13007,7 +12936,7 @@ var DefaultProviderRegistry = class {
|
|
|
13007
12936
|
availableProviders: Object.keys(this.providers)
|
|
13008
12937
|
});
|
|
13009
12938
|
}
|
|
13010
|
-
return
|
|
12939
|
+
return provider;
|
|
13011
12940
|
}
|
|
13012
12941
|
splitId(id, modelType) {
|
|
13013
12942
|
const index = id.indexOf(this.separator);
|
|
@@ -13108,50 +13037,36 @@ var DefaultProviderRegistry = class {
|
|
|
13108
13037
|
if (model == null) {
|
|
13109
13038
|
throw new NoSuchModelError4({ modelId: id, modelType: "videoModel" });
|
|
13110
13039
|
}
|
|
13111
|
-
return model;
|
|
13040
|
+
return asVideoModelV4(model);
|
|
13112
13041
|
}
|
|
13113
|
-
files(
|
|
13114
|
-
var _a21
|
|
13115
|
-
const
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
modelId: providerId,
|
|
13119
|
-
modelType: "languageModel",
|
|
13120
|
-
providerId,
|
|
13121
|
-
availableProviders: Object.keys(this.providers)
|
|
13122
|
-
});
|
|
13123
|
-
}
|
|
13124
|
-
const filesInterface = (_b = (_a21 = asProviderV4(providerInstance)).files) == null ? void 0 : _b.call(_a21);
|
|
13125
|
-
if (filesInterface == null) {
|
|
13042
|
+
files(id) {
|
|
13043
|
+
var _a21;
|
|
13044
|
+
const provider = this.getProvider(id, "languageModel");
|
|
13045
|
+
const files = (_a21 = provider.files) == null ? void 0 : _a21.call(provider);
|
|
13046
|
+
if (files == null) {
|
|
13126
13047
|
throw new Error(
|
|
13127
|
-
`
|
|
13048
|
+
`The provider "${id}" does not support file uploads. Make sure it exposes a files() method.`
|
|
13128
13049
|
);
|
|
13129
13050
|
}
|
|
13130
|
-
return
|
|
13051
|
+
return files;
|
|
13131
13052
|
}
|
|
13132
|
-
skills(
|
|
13133
|
-
var _a21
|
|
13134
|
-
const
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
modelId: providerId,
|
|
13138
|
-
modelType: "languageModel",
|
|
13139
|
-
providerId,
|
|
13140
|
-
availableProviders: Object.keys(this.providers)
|
|
13141
|
-
});
|
|
13142
|
-
}
|
|
13143
|
-
const skillsInterface = (_b = (_a21 = asProviderV4(providerInstance)).skills) == null ? void 0 : _b.call(_a21);
|
|
13144
|
-
if (skillsInterface == null) {
|
|
13053
|
+
skills(id) {
|
|
13054
|
+
var _a21;
|
|
13055
|
+
const provider = this.getProvider(id, "languageModel");
|
|
13056
|
+
const skills = (_a21 = provider.skills) == null ? void 0 : _a21.call(provider);
|
|
13057
|
+
if (skills == null) {
|
|
13145
13058
|
throw new Error(
|
|
13146
|
-
`
|
|
13059
|
+
`The provider "${id}" does not support skills. Make sure it exposes a skills() method.`
|
|
13147
13060
|
);
|
|
13148
13061
|
}
|
|
13149
|
-
return
|
|
13062
|
+
return skills;
|
|
13150
13063
|
}
|
|
13151
13064
|
};
|
|
13152
13065
|
|
|
13153
13066
|
// src/rerank/rerank.ts
|
|
13154
|
-
import {
|
|
13067
|
+
import {
|
|
13068
|
+
createIdGenerator as createIdGenerator8
|
|
13069
|
+
} from "@ai-sdk/provider-utils";
|
|
13155
13070
|
var originalGenerateCallId6 = createIdGenerator8({
|
|
13156
13071
|
prefix: "call",
|
|
13157
13072
|
size: 24
|
|
@@ -13349,7 +13264,10 @@ var DefaultRerankResult = class {
|
|
|
13349
13264
|
};
|
|
13350
13265
|
|
|
13351
13266
|
// src/transcribe/transcribe.ts
|
|
13352
|
-
import {
|
|
13267
|
+
import {
|
|
13268
|
+
detectMediaType as detectMediaType5,
|
|
13269
|
+
withUserAgentSuffix as withUserAgentSuffix9
|
|
13270
|
+
} from "@ai-sdk/provider-utils";
|
|
13353
13271
|
var defaultDownload2 = createDownload();
|
|
13354
13272
|
async function transcribe({
|
|
13355
13273
|
model,
|
|
@@ -13381,9 +13299,9 @@ async function transcribe({
|
|
|
13381
13299
|
abortSignal,
|
|
13382
13300
|
headers: headersWithUserAgent,
|
|
13383
13301
|
providerOptions,
|
|
13384
|
-
mediaType: (_a21 =
|
|
13302
|
+
mediaType: (_a21 = detectMediaType5({
|
|
13385
13303
|
data: audioData,
|
|
13386
|
-
|
|
13304
|
+
topLevelType: "audio"
|
|
13387
13305
|
})) != null ? _a21 : "audio/wav"
|
|
13388
13306
|
});
|
|
13389
13307
|
}
|
|
@@ -14244,7 +14162,8 @@ var TextStreamChatTransport = class extends HttpChatTransport {
|
|
|
14244
14162
|
|
|
14245
14163
|
// src/upload-file/upload-file.ts
|
|
14246
14164
|
import {
|
|
14247
|
-
convertBase64ToUint8Array as
|
|
14165
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array5,
|
|
14166
|
+
detectMediaType as detectMediaType6
|
|
14248
14167
|
} from "@ai-sdk/provider-utils";
|
|
14249
14168
|
async function uploadFile({
|
|
14250
14169
|
api,
|
|
@@ -14254,21 +14173,8 @@ async function uploadFile({
|
|
|
14254
14173
|
providerOptions
|
|
14255
14174
|
}) {
|
|
14256
14175
|
var _a21;
|
|
14257
|
-
const { data }
|
|
14258
|
-
|
|
14259
|
-
throw new Error(
|
|
14260
|
-
"URL data is not supported for file uploads. Fetch the URL content first and pass the bytes."
|
|
14261
|
-
);
|
|
14262
|
-
}
|
|
14263
|
-
const mediaType = (_a21 = mediaTypeArg != null ? mediaTypeArg : detectMediaType({
|
|
14264
|
-
data,
|
|
14265
|
-
signatures: [
|
|
14266
|
-
...imageMediaTypeSignatures,
|
|
14267
|
-
...documentMediaTypeSignatures,
|
|
14268
|
-
...audioMediaTypeSignatures,
|
|
14269
|
-
...videoMediaTypeSignatures
|
|
14270
|
-
]
|
|
14271
|
-
})) != null ? _a21 : isLikelyText(data) ? "text/plain" : "application/octet-stream";
|
|
14176
|
+
const data = dataArg instanceof Uint8Array || typeof dataArg === "string" ? { type: "data", data: dataArg } : dataArg;
|
|
14177
|
+
const mediaType = mediaTypeArg != null ? mediaTypeArg : data.type === "text" ? "text/plain" : (_a21 = detectMediaType6({ data: data.data })) != null ? _a21 : isLikelyText(data.data) ? "text/plain" : "application/octet-stream";
|
|
14272
14178
|
const filesApi = "uploadFile" in api ? api : typeof api.files === "function" ? api.files() : (() => {
|
|
14273
14179
|
throw new Error(
|
|
14274
14180
|
"The provider does not support file uploads. Make sure it exposes a files() method."
|
|
@@ -14300,7 +14206,7 @@ var DefaultUploadFileResult = class {
|
|
|
14300
14206
|
function isLikelyText(data) {
|
|
14301
14207
|
const CHECK_LENGTH = 512;
|
|
14302
14208
|
const BASE64_CHECK_LENGTH = Math.ceil((CHECK_LENGTH + 4) / 3) * 4;
|
|
14303
|
-
const bytes = typeof data === "string" ?
|
|
14209
|
+
const bytes = typeof data === "string" ? convertBase64ToUint8Array5(
|
|
14304
14210
|
data.substring(0, Math.min(data.length, BASE64_CHECK_LENGTH))
|
|
14305
14211
|
) : data;
|
|
14306
14212
|
const checkLength = Math.min(bytes.length, CHECK_LENGTH);
|
|
@@ -14327,8 +14233,12 @@ async function uploadSkill({
|
|
|
14327
14233
|
"The provider does not support skills. Make sure it exposes a skills() method."
|
|
14328
14234
|
);
|
|
14329
14235
|
})();
|
|
14236
|
+
const normalizedFiles = files.map((file) => ({
|
|
14237
|
+
...file,
|
|
14238
|
+
data: file.data instanceof Uint8Array || typeof file.data === "string" ? { type: "data", data: file.data } : file.data
|
|
14239
|
+
}));
|
|
14330
14240
|
const result = await skillsApi.uploadSkill({
|
|
14331
|
-
files,
|
|
14241
|
+
files: normalizedFiles,
|
|
14332
14242
|
displayTitle,
|
|
14333
14243
|
providerOptions
|
|
14334
14244
|
});
|
|
@@ -14336,6 +14246,7 @@ async function uploadSkill({
|
|
|
14336
14246
|
}
|
|
14337
14247
|
export {
|
|
14338
14248
|
AISDKError21 as AISDKError,
|
|
14249
|
+
AI_SDK_TELEMETRY_DIAGNOSTIC_CHANNEL,
|
|
14339
14250
|
APICallError,
|
|
14340
14251
|
AbstractChat,
|
|
14341
14252
|
DefaultChatTransport,
|
|
@@ -14408,7 +14319,6 @@ export {
|
|
|
14408
14319
|
embed,
|
|
14409
14320
|
embedMany,
|
|
14410
14321
|
experimental_createProviderRegistry,
|
|
14411
|
-
experimental_customProvider,
|
|
14412
14322
|
filterActiveTools as experimental_filterActiveTools,
|
|
14413
14323
|
experimental_generateImage,
|
|
14414
14324
|
generateSpeech as experimental_generateSpeech,
|