ai 5.0.242 → 5.0.243
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 +9 -0
- package/dist/index.js +27 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -5
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 5.0.243
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9e8a754: Prevent exceptions in streaming `onChunk` and `onError` callbacks from terminating the stream or masking provider errors.
|
|
8
|
+
- Updated dependencies [1a04ece]
|
|
9
|
+
- Updated dependencies [ed2f035]
|
|
10
|
+
- @ai-sdk/gateway@2.0.138
|
|
11
|
+
|
|
3
12
|
## 5.0.242
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -816,7 +816,7 @@ function detectMediaType({
|
|
|
816
816
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
817
817
|
|
|
818
818
|
// src/version.ts
|
|
819
|
-
var VERSION = true ? "5.0.
|
|
819
|
+
var VERSION = true ? "5.0.243" : "0.0.0-test";
|
|
820
820
|
|
|
821
821
|
// src/util/download/download.ts
|
|
822
822
|
var download = async ({
|
|
@@ -4431,6 +4431,16 @@ function createStitchableStream() {
|
|
|
4431
4431
|
};
|
|
4432
4432
|
}
|
|
4433
4433
|
|
|
4434
|
+
// src/util/notify.ts
|
|
4435
|
+
async function notify(options) {
|
|
4436
|
+
for (const callback of asArray(options.callbacks)) {
|
|
4437
|
+
try {
|
|
4438
|
+
await callback(options.event);
|
|
4439
|
+
} catch (_ignored) {
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
|
|
4434
4444
|
// src/util/now.ts
|
|
4435
4445
|
function now() {
|
|
4436
4446
|
var _a16, _b;
|
|
@@ -4918,10 +4928,16 @@ var DefaultStreamTextResult = class {
|
|
|
4918
4928
|
controller.enqueue(chunk);
|
|
4919
4929
|
const { part } = chunk;
|
|
4920
4930
|
if (part.type === "text-delta" || part.type === "reasoning-delta" || part.type === "source" || part.type === "tool-call" || part.type === "tool-result" || part.type === "tool-input-start" || part.type === "tool-input-delta" || part.type === "raw") {
|
|
4921
|
-
await (
|
|
4931
|
+
await notify({
|
|
4932
|
+
event: { chunk: part },
|
|
4933
|
+
callbacks: onChunk
|
|
4934
|
+
});
|
|
4922
4935
|
}
|
|
4923
4936
|
if (part.type === "error") {
|
|
4924
|
-
await
|
|
4937
|
+
await notify({
|
|
4938
|
+
event: { error: wrapGatewayError(part.error) },
|
|
4939
|
+
callbacks: onError
|
|
4940
|
+
});
|
|
4925
4941
|
}
|
|
4926
4942
|
if (part.type === "text-start") {
|
|
4927
4943
|
activeTextContent[part.id] = {
|
|
@@ -7767,7 +7783,10 @@ var DefaultStreamObjectResult = class {
|
|
|
7767
7783
|
transform(chunk, controller) {
|
|
7768
7784
|
controller.enqueue(chunk);
|
|
7769
7785
|
if (chunk.type === "error") {
|
|
7770
|
-
|
|
7786
|
+
void notify({
|
|
7787
|
+
event: { error: wrapGatewayError(chunk.error) },
|
|
7788
|
+
callbacks: onError
|
|
7789
|
+
});
|
|
7771
7790
|
}
|
|
7772
7791
|
}
|
|
7773
7792
|
});
|
|
@@ -8089,7 +8108,10 @@ var DefaultStreamObjectResult = class {
|
|
|
8089
8108
|
onError(error2) {
|
|
8090
8109
|
const wrappedError = wrapGatewayError(error2);
|
|
8091
8110
|
self.rejectResultPromises(wrappedError);
|
|
8092
|
-
void
|
|
8111
|
+
void notify({
|
|
8112
|
+
event: { error: wrappedError },
|
|
8113
|
+
callbacks: onError
|
|
8114
|
+
});
|
|
8093
8115
|
}
|
|
8094
8116
|
});
|
|
8095
8117
|
}
|