@ai-sdk/workflow 2.0.53 → 2.0.54

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @ai-sdk/workflow
2
2
 
3
+ ## 2.0.54
4
+
5
+ ### Patch Changes
6
+
7
+ - 70c051c: fix(workflow): preserve reasoning and provider metadata across agent steps
8
+ - ede5b89: chore: migrate package builds from tsup to tsdown
9
+ - Updated dependencies [05cdac6]
10
+ - Updated dependencies [4514fc1]
11
+ - Updated dependencies [ede5b89]
12
+ - Updated dependencies [2a625cf]
13
+ - Updated dependencies [50a26d5]
14
+ - ai@7.0.123
15
+ - @ai-sdk/provider@4.0.20
16
+ - @ai-sdk/provider-utils@5.0.52
17
+
3
18
  ## 2.0.53
4
19
 
5
20
  ### Patch Changes
package/dist/client.d.ts CHANGED
@@ -1,160 +1,2 @@
1
- import { UIMessage, ChatTransport, PrepareSendMessagesRequest, PrepareReconnectToStreamRequest, ChatRequestOptions, UIMessageChunk } from 'ai';
2
-
3
- interface SendMessagesOptions<UI_MESSAGE extends UIMessage> {
4
- trigger: 'submit-message' | 'regenerate-message';
5
- chatId: string;
6
- messageId?: string;
7
- messages: UI_MESSAGE[];
8
- abortSignal?: AbortSignal;
9
- }
10
- interface ReconnectToStreamOptions {
11
- chatId: string;
12
- abortSignal?: AbortSignal;
13
- /**
14
- * Override the `startIndex` for this reconnection.
15
- * Negative values read from the end when the server's durable stream and
16
- * tail-index header use the same UIMessageChunk index space.
17
- * When omitted, falls back to the constructor's `initialStartIndex`.
18
- */
19
- startIndex?: number;
20
- }
21
- type OnChatSendMessage<UI_MESSAGE extends UIMessage> = (response: Response, options: SendMessagesOptions<UI_MESSAGE>) => void | Promise<void>;
22
- type OnChatEnd = ({ chatId, chunkIndex, }: {
23
- chatId: string;
24
- chunkIndex: number;
25
- }) => void | Promise<void>;
26
- /**
27
- * Configuration options for the WorkflowChatTransport.
28
- *
29
- * @template UI_MESSAGE - The type of UI messages being sent and received,
30
- * must extend the UIMessage interface from the AI SDK.
31
- */
32
- interface WorkflowChatTransportOptions<UI_MESSAGE extends UIMessage> {
33
- /**
34
- * API endpoint for chat requests
35
- * Defaults to /api/chat if not provided
36
- */
37
- api?: string;
38
- /**
39
- * Custom fetch implementation to use for HTTP requests.
40
- * Defaults to the global fetch function if not provided.
41
- */
42
- fetch?: typeof fetch;
43
- /**
44
- * Callback invoked after successfully sending messages to the chat endpoint.
45
- * Useful for tracking chat history and inspecting response headers.
46
- *
47
- * @param response - The HTTP response object from the chat endpoint
48
- * @param options - The original options passed to sendMessages
49
- */
50
- onChatSendMessage?: OnChatSendMessage<UI_MESSAGE>;
51
- /**
52
- * Callback invoked when a chat stream ends (receives a "finish" chunk).
53
- * Useful for cleanup operations or state updates.
54
- *
55
- * @param chatId - The ID of the chat that ended
56
- * @param chunkIndex - The total number of chunks received
57
- */
58
- onChatEnd?: OnChatEnd;
59
- /**
60
- * Maximum number of consecutive errors allowed during reconnection attempts.
61
- * Defaults to 3 if not provided.
62
- */
63
- maxConsecutiveErrors?: number;
64
- /**
65
- * Default `startIndex` to use when reconnecting to a stream without a known
66
- * chunk position (i.e. the initial reconnection, not a retry).
67
- * Negative values read from the end of a durable UIMessageChunk stream (e.g.
68
- * `-10` fetches the last 10 chunks), which is useful for resuming a chat UI
69
- * after a page refresh without replaying the full conversation. Raw
70
- * ModelCallStreamPart streams do not support negative UI chunk indexes.
71
- *
72
- * Can be overridden per-call via `ReconnectToStreamOptions.startIndex`.
73
- *
74
- * Defaults to `0` (replay from the beginning).
75
- */
76
- initialStartIndex?: number;
77
- /**
78
- * Function to prepare the request for sending messages.
79
- * Allows customizing the API endpoint, headers, credentials, and body.
80
- */
81
- prepareSendMessagesRequest?: PrepareSendMessagesRequest<UI_MESSAGE>;
82
- /**
83
- * Function to prepare the request for reconnecting to a stream.
84
- * Allows customizing the API endpoint, headers, and credentials.
85
- */
86
- prepareReconnectToStreamRequest?: PrepareReconnectToStreamRequest;
87
- }
88
- /**
89
- * A transport implementation for managing chat workflows with support for
90
- * streaming responses and automatic reconnection to interrupted streams.
91
- *
92
- * This class implements the ChatTransport interface from the AI SDK and provides
93
- * reliable message streaming with automatic recovery from network interruptions
94
- * or function timeouts.
95
- *
96
- * @template UI_MESSAGE - The type of UI messages being sent and received,
97
- * must extend the UIMessage interface from the AI SDK.
98
- *
99
- * @implements {ChatTransport<UI_MESSAGE>}
100
- */
101
- declare class WorkflowChatTransport<UI_MESSAGE extends UIMessage> implements ChatTransport<UI_MESSAGE> {
102
- private readonly api;
103
- private readonly fetch;
104
- private readonly onChatSendMessage?;
105
- private readonly onChatEnd?;
106
- private readonly maxConsecutiveErrors;
107
- private readonly initialStartIndex;
108
- private readonly prepareSendMessagesRequest?;
109
- private readonly prepareReconnectToStreamRequest?;
110
- /**
111
- * Creates a new WorkflowChatTransport instance.
112
- *
113
- * @param options - Configuration options for the transport
114
- * @param options.api - API endpoint for chat requests (defaults to '/api/chat')
115
- * @param options.fetch - Custom fetch implementation (defaults to global fetch)
116
- * @param options.onChatSendMessage - Callback after sending messages
117
- * @param options.onChatEnd - Callback when chat stream ends
118
- * @param options.maxConsecutiveErrors - Maximum consecutive errors for reconnection
119
- * @param options.prepareSendMessagesRequest - Function to prepare send messages request
120
- * @param options.prepareReconnectToStreamRequest - Function to prepare reconnect request
121
- */
122
- constructor(options?: WorkflowChatTransportOptions<UI_MESSAGE>);
123
- /**
124
- * Sends messages to the chat endpoint and returns a stream of response chunks.
125
- *
126
- * This method handles the entire chat lifecycle including:
127
- * - Sending messages to the /api/chat endpoint
128
- * - Streaming response chunks
129
- * - Automatic reconnection if the stream is interrupted
130
- *
131
- * @param options - Options for sending messages
132
- * @param options.trigger - The type of message submission ('submit-message' or 'regenerate-message')
133
- * @param options.chatId - Unique identifier for this chat session
134
- * @param options.messageId - Optional message ID for tracking specific messages
135
- * @param options.messages - Array of UI messages to send
136
- * @param options.abortSignal - Optional AbortSignal to cancel the request
137
- *
138
- * @returns A ReadableStream of UIMessageChunk objects containing the response
139
- * @throws Error if the fetch request fails or returns a non-OK status
140
- */
141
- sendMessages(options: SendMessagesOptions<UI_MESSAGE> & ChatRequestOptions): Promise<ReadableStream<UIMessageChunk>>;
142
- private sendMessagesIterator;
143
- /**
144
- * Reconnects to an existing chat stream that was previously interrupted.
145
- *
146
- * This method is useful for resuming a chat session after network issues,
147
- * page refreshes, or Vercel Function timeouts.
148
- *
149
- * @param options - Options for reconnecting to the stream
150
- * @param options.chatId - The chat ID to reconnect to
151
- *
152
- * @returns A ReadableStream of UIMessageChunk objects
153
- * @throws Error if the reconnection request fails or returns a non-OK status
154
- */
155
- reconnectToStream(options: ReconnectToStreamOptions & ChatRequestOptions): Promise<ReadableStream<UIMessageChunk> | null>;
156
- private reconnectToStreamIterator;
157
- private onFinish;
158
- }
159
-
160
- export { type ReconnectToStreamOptions, type SendMessagesOptions, WorkflowChatTransport, type WorkflowChatTransportOptions };
1
+ import { i as WorkflowChatTransportOptions, n as SendMessagesOptions, r as WorkflowChatTransport, t as ReconnectToStreamOptions } from "./workflow-chat-transport-DwOgX7dK.js";
2
+ export { type ReconnectToStreamOptions, type SendMessagesOptions, WorkflowChatTransport, type WorkflowChatTransportOptions };
package/dist/client.js CHANGED
@@ -1,8 +1,2 @@
1
- import {
2
- WorkflowChatTransport
3
- } from "./chunk-CKYLPPDM.js";
4
- import "./chunk-UAWBPTDW.js";
5
- export {
6
- WorkflowChatTransport
7
- };
8
- //# sourceMappingURL=client.js.map
1
+ import { t as WorkflowChatTransport } from "./workflow-chat-transport-Bduf4ZDx.js";
2
+ export { WorkflowChatTransport };