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/dist/index.mjs
CHANGED
|
@@ -1224,7 +1224,7 @@ import {
|
|
|
1224
1224
|
} from "@ai-sdk/provider-utils";
|
|
1225
1225
|
|
|
1226
1226
|
// src/version.ts
|
|
1227
|
-
var VERSION = true ? "6.0.
|
|
1227
|
+
var VERSION = true ? "6.0.294" : "0.0.0-test";
|
|
1228
1228
|
|
|
1229
1229
|
// src/util/download/download.ts
|
|
1230
1230
|
var download = async ({
|
|
@@ -1696,7 +1696,7 @@ async function downloadAssets(messages, download2, supportedUrls) {
|
|
|
1696
1696
|
if (contentPart.type === "image-url" || contentPart.type === "file-url") {
|
|
1697
1697
|
downloadableFiles.push({
|
|
1698
1698
|
data: new URL(contentPart.url),
|
|
1699
|
-
mediaType: contentPart.type === "image-url" ? "image/*" :
|
|
1699
|
+
mediaType: contentPart.type === "image-url" ? "image/*" : contentPart.mediaType
|
|
1700
1700
|
});
|
|
1701
1701
|
}
|
|
1702
1702
|
}
|
|
@@ -2139,6 +2139,7 @@ var outputSchema = z4.discriminatedUnion(
|
|
|
2139
2139
|
z4.object({
|
|
2140
2140
|
type: z4.literal("file-url"),
|
|
2141
2141
|
url: z4.string(),
|
|
2142
|
+
mediaType: z4.string().optional(),
|
|
2142
2143
|
providerOptions: providerMetadataSchema.optional()
|
|
2143
2144
|
}),
|
|
2144
2145
|
z4.object({
|
|
@@ -5574,21 +5575,44 @@ function writeToServerResponse({
|
|
|
5574
5575
|
response.writeHead(statusCode, headers);
|
|
5575
5576
|
}
|
|
5576
5577
|
const reader = stream.getReader();
|
|
5578
|
+
let clientDisconnected = false;
|
|
5579
|
+
let onDisconnect;
|
|
5580
|
+
const handleClose = () => {
|
|
5581
|
+
if (response.writableFinished) {
|
|
5582
|
+
return;
|
|
5583
|
+
}
|
|
5584
|
+
clientDisconnected = true;
|
|
5585
|
+
onDisconnect == null ? void 0 : onDisconnect();
|
|
5586
|
+
reader.cancel(new Error("Client disconnected.")).catch(() => {
|
|
5587
|
+
});
|
|
5588
|
+
};
|
|
5589
|
+
response.once("close", handleClose);
|
|
5590
|
+
if (response.destroyed) {
|
|
5591
|
+
handleClose();
|
|
5592
|
+
}
|
|
5577
5593
|
const read = async () => {
|
|
5578
5594
|
try {
|
|
5579
5595
|
while (true) {
|
|
5580
5596
|
const { done, value } = await reader.read();
|
|
5581
|
-
if (done)
|
|
5597
|
+
if (done || clientDisconnected || response.destroyed)
|
|
5582
5598
|
break;
|
|
5583
5599
|
const canContinue = response.write(value);
|
|
5584
5600
|
if (!canContinue) {
|
|
5585
5601
|
await new Promise((resolve3) => {
|
|
5602
|
+
onDisconnect = resolve3;
|
|
5586
5603
|
response.once("drain", resolve3);
|
|
5587
5604
|
});
|
|
5605
|
+
onDisconnect = void 0;
|
|
5588
5606
|
}
|
|
5589
5607
|
}
|
|
5590
5608
|
} finally {
|
|
5591
|
-
response.
|
|
5609
|
+
response.off("close", handleClose);
|
|
5610
|
+
if (clientDisconnected || response.destroyed) {
|
|
5611
|
+
reader.cancel().catch(() => {
|
|
5612
|
+
});
|
|
5613
|
+
} else {
|
|
5614
|
+
response.end();
|
|
5615
|
+
}
|
|
5592
5616
|
}
|
|
5593
5617
|
};
|
|
5594
5618
|
return read();
|