ai 6.0.330 → 6.0.332
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 +17 -0
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +379 -267
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +379 -267
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/04-ai-sdk-ui/02-chatbot.mdx +9 -10
- package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +70 -33
- package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +8 -1
- package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +3 -1
- package/package.json +4 -4
- package/src/generate-text/stream-text-result.ts +21 -2
- package/src/generate-text/stream-text.ts +25 -3
- package/src/ui/validate-ui-messages.ts +424 -266
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 6.0.332
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [23ff635]
|
|
8
|
+
- @ai-sdk/gateway@3.0.237
|
|
9
|
+
|
|
10
|
+
## 6.0.331
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 60dc26c: Keep failed tool call error text consistent with the model's message history by default. Set `redactToolErrors: true` to replace it with the result of `onError`.
|
|
15
|
+
- 9e8f918: Prevent excessive memory and CPU usage when validating malformed UI messages. `validateUIMessages`, `safeValidateUIMessages`, and the agent UI stream helpers reported the issues of every part schema for every invalid part, so a small request with many malformed parts could exhaust memory. Each part is now validated against the schemas for its type only, validation stops at the first invalid message or part, and an invalid JSON value in provider or tool metadata is reported as a single issue.
|
|
16
|
+
- Updated dependencies [271ca50]
|
|
17
|
+
- Updated dependencies [f0a7beb]
|
|
18
|
+
- @ai-sdk/gateway@3.0.236
|
|
19
|
+
|
|
3
20
|
## 6.0.330
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -2288,14 +2288,32 @@ type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
|
|
2288
2288
|
/**
|
|
2289
2289
|
* Process an error, e.g. to log it. Default to `() => 'An error occurred.'`.
|
|
2290
2290
|
*
|
|
2291
|
+
* This callback handles stream errors. It also handles failed tool calls
|
|
2292
|
+
* (tool execution errors and invalid tool calls) when `redactToolErrors` is
|
|
2293
|
+
* enabled, which is the default when this callback is provided.
|
|
2294
|
+
*
|
|
2291
2295
|
* Tool execution errors marked `providerExecuted: true` bypass this callback.
|
|
2292
2296
|
* Their strings pass through unchanged; other values are JSON-stringified to
|
|
2293
|
-
* preserve provider error data for model-message round trips.
|
|
2294
|
-
*
|
|
2297
|
+
* preserve provider error data for model-message round trips. Invalid tool
|
|
2298
|
+
* calls of provider-executed tools always use it.
|
|
2295
2299
|
*
|
|
2296
2300
|
* @returns error message to include in the data stream.
|
|
2297
2301
|
*/
|
|
2298
2302
|
onError?: (error: unknown) => string;
|
|
2303
|
+
/**
|
|
2304
|
+
* Replace the error text of failed tool calls (tool execution errors and
|
|
2305
|
+
* invalid tool calls) with the result of `onError`.
|
|
2306
|
+
*
|
|
2307
|
+
* By default, the client receives the same error text as the model. UI
|
|
2308
|
+
* messages are sent back to the model on the next request, so a different
|
|
2309
|
+
* text changes the history that the model's reasoning and answers are based
|
|
2310
|
+
* on. Some models reject such a history, for example Anthropic models with
|
|
2311
|
+
* preserved thinking. To keep error details away from the client, throw a
|
|
2312
|
+
* safe error from the tool's `execute` function.
|
|
2313
|
+
*
|
|
2314
|
+
* Defaults to `true` when `onError` is provided, and `false` otherwise.
|
|
2315
|
+
*/
|
|
2316
|
+
redactToolErrors?: boolean;
|
|
2299
2317
|
};
|
|
2300
2318
|
type ConsumeStreamOptions = {
|
|
2301
2319
|
onError?: ErrorHandler;
|
package/dist/index.d.ts
CHANGED
|
@@ -2288,14 +2288,32 @@ type UIMessageStreamOptions<UI_MESSAGE extends UIMessage> = {
|
|
|
2288
2288
|
/**
|
|
2289
2289
|
* Process an error, e.g. to log it. Default to `() => 'An error occurred.'`.
|
|
2290
2290
|
*
|
|
2291
|
+
* This callback handles stream errors. It also handles failed tool calls
|
|
2292
|
+
* (tool execution errors and invalid tool calls) when `redactToolErrors` is
|
|
2293
|
+
* enabled, which is the default when this callback is provided.
|
|
2294
|
+
*
|
|
2291
2295
|
* Tool execution errors marked `providerExecuted: true` bypass this callback.
|
|
2292
2296
|
* Their strings pass through unchanged; other values are JSON-stringified to
|
|
2293
|
-
* preserve provider error data for model-message round trips.
|
|
2294
|
-
*
|
|
2297
|
+
* preserve provider error data for model-message round trips. Invalid tool
|
|
2298
|
+
* calls of provider-executed tools always use it.
|
|
2295
2299
|
*
|
|
2296
2300
|
* @returns error message to include in the data stream.
|
|
2297
2301
|
*/
|
|
2298
2302
|
onError?: (error: unknown) => string;
|
|
2303
|
+
/**
|
|
2304
|
+
* Replace the error text of failed tool calls (tool execution errors and
|
|
2305
|
+
* invalid tool calls) with the result of `onError`.
|
|
2306
|
+
*
|
|
2307
|
+
* By default, the client receives the same error text as the model. UI
|
|
2308
|
+
* messages are sent back to the model on the next request, so a different
|
|
2309
|
+
* text changes the history that the model's reasoning and answers are based
|
|
2310
|
+
* on. Some models reject such a history, for example Anthropic models with
|
|
2311
|
+
* preserved thinking. To keep error details away from the client, throw a
|
|
2312
|
+
* safe error from the tool's `execute` function.
|
|
2313
|
+
*
|
|
2314
|
+
* Defaults to `true` when `onError` is provided, and `false` otherwise.
|
|
2315
|
+
*/
|
|
2316
|
+
redactToolErrors?: boolean;
|
|
2299
2317
|
};
|
|
2300
2318
|
type ConsumeStreamOptions = {
|
|
2301
2319
|
onError?: ErrorHandler;
|