ai 6.0.292 → 6.0.294
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.js +28 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +3 -2
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +3 -2
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +5 -2
- package/docs/03-ai-sdk-core/36-transcription.mdx +1 -0
- package/package.json +5 -5
- package/src/prompt/content-part.ts +1 -0
- package/src/prompt/convert-to-language-model-prompt.ts +3 -1
- package/src/util/write-to-server-response.ts +41 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.294
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 16a04d7: fix(ai): cancel response streams when clients disconnect
|
|
8
|
+
- Updated dependencies [29dc427]
|
|
9
|
+
- @ai-sdk/provider-utils@4.0.56
|
|
10
|
+
- @ai-sdk/gateway@3.0.204
|
|
11
|
+
|
|
12
|
+
## 6.0.293
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 3983fea: fix(provider): preserve media types on tool result file URLs and match full MIME types exactly when checking native URL support.
|
|
17
|
+
- Updated dependencies [3983fea]
|
|
18
|
+
- @ai-sdk/provider@3.0.18
|
|
19
|
+
- @ai-sdk/provider-utils@4.0.55
|
|
20
|
+
- @ai-sdk/gateway@3.0.203
|
|
21
|
+
|
|
3
22
|
## 6.0.292
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1334,7 +1334,7 @@ function detectMediaType({
|
|
|
1334
1334
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
1335
1335
|
|
|
1336
1336
|
// src/version.ts
|
|
1337
|
-
var VERSION = true ? "6.0.
|
|
1337
|
+
var VERSION = true ? "6.0.294" : "0.0.0-test";
|
|
1338
1338
|
|
|
1339
1339
|
// src/util/download/download.ts
|
|
1340
1340
|
var download = async ({
|
|
@@ -1803,7 +1803,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
1803
1803
|
if (contentPart.type === "image-url" || contentPart.type === "file-url") {
|
|
1804
1804
|
downloadableFiles.push({
|
|
1805
1805
|
data: new URL(contentPart.url),
|
|
1806
|
-
mediaType: contentPart.type === "image-url" ? "image/*" :
|
|
1806
|
+
mediaType: contentPart.type === "image-url" ? "image/*" : contentPart.mediaType
|
|
1807
1807
|
});
|
|
1808
1808
|
}
|
|
1809
1809
|
}
|
|
@@ -2244,6 +2244,7 @@ var outputSchema = import_v44.z.discriminatedUnion(
|
|
|
2244
2244
|
import_v44.z.object({
|
|
2245
2245
|
type: import_v44.z.literal("file-url"),
|
|
2246
2246
|
url: import_v44.z.string(),
|
|
2247
|
+
mediaType: import_v44.z.string().optional(),
|
|
2247
2248
|
providerOptions: providerMetadataSchema.optional()
|
|
2248
2249
|
}),
|
|
2249
2250
|
import_v44.z.object({
|
|
@@ -5647,21 +5648,44 @@ function writeToServerResponse({
|
|
|
5647
5648
|
response.writeHead(statusCode, headers);
|
|
5648
5649
|
}
|
|
5649
5650
|
const reader = stream.getReader();
|
|
5651
|
+
let clientDisconnected = false;
|
|
5652
|
+
let onDisconnect;
|
|
5653
|
+
const handleClose = () => {
|
|
5654
|
+
if (response.writableFinished) {
|
|
5655
|
+
return;
|
|
5656
|
+
}
|
|
5657
|
+
clientDisconnected = true;
|
|
5658
|
+
onDisconnect == null ? void 0 : onDisconnect();
|
|
5659
|
+
reader.cancel(new Error("Client disconnected.")).catch(() => {
|
|
5660
|
+
});
|
|
5661
|
+
};
|
|
5662
|
+
response.once("close", handleClose);
|
|
5663
|
+
if (response.destroyed) {
|
|
5664
|
+
handleClose();
|
|
5665
|
+
}
|
|
5650
5666
|
const read = async () => {
|
|
5651
5667
|
try {
|
|
5652
5668
|
while (true) {
|
|
5653
5669
|
const { done, value } = await reader.read();
|
|
5654
|
-
if (done)
|
|
5670
|
+
if (done || clientDisconnected || response.destroyed)
|
|
5655
5671
|
break;
|
|
5656
5672
|
const canContinue = response.write(value);
|
|
5657
5673
|
if (!canContinue) {
|
|
5658
5674
|
await new Promise((resolve3) => {
|
|
5675
|
+
onDisconnect = resolve3;
|
|
5659
5676
|
response.once("drain", resolve3);
|
|
5660
5677
|
});
|
|
5678
|
+
onDisconnect = void 0;
|
|
5661
5679
|
}
|
|
5662
5680
|
}
|
|
5663
5681
|
} finally {
|
|
5664
|
-
response.
|
|
5682
|
+
response.off("close", handleClose);
|
|
5683
|
+
if (clientDisconnected || response.destroyed) {
|
|
5684
|
+
reader.cancel().catch(() => {
|
|
5685
|
+
});
|
|
5686
|
+
} else {
|
|
5687
|
+
response.end();
|
|
5688
|
+
}
|
|
5665
5689
|
}
|
|
5666
5690
|
};
|
|
5667
5691
|
return read();
|