ai 5.0.20 → 5.0.21
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 +10 -0
- package/dist/index.d.mts +25 -11
- package/dist/index.d.ts +25 -11
- package/dist/index.js +32 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -39
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +25 -11
- package/dist/internal/index.d.ts +25 -11
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 5.0.21
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 581abea: fix(ai): call abort callback when stream is aborted during tool execution
|
8
|
+
- 3c178ec: feat(ai): improved type checking for prompt/messages input
|
9
|
+
- Updated dependencies [0857788]
|
10
|
+
- @ai-sdk/provider-utils@3.0.5
|
11
|
+
- @ai-sdk/gateway@1.0.10
|
12
|
+
|
3
13
|
## 5.0.20
|
4
14
|
|
5
15
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -89,19 +89,33 @@ type Prompt = {
|
|
89
89
|
System message to include in the prompt. Can be used with `prompt` or `messages`.
|
90
90
|
*/
|
91
91
|
system?: string;
|
92
|
+
} & ({
|
92
93
|
/**
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
prompt
|
94
|
+
A prompt. It can be either a text prompt or a list of messages.
|
95
|
+
|
96
|
+
You can either use `prompt` or `messages` but not both.
|
97
|
+
*/
|
98
|
+
prompt: string | Array<ModelMessage>;
|
98
99
|
/**
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
messages?:
|
104
|
-
}
|
100
|
+
A list of messages.
|
101
|
+
|
102
|
+
You can either use `prompt` or `messages` but not both.
|
103
|
+
*/
|
104
|
+
messages?: never;
|
105
|
+
} | {
|
106
|
+
/**
|
107
|
+
A list of messages.
|
108
|
+
|
109
|
+
You can either use `prompt` or `messages` but not both.
|
110
|
+
*/
|
111
|
+
messages: Array<ModelMessage>;
|
112
|
+
/**
|
113
|
+
A prompt. It can be either a text prompt or a list of messages.
|
114
|
+
|
115
|
+
You can either use `prompt` or `messages` but not both.
|
116
|
+
*/
|
117
|
+
prompt?: never;
|
118
|
+
});
|
105
119
|
|
106
120
|
/**
|
107
121
|
* Telemetry configuration.
|
package/dist/index.d.ts
CHANGED
@@ -89,19 +89,33 @@ type Prompt = {
|
|
89
89
|
System message to include in the prompt. Can be used with `prompt` or `messages`.
|
90
90
|
*/
|
91
91
|
system?: string;
|
92
|
+
} & ({
|
92
93
|
/**
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
prompt
|
94
|
+
A prompt. It can be either a text prompt or a list of messages.
|
95
|
+
|
96
|
+
You can either use `prompt` or `messages` but not both.
|
97
|
+
*/
|
98
|
+
prompt: string | Array<ModelMessage>;
|
98
99
|
/**
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
messages?:
|
104
|
-
}
|
100
|
+
A list of messages.
|
101
|
+
|
102
|
+
You can either use `prompt` or `messages` but not both.
|
103
|
+
*/
|
104
|
+
messages?: never;
|
105
|
+
} | {
|
106
|
+
/**
|
107
|
+
A list of messages.
|
108
|
+
|
109
|
+
You can either use `prompt` or `messages` but not both.
|
110
|
+
*/
|
111
|
+
messages: Array<ModelMessage>;
|
112
|
+
/**
|
113
|
+
A prompt. It can be either a text prompt or a list of messages.
|
114
|
+
|
115
|
+
You can either use `prompt` or `messages` but not both.
|
116
|
+
*/
|
117
|
+
prompt?: never;
|
118
|
+
});
|
105
119
|
|
106
120
|
/**
|
107
121
|
* Telemetry configuration.
|
package/dist/index.js
CHANGED
@@ -4046,30 +4046,6 @@ var DelayedPromise = class {
|
|
4046
4046
|
}
|
4047
4047
|
};
|
4048
4048
|
|
4049
|
-
// src/util/filter-stream-errors.ts
|
4050
|
-
function filterStreamErrors(readable, onError) {
|
4051
|
-
return new ReadableStream({
|
4052
|
-
async start(controller) {
|
4053
|
-
const reader = readable.getReader();
|
4054
|
-
try {
|
4055
|
-
while (true) {
|
4056
|
-
const { done, value } = await reader.read();
|
4057
|
-
if (done) {
|
4058
|
-
controller.close();
|
4059
|
-
break;
|
4060
|
-
}
|
4061
|
-
controller.enqueue(value);
|
4062
|
-
}
|
4063
|
-
} catch (error) {
|
4064
|
-
await onError({ error, controller });
|
4065
|
-
}
|
4066
|
-
},
|
4067
|
-
cancel(reason) {
|
4068
|
-
return readable.cancel(reason);
|
4069
|
-
}
|
4070
|
-
});
|
4071
|
-
}
|
4072
|
-
|
4073
4049
|
// src/util/now.ts
|
4074
4050
|
function now() {
|
4075
4051
|
var _a17, _b;
|
@@ -4704,23 +4680,40 @@ var DefaultStreamTextResult = class {
|
|
4704
4680
|
const stitchableStream = createStitchableStream();
|
4705
4681
|
this.addStream = stitchableStream.addStream;
|
4706
4682
|
this.closeStream = stitchableStream.close;
|
4707
|
-
|
4708
|
-
stream =
|
4709
|
-
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4683
|
+
const reader = stitchableStream.stream.getReader();
|
4684
|
+
let stream = new ReadableStream({
|
4685
|
+
async start(controller) {
|
4686
|
+
controller.enqueue({ type: "start" });
|
4687
|
+
},
|
4688
|
+
async pull(controller) {
|
4689
|
+
function abort() {
|
4690
|
+
onAbort == null ? void 0 : onAbort({ steps: recordedSteps });
|
4691
|
+
controller.enqueue({ type: "abort" });
|
4692
|
+
controller.close();
|
4693
|
+
}
|
4694
|
+
try {
|
4695
|
+
const { done, value } = await reader.read();
|
4696
|
+
if (done) {
|
4697
|
+
controller.close();
|
4698
|
+
return;
|
4699
|
+
}
|
4700
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
4701
|
+
abort();
|
4702
|
+
return;
|
4703
|
+
}
|
4704
|
+
controller.enqueue(value);
|
4705
|
+
} catch (error) {
|
4706
|
+
if ((0, import_provider_utils13.isAbortError)(error) && (abortSignal == null ? void 0 : abortSignal.aborted)) {
|
4707
|
+
abort();
|
4708
|
+
} else {
|
4709
|
+
controller.error(error);
|
4710
|
+
}
|
4711
|
+
}
|
4712
|
+
},
|
4713
|
+
cancel(reason) {
|
4714
|
+
return stitchableStream.stream.cancel(reason);
|
4715
4715
|
}
|
4716
4716
|
});
|
4717
|
-
stream = stream.pipeThrough(
|
4718
|
-
new TransformStream({
|
4719
|
-
start(controller) {
|
4720
|
-
controller.enqueue({ type: "start" });
|
4721
|
-
}
|
4722
|
-
})
|
4723
|
-
);
|
4724
4717
|
for (const transform of transforms) {
|
4725
4718
|
stream = stream.pipeThrough(
|
4726
4719
|
transform({
|