ai 5.0.0-beta.33 → 5.0.0-beta.34
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 +12 -0
- package/dist/index.d.mts +77 -6
- package/dist/index.d.ts +77 -6
- package/dist/index.js +200 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +161 -101
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -1
- package/dist/internal/index.d.ts +2 -1
- package/dist/internal/index.js +34 -16
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +34 -16
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# ai
|
2
2
|
|
3
|
+
## 5.0.0-beta.34
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 53569b8: feat (ai): add experimental repairText function to streamObject
|
8
|
+
- 88a8ee5: fix (ai): support abort during retry waits
|
9
|
+
- f2c7f19: feat (ui): add Chat.clearError()
|
10
|
+
- Updated dependencies [721775e]
|
11
|
+
- Updated dependencies [88a8ee5]
|
12
|
+
- @ai-sdk/gateway@1.0.0-beta.19
|
13
|
+
- @ai-sdk/provider-utils@3.0.0-beta.10
|
14
|
+
|
3
15
|
## 5.0.0-beta.33
|
4
16
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
@@ -2651,7 +2651,7 @@ interface GenerateObjectResult<OBJECT> {
|
|
2651
2651
|
}
|
2652
2652
|
|
2653
2653
|
/**
|
2654
|
-
A function that attempts to repair the raw output of the
|
2654
|
+
A function that attempts to repair the raw output of the model
|
2655
2655
|
to enable JSON parsing.
|
2656
2656
|
|
2657
2657
|
Should return the repaired text or null if the text cannot be repaired.
|
@@ -2660,6 +2660,7 @@ type RepairTextFunction = (options: {
|
|
2660
2660
|
text: string;
|
2661
2661
|
error: JSONParseError | TypeValidationError;
|
2662
2662
|
}) => Promise<string | null>;
|
2663
|
+
|
2663
2664
|
/**
|
2664
2665
|
Generate a structured, typed object for a given prompt and schema using a language model.
|
2665
2666
|
|
@@ -2712,7 +2713,7 @@ via tool or schema description.
|
|
2712
2713
|
- 'enum': The output is an enum.
|
2713
2714
|
- 'no-schema': The output is not a schema.
|
2714
2715
|
|
2715
|
-
@param experimental_repairText - A function that attempts to repair the raw output of the
|
2716
|
+
@param experimental_repairText - A function that attempts to repair the raw output of the model
|
2716
2717
|
to enable JSON parsing.
|
2717
2718
|
|
2718
2719
|
@param experimental_telemetry - Optional telemetry configuration (experimental).
|
@@ -2769,7 +2770,7 @@ The language model to use.
|
|
2769
2770
|
*/
|
2770
2771
|
model: LanguageModel;
|
2771
2772
|
/**
|
2772
|
-
A function that attempts to repair the raw output of the
|
2773
|
+
A function that attempts to repair the raw output of the model
|
2773
2774
|
to enable JSON parsing.
|
2774
2775
|
*/
|
2775
2776
|
experimental_repairText?: RepairTextFunction;
|
@@ -3107,6 +3108,11 @@ The language model to use.
|
|
3107
3108
|
*/
|
3108
3109
|
model: LanguageModel;
|
3109
3110
|
/**
|
3111
|
+
A function that attempts to repair the raw output of the model
|
3112
|
+
to enable JSON parsing.
|
3113
|
+
*/
|
3114
|
+
experimental_repairText?: RepairTextFunction;
|
3115
|
+
/**
|
3110
3116
|
Optional telemetry configuration (experimental).
|
3111
3117
|
*/
|
3112
3118
|
experimental_telemetry?: TelemetrySettings;
|
@@ -3769,16 +3775,77 @@ declare const UI_MESSAGE_STREAM_HEADERS: {
|
|
3769
3775
|
'x-accel-buffering': string;
|
3770
3776
|
};
|
3771
3777
|
|
3778
|
+
/**
|
3779
|
+
* Transport interface for handling chat message communication and streaming.
|
3780
|
+
*
|
3781
|
+
* The `ChatTransport` interface provides fine-grained control over how messages
|
3782
|
+
* are sent to API endpoints and how responses are processed. This enables
|
3783
|
+
* alternative communication protocols like WebSockets, custom authentication
|
3784
|
+
* patterns, or specialized backend integrations.
|
3785
|
+
*
|
3786
|
+
* @template UI_MESSAGE - The UI message type extending UIMessage
|
3787
|
+
*/
|
3772
3788
|
interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
3789
|
+
/**
|
3790
|
+
* Sends messages to the chat API endpoint and returns a streaming response.
|
3791
|
+
*
|
3792
|
+
* This method handles both new message submission and message regeneration.
|
3793
|
+
* It supports real-time streaming of responses through UIMessageChunk events.
|
3794
|
+
*
|
3795
|
+
* @param options - Configuration object containing:
|
3796
|
+
* @param options.trigger - The type of message submission:
|
3797
|
+
* - `'submit-message'`: Submitting a new user message
|
3798
|
+
* - `'regenerate-message'`: Regenerating an assistant response
|
3799
|
+
* @param options.chatId - Unique identifier for the chat session
|
3800
|
+
* @param options.messageId - ID of the message to regenerate (for regenerate-message trigger) or undefined for new messages
|
3801
|
+
* @param options.messages - Array of UI messages representing the conversation history
|
3802
|
+
* @param options.abortSignal - Signal to abort the request if needed
|
3803
|
+
* @param options.headers - Additional HTTP headers to include in the request
|
3804
|
+
* @param options.body - Additional JSON properties to include in the request body
|
3805
|
+
* @param options.metadata - Custom metadata to attach to the request
|
3806
|
+
*
|
3807
|
+
* @returns Promise resolving to a ReadableStream of UIMessageChunk objects.
|
3808
|
+
* The stream emits various chunk types like:
|
3809
|
+
* - `text-start`, `text-delta`, `text-end`: For streaming text content
|
3810
|
+
* - `tool-input-start`, `tool-input-delta`, `tool-input-available`: For tool calls
|
3811
|
+
* - `data-part-start`, `data-part-delta`, `data-part-available`: For data parts
|
3812
|
+
* - `error`: For error handling
|
3813
|
+
*
|
3814
|
+
* @throws Error when the API request fails or response is invalid
|
3815
|
+
*/
|
3773
3816
|
sendMessages: (options: {
|
3817
|
+
/** The type of message submission - either new message or regeneration */
|
3818
|
+
trigger: 'submit-message' | 'regenerate-message';
|
3819
|
+
/** Unique identifier for the chat session */
|
3774
3820
|
chatId: string;
|
3821
|
+
/** ID of the message to regenerate, or undefined for new messages */
|
3822
|
+
messageId: string | undefined;
|
3823
|
+
/** Array of UI messages representing the conversation history */
|
3775
3824
|
messages: UI_MESSAGE[];
|
3825
|
+
/** Signal to abort the request if needed */
|
3776
3826
|
abortSignal: AbortSignal | undefined;
|
3777
|
-
} & {
|
3778
|
-
trigger: 'submit-message' | 'regenerate-message';
|
3779
|
-
messageId: string | undefined;
|
3780
3827
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
3828
|
+
/**
|
3829
|
+
* Reconnects to an existing streaming response for the specified chat session.
|
3830
|
+
*
|
3831
|
+
* This method is used to resume streaming when a connection is interrupted
|
3832
|
+
* or when resuming a chat session. It's particularly useful for maintaining
|
3833
|
+
* continuity in long-running conversations or recovering from network issues.
|
3834
|
+
*
|
3835
|
+
* @param options - Configuration object containing:
|
3836
|
+
* @param options.chatId - Unique identifier for the chat session to reconnect to
|
3837
|
+
* @param options.headers - Additional HTTP headers to include in the reconnection request
|
3838
|
+
* @param options.body - Additional JSON properties to include in the request body
|
3839
|
+
* @param options.metadata - Custom metadata to attach to the request
|
3840
|
+
*
|
3841
|
+
* @returns Promise resolving to:
|
3842
|
+
* - `ReadableStream<UIMessageChunk>`: If an active stream is found and can be resumed
|
3843
|
+
* - `null`: If no active stream exists for the specified chat session (e.g., response already completed)
|
3844
|
+
*
|
3845
|
+
* @throws Error when the reconnection request fails or response is invalid
|
3846
|
+
*/
|
3781
3847
|
reconnectToStream: (options: {
|
3848
|
+
/** Unique identifier for the chat session to reconnect to */
|
3782
3849
|
chatId: string;
|
3783
3850
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk> | null>;
|
3784
3851
|
}
|
@@ -3937,6 +4004,10 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3937
4004
|
* Attempt to resume an ongoing streaming response.
|
3938
4005
|
*/
|
3939
4006
|
resumeStream: (options?: ChatRequestOptions) => Promise<void>;
|
4007
|
+
/**
|
4008
|
+
* Clear the error state and set the status to ready if the chat is in an error state.
|
4009
|
+
*/
|
4010
|
+
clearError: () => void;
|
3940
4011
|
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ tool, toolCallId, output, }: {
|
3941
4012
|
tool: TOOL;
|
3942
4013
|
toolCallId: string;
|
package/dist/index.d.ts
CHANGED
@@ -2651,7 +2651,7 @@ interface GenerateObjectResult<OBJECT> {
|
|
2651
2651
|
}
|
2652
2652
|
|
2653
2653
|
/**
|
2654
|
-
A function that attempts to repair the raw output of the
|
2654
|
+
A function that attempts to repair the raw output of the model
|
2655
2655
|
to enable JSON parsing.
|
2656
2656
|
|
2657
2657
|
Should return the repaired text or null if the text cannot be repaired.
|
@@ -2660,6 +2660,7 @@ type RepairTextFunction = (options: {
|
|
2660
2660
|
text: string;
|
2661
2661
|
error: JSONParseError | TypeValidationError;
|
2662
2662
|
}) => Promise<string | null>;
|
2663
|
+
|
2663
2664
|
/**
|
2664
2665
|
Generate a structured, typed object for a given prompt and schema using a language model.
|
2665
2666
|
|
@@ -2712,7 +2713,7 @@ via tool or schema description.
|
|
2712
2713
|
- 'enum': The output is an enum.
|
2713
2714
|
- 'no-schema': The output is not a schema.
|
2714
2715
|
|
2715
|
-
@param experimental_repairText - A function that attempts to repair the raw output of the
|
2716
|
+
@param experimental_repairText - A function that attempts to repair the raw output of the model
|
2716
2717
|
to enable JSON parsing.
|
2717
2718
|
|
2718
2719
|
@param experimental_telemetry - Optional telemetry configuration (experimental).
|
@@ -2769,7 +2770,7 @@ The language model to use.
|
|
2769
2770
|
*/
|
2770
2771
|
model: LanguageModel;
|
2771
2772
|
/**
|
2772
|
-
A function that attempts to repair the raw output of the
|
2773
|
+
A function that attempts to repair the raw output of the model
|
2773
2774
|
to enable JSON parsing.
|
2774
2775
|
*/
|
2775
2776
|
experimental_repairText?: RepairTextFunction;
|
@@ -3107,6 +3108,11 @@ The language model to use.
|
|
3107
3108
|
*/
|
3108
3109
|
model: LanguageModel;
|
3109
3110
|
/**
|
3111
|
+
A function that attempts to repair the raw output of the model
|
3112
|
+
to enable JSON parsing.
|
3113
|
+
*/
|
3114
|
+
experimental_repairText?: RepairTextFunction;
|
3115
|
+
/**
|
3110
3116
|
Optional telemetry configuration (experimental).
|
3111
3117
|
*/
|
3112
3118
|
experimental_telemetry?: TelemetrySettings;
|
@@ -3769,16 +3775,77 @@ declare const UI_MESSAGE_STREAM_HEADERS: {
|
|
3769
3775
|
'x-accel-buffering': string;
|
3770
3776
|
};
|
3771
3777
|
|
3778
|
+
/**
|
3779
|
+
* Transport interface for handling chat message communication and streaming.
|
3780
|
+
*
|
3781
|
+
* The `ChatTransport` interface provides fine-grained control over how messages
|
3782
|
+
* are sent to API endpoints and how responses are processed. This enables
|
3783
|
+
* alternative communication protocols like WebSockets, custom authentication
|
3784
|
+
* patterns, or specialized backend integrations.
|
3785
|
+
*
|
3786
|
+
* @template UI_MESSAGE - The UI message type extending UIMessage
|
3787
|
+
*/
|
3772
3788
|
interface ChatTransport<UI_MESSAGE extends UIMessage> {
|
3789
|
+
/**
|
3790
|
+
* Sends messages to the chat API endpoint and returns a streaming response.
|
3791
|
+
*
|
3792
|
+
* This method handles both new message submission and message regeneration.
|
3793
|
+
* It supports real-time streaming of responses through UIMessageChunk events.
|
3794
|
+
*
|
3795
|
+
* @param options - Configuration object containing:
|
3796
|
+
* @param options.trigger - The type of message submission:
|
3797
|
+
* - `'submit-message'`: Submitting a new user message
|
3798
|
+
* - `'regenerate-message'`: Regenerating an assistant response
|
3799
|
+
* @param options.chatId - Unique identifier for the chat session
|
3800
|
+
* @param options.messageId - ID of the message to regenerate (for regenerate-message trigger) or undefined for new messages
|
3801
|
+
* @param options.messages - Array of UI messages representing the conversation history
|
3802
|
+
* @param options.abortSignal - Signal to abort the request if needed
|
3803
|
+
* @param options.headers - Additional HTTP headers to include in the request
|
3804
|
+
* @param options.body - Additional JSON properties to include in the request body
|
3805
|
+
* @param options.metadata - Custom metadata to attach to the request
|
3806
|
+
*
|
3807
|
+
* @returns Promise resolving to a ReadableStream of UIMessageChunk objects.
|
3808
|
+
* The stream emits various chunk types like:
|
3809
|
+
* - `text-start`, `text-delta`, `text-end`: For streaming text content
|
3810
|
+
* - `tool-input-start`, `tool-input-delta`, `tool-input-available`: For tool calls
|
3811
|
+
* - `data-part-start`, `data-part-delta`, `data-part-available`: For data parts
|
3812
|
+
* - `error`: For error handling
|
3813
|
+
*
|
3814
|
+
* @throws Error when the API request fails or response is invalid
|
3815
|
+
*/
|
3773
3816
|
sendMessages: (options: {
|
3817
|
+
/** The type of message submission - either new message or regeneration */
|
3818
|
+
trigger: 'submit-message' | 'regenerate-message';
|
3819
|
+
/** Unique identifier for the chat session */
|
3774
3820
|
chatId: string;
|
3821
|
+
/** ID of the message to regenerate, or undefined for new messages */
|
3822
|
+
messageId: string | undefined;
|
3823
|
+
/** Array of UI messages representing the conversation history */
|
3775
3824
|
messages: UI_MESSAGE[];
|
3825
|
+
/** Signal to abort the request if needed */
|
3776
3826
|
abortSignal: AbortSignal | undefined;
|
3777
|
-
} & {
|
3778
|
-
trigger: 'submit-message' | 'regenerate-message';
|
3779
|
-
messageId: string | undefined;
|
3780
3827
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk>>;
|
3828
|
+
/**
|
3829
|
+
* Reconnects to an existing streaming response for the specified chat session.
|
3830
|
+
*
|
3831
|
+
* This method is used to resume streaming when a connection is interrupted
|
3832
|
+
* or when resuming a chat session. It's particularly useful for maintaining
|
3833
|
+
* continuity in long-running conversations or recovering from network issues.
|
3834
|
+
*
|
3835
|
+
* @param options - Configuration object containing:
|
3836
|
+
* @param options.chatId - Unique identifier for the chat session to reconnect to
|
3837
|
+
* @param options.headers - Additional HTTP headers to include in the reconnection request
|
3838
|
+
* @param options.body - Additional JSON properties to include in the request body
|
3839
|
+
* @param options.metadata - Custom metadata to attach to the request
|
3840
|
+
*
|
3841
|
+
* @returns Promise resolving to:
|
3842
|
+
* - `ReadableStream<UIMessageChunk>`: If an active stream is found and can be resumed
|
3843
|
+
* - `null`: If no active stream exists for the specified chat session (e.g., response already completed)
|
3844
|
+
*
|
3845
|
+
* @throws Error when the reconnection request fails or response is invalid
|
3846
|
+
*/
|
3781
3847
|
reconnectToStream: (options: {
|
3848
|
+
/** Unique identifier for the chat session to reconnect to */
|
3782
3849
|
chatId: string;
|
3783
3850
|
} & ChatRequestOptions) => Promise<ReadableStream<UIMessageChunk> | null>;
|
3784
3851
|
}
|
@@ -3937,6 +4004,10 @@ declare abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
3937
4004
|
* Attempt to resume an ongoing streaming response.
|
3938
4005
|
*/
|
3939
4006
|
resumeStream: (options?: ChatRequestOptions) => Promise<void>;
|
4007
|
+
/**
|
4008
|
+
* Clear the error state and set the status to ready if the chat is in an error state.
|
4009
|
+
*/
|
4010
|
+
clearError: () => void;
|
3940
4011
|
addToolResult: <TOOL extends keyof InferUIMessageTools<UI_MESSAGE>>({ tool, toolCallId, output, }: {
|
3941
4012
|
tool: TOOL;
|
3942
4013
|
toolCallId: string;
|