ai 6.0.233 → 6.0.235
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 +19 -0
- package/dist/index.d.mts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +33 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +26 -14
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +26 -14
- package/dist/internal/index.mjs.map +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +29 -0
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +2 -2
- package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +6 -1
- package/docs/08-migration-guides/24-migration-guide-6-0.mdx +28 -0
- package/package.json +2 -2
- package/src/agent/pipe-agent-ui-stream-to-response.ts +1 -1
- package/src/generate-object/stream-object-result.ts +4 -1
- package/src/generate-object/stream-object.ts +1 -1
- package/src/generate-text/stream-text-result.ts +5 -2
- package/src/generate-text/stream-text.ts +2 -2
- package/src/text-stream/pipe-text-stream-to-response.ts +3 -2
- package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +3 -2
- package/src/util/detect-media-type.ts +47 -26
- package/src/util/write-to-server-response.ts +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1140,25 +1140,37 @@ var videoMediaTypeSignatures = [
|
|
|
1140
1140
|
// RIFF (AVI)
|
|
1141
1141
|
}
|
|
1142
1142
|
];
|
|
1143
|
-
var
|
|
1144
|
-
|
|
1143
|
+
var DEFAULT_SNIFF_BYTES = 18;
|
|
1144
|
+
var MAX_SIGNATURE_BYTES = 12;
|
|
1145
|
+
var MAX_ID3_TAG_BYTES = 128 * 1024;
|
|
1146
|
+
var ID3_SCAN_BYTES = MAX_ID3_TAG_BYTES + MAX_SIGNATURE_BYTES;
|
|
1147
|
+
function decodePrefix(data, maxBytes) {
|
|
1148
|
+
if (typeof data !== "string") {
|
|
1149
|
+
return data.length > maxBytes ? data.subarray(0, maxBytes) : data;
|
|
1150
|
+
}
|
|
1151
|
+
const maxChars = Math.ceil(maxBytes / 3) * 4;
|
|
1152
|
+
const bytes = convertBase64ToUint8Array(
|
|
1153
|
+
data.substring(0, Math.min(data.length, maxChars))
|
|
1154
|
+
);
|
|
1155
|
+
return bytes.length > maxBytes ? bytes.subarray(0, maxBytes) : bytes;
|
|
1156
|
+
}
|
|
1157
|
+
function hasID3(bytes) {
|
|
1158
|
+
return bytes.length > 10 && bytes[0] === 73 && // 'I'
|
|
1159
|
+
bytes[1] === 68 && // 'D'
|
|
1160
|
+
bytes[2] === 51;
|
|
1161
|
+
}
|
|
1162
|
+
var stripID3 = (bytes) => {
|
|
1145
1163
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
1146
|
-
return bytes.
|
|
1164
|
+
return bytes.subarray(id3Size + 10);
|
|
1147
1165
|
};
|
|
1148
|
-
function stripID3TagsIfPresent(data) {
|
|
1149
|
-
const hasId3 = typeof data === "string" && data.startsWith("SUQz") || typeof data !== "string" && data.length > 10 && data[0] === 73 && // 'I'
|
|
1150
|
-
data[1] === 68 && // 'D'
|
|
1151
|
-
data[2] === 51;
|
|
1152
|
-
return hasId3 ? stripID3(data) : data;
|
|
1153
|
-
}
|
|
1154
1166
|
function detectMediaType({
|
|
1155
1167
|
data,
|
|
1156
1168
|
signatures
|
|
1157
1169
|
}) {
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1170
|
+
let bytes = decodePrefix(data, DEFAULT_SNIFF_BYTES);
|
|
1171
|
+
if (hasID3(bytes)) {
|
|
1172
|
+
bytes = stripID3(decodePrefix(data, ID3_SCAN_BYTES));
|
|
1173
|
+
}
|
|
1162
1174
|
for (const signature of signatures) {
|
|
1163
1175
|
if (bytes.length >= signature.bytesPrefix.length && signature.bytesPrefix.every(
|
|
1164
1176
|
(byte, index) => byte === null || bytes[index] === byte
|
|
@@ -1181,7 +1193,7 @@ import {
|
|
|
1181
1193
|
} from "@ai-sdk/provider-utils";
|
|
1182
1194
|
|
|
1183
1195
|
// src/version.ts
|
|
1184
|
-
var VERSION = true ? "6.0.
|
|
1196
|
+
var VERSION = true ? "6.0.235" : "0.0.0-test";
|
|
1185
1197
|
|
|
1186
1198
|
// src/util/download/download.ts
|
|
1187
1199
|
var download = async ({
|
|
@@ -5388,7 +5400,7 @@ function writeToServerResponse({
|
|
|
5388
5400
|
response.end();
|
|
5389
5401
|
}
|
|
5390
5402
|
};
|
|
5391
|
-
read();
|
|
5403
|
+
return read();
|
|
5392
5404
|
}
|
|
5393
5405
|
|
|
5394
5406
|
// src/text-stream/pipe-text-stream-to-response.ts
|
|
@@ -5399,7 +5411,7 @@ function pipeTextStreamToResponse({
|
|
|
5399
5411
|
headers,
|
|
5400
5412
|
textStream
|
|
5401
5413
|
}) {
|
|
5402
|
-
writeToServerResponse({
|
|
5414
|
+
return writeToServerResponse({
|
|
5403
5415
|
response,
|
|
5404
5416
|
status,
|
|
5405
5417
|
statusText,
|
|
@@ -6410,7 +6422,7 @@ function pipeUIMessageStreamToResponse({
|
|
|
6410
6422
|
sseStream = stream1;
|
|
6411
6423
|
consumeSseStream({ stream: stream2 });
|
|
6412
6424
|
}
|
|
6413
|
-
writeToServerResponse({
|
|
6425
|
+
return writeToServerResponse({
|
|
6414
6426
|
response,
|
|
6415
6427
|
status,
|
|
6416
6428
|
statusText,
|
|
@@ -8649,7 +8661,7 @@ var DefaultStreamTextResult = class {
|
|
|
8649
8661
|
onError,
|
|
8650
8662
|
...init
|
|
8651
8663
|
} = {}) {
|
|
8652
|
-
pipeUIMessageStreamToResponse({
|
|
8664
|
+
return pipeUIMessageStreamToResponse({
|
|
8653
8665
|
response,
|
|
8654
8666
|
stream: this.toUIMessageStream({
|
|
8655
8667
|
originalMessages,
|
|
@@ -8666,7 +8678,7 @@ var DefaultStreamTextResult = class {
|
|
|
8666
8678
|
});
|
|
8667
8679
|
}
|
|
8668
8680
|
pipeTextStreamToResponse(response, init) {
|
|
8669
|
-
pipeTextStreamToResponse({
|
|
8681
|
+
return pipeTextStreamToResponse({
|
|
8670
8682
|
response,
|
|
8671
8683
|
textStream: this.textStream,
|
|
8672
8684
|
...init
|
|
@@ -9703,7 +9715,7 @@ async function pipeAgentUIStreamToResponse({
|
|
|
9703
9715
|
consumeSseStream,
|
|
9704
9716
|
...options
|
|
9705
9717
|
}) {
|
|
9706
|
-
pipeUIMessageStreamToResponse({
|
|
9718
|
+
return pipeUIMessageStreamToResponse({
|
|
9707
9719
|
response,
|
|
9708
9720
|
headers,
|
|
9709
9721
|
status,
|
|
@@ -11671,7 +11683,7 @@ var DefaultStreamObjectResult = class {
|
|
|
11671
11683
|
return createAsyncIterableStream(this.baseStream);
|
|
11672
11684
|
}
|
|
11673
11685
|
pipeTextStreamToResponse(response, init) {
|
|
11674
|
-
pipeTextStreamToResponse({
|
|
11686
|
+
return pipeTextStreamToResponse({
|
|
11675
11687
|
response,
|
|
11676
11688
|
textStream: this.textStream,
|
|
11677
11689
|
...init
|