ai 6.0.206 → 6.0.208
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 +20 -0
- package/dist/index.js +25 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +2 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +3 -1
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-ai-sdk-core/36-transcription.mdx +28 -25
- package/package.json +3 -3
- package/src/generate-text/stream-text.ts +3 -1
- package/src/util/download/download.ts +4 -0
- package/src/util/fix-json.ts +30 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.208
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8261640: fix(ai): handle partial unicode escapes in fixJson
|
|
8
|
+
- f994df3: Serialize `undefined` tool output to `null` in UI message chunks
|
|
9
|
+
|
|
10
|
+
## 6.0.207
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 779f5cd: fix(provider-utils): cancel response body on download rejection to prevent socket leak
|
|
15
|
+
|
|
16
|
+
When a download was rejected early — because the `Content-Length` header exceeded the size limit, the response status was not ok, or a redirect resolved to a blocked URL — the fetch response body was left unconsumed and uncancelled. With WHATWG Fetch/undici this leaves the underlying TCP socket open instead of returning it to the connection pool, allowing an attacker-controlled origin to exhaust file descriptors and cause a denial of service. The body is now cancelled on all early-rejection paths in `readResponseWithSizeLimit`, `download`, and `downloadBlob`, and `fetchWithValidatedRedirects` cancels each redirect hop's body before following or rejecting the next hop.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [5bfde36]
|
|
19
|
+
- Updated dependencies [779f5cd]
|
|
20
|
+
- @ai-sdk/gateway@3.0.133
|
|
21
|
+
- @ai-sdk/provider-utils@4.0.30
|
|
22
|
+
|
|
3
23
|
## 6.0.206
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1281,7 +1281,7 @@ function detectMediaType({
|
|
|
1281
1281
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1282
1282
|
|
|
1283
1283
|
// src/version.ts
|
|
1284
|
-
var VERSION = true ? "6.0.
|
|
1284
|
+
var VERSION = true ? "6.0.208" : "0.0.0-test";
|
|
1285
1285
|
|
|
1286
1286
|
// src/util/download/download.ts
|
|
1287
1287
|
var download = async ({
|
|
@@ -1303,6 +1303,7 @@ var download = async ({
|
|
|
1303
1303
|
abortSignal
|
|
1304
1304
|
});
|
|
1305
1305
|
if (!response.ok) {
|
|
1306
|
+
await (0, import_provider_utils3.cancelResponseBody)(response);
|
|
1306
1307
|
throw new import_provider_utils3.DownloadError({
|
|
1307
1308
|
url: urlText,
|
|
1308
1309
|
statusCode: response.status,
|
|
@@ -3348,6 +3349,10 @@ function fixJson(input) {
|
|
|
3348
3349
|
const stack = ["ROOT"];
|
|
3349
3350
|
let lastValidIndex = -1;
|
|
3350
3351
|
let literalStart = null;
|
|
3352
|
+
let unicodeEscapeDigits = 0;
|
|
3353
|
+
function isHexDigit(char) {
|
|
3354
|
+
return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
|
|
3355
|
+
}
|
|
3351
3356
|
function processValueStart(char, i, swapState) {
|
|
3352
3357
|
{
|
|
3353
3358
|
switch (char) {
|
|
@@ -3552,7 +3557,22 @@ function fixJson(input) {
|
|
|
3552
3557
|
}
|
|
3553
3558
|
case "INSIDE_STRING_ESCAPE": {
|
|
3554
3559
|
stack.pop();
|
|
3555
|
-
|
|
3560
|
+
if (char === "u") {
|
|
3561
|
+
unicodeEscapeDigits = 0;
|
|
3562
|
+
stack.push("INSIDE_STRING_UNICODE_ESCAPE");
|
|
3563
|
+
} else {
|
|
3564
|
+
lastValidIndex = i;
|
|
3565
|
+
}
|
|
3566
|
+
break;
|
|
3567
|
+
}
|
|
3568
|
+
case "INSIDE_STRING_UNICODE_ESCAPE": {
|
|
3569
|
+
if (isHexDigit(char)) {
|
|
3570
|
+
unicodeEscapeDigits++;
|
|
3571
|
+
if (unicodeEscapeDigits === 4) {
|
|
3572
|
+
stack.pop();
|
|
3573
|
+
lastValidIndex = i;
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3556
3576
|
break;
|
|
3557
3577
|
}
|
|
3558
3578
|
case "INSIDE_NUMBER": {
|
|
@@ -8435,7 +8455,9 @@ var DefaultStreamTextResult = class {
|
|
|
8435
8455
|
controller.enqueue({
|
|
8436
8456
|
type: "tool-output-available",
|
|
8437
8457
|
toolCallId: part.toolCallId,
|
|
8438
|
-
|
|
8458
|
+
// UI stream chunks are serialized as JSON, which drops undefined
|
|
8459
|
+
// properties. Use null so tool outputs always keep the output field.
|
|
8460
|
+
output: part.output === void 0 ? null : part.output,
|
|
8439
8461
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
8440
8462
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
8441
8463
|
...part.toolMetadata != null ? { toolMetadata: part.toolMetadata } : {},
|