@ai-sdk/workflow 1.0.69 → 2.0.0
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 +24 -0
- package/README.md +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/src/do-stream-step.ts +10 -2
- package/src/normalize-ui-message-stream.ts +10 -0
- package/src/stream-text-iterator.ts +1 -1
- package/src/to-ui-message-chunk.ts +5 -5
- package/src/workflow-agent.ts +1 -1
- package/src/workflow-chat-transport.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @ai-sdk/workflow
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 3238c04: Upgrade to Workflow 5 and drop Workflow 4 support. Applications must now install Workflow 5, which is currently available under the `beta` tag.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- d3cc3fe: Clear partial UI message parts when a WorkflowAgent model-call step is retried.
|
|
12
|
+
- Updated dependencies [e6087c9]
|
|
13
|
+
- Updated dependencies [9566914]
|
|
14
|
+
- Updated dependencies [b181020]
|
|
15
|
+
- Updated dependencies [7054073]
|
|
16
|
+
- Updated dependencies [a828527]
|
|
17
|
+
- Updated dependencies [d3cc3fe]
|
|
18
|
+
- @ai-sdk/provider-utils@5.0.28
|
|
19
|
+
- ai@7.0.70
|
|
20
|
+
|
|
21
|
+
## 1.0.70
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- ai@7.0.69
|
|
26
|
+
|
|
3
27
|
## 1.0.69
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { LanguageModelV4, LanguageModelV4CallOptions, SharedV4ProviderOptions, LanguageModelV4Prompt, LanguageModelV4StreamPart } from '@ai-sdk/provider';
|
|
2
2
|
import { Context, HasRequiredKey, InferToolSetContext } from '@ai-sdk/provider-utils';
|
|
3
|
-
import { ToolSet, LanguageModel, Instructions, ToolChoice, TelemetryOptions as TelemetryOptions$1, StopCondition, ActiveTools, LanguageModelResponseMetadata, LanguageModelUsage, FinishReason, ToolCallRepairFunction, Experimental_SandboxSession, ModelMessage, StepResult, GenerateTextOnStepEndCallback,
|
|
4
|
-
export {
|
|
3
|
+
import { ToolSet, Experimental_LanguageModelStreamPart, LanguageModel, Instructions, ToolChoice, TelemetryOptions as TelemetryOptions$1, StopCondition, ActiveTools, LanguageModelResponseMetadata, LanguageModelUsage, FinishReason, ToolCallRepairFunction, Experimental_SandboxSession, ModelMessage, StepResult, GenerateTextOnStepEndCallback, UIMessage, UIMessageChunk, ChatTransport, PrepareSendMessagesRequest, PrepareReconnectToStreamRequest, ChatRequestOptions } from 'ai';
|
|
4
|
+
export { Output, ToolCallRepairFunction } from 'ai';
|
|
5
|
+
|
|
6
|
+
type ModelCallStreamPart<TTools extends ToolSet = ToolSet> = Experimental_LanguageModelStreamPart<TTools> | {
|
|
7
|
+
type: 'reset-step';
|
|
8
|
+
};
|
|
5
9
|
|
|
6
10
|
/**
|
|
7
11
|
* Shared types for AI SDK V4.
|
|
@@ -658,7 +662,7 @@ type WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, TRuntimeContex
|
|
|
658
662
|
* });
|
|
659
663
|
* ```
|
|
660
664
|
*/
|
|
661
|
-
writable?: WritableStream<
|
|
665
|
+
writable?: WritableStream<ModelCallStreamPart<ToolSet>>;
|
|
662
666
|
/**
|
|
663
667
|
* Condition for stopping the generation when there are tool results in the last step.
|
|
664
668
|
* When the condition is an array, any of the conditions can be met to stop the generation.
|
|
@@ -995,12 +999,12 @@ declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet, TRuntimeContex
|
|
|
995
999
|
* Convert a single ModelCallStreamPart to a UIMessageChunk.
|
|
996
1000
|
* Returns undefined for parts that don't map to UI chunks.
|
|
997
1001
|
*/
|
|
998
|
-
declare function toUIMessageChunk(part:
|
|
1002
|
+
declare function toUIMessageChunk(part: ModelCallStreamPart<ToolSet>): UIMessageChunk | undefined;
|
|
999
1003
|
/**
|
|
1000
1004
|
* Create a TransformStream that converts ModelCallStreamPart to UIMessageChunk.
|
|
1001
1005
|
* Wraps toUIMessageChunk with start/start-step/finish-step lifecycle chunks.
|
|
1002
1006
|
*/
|
|
1003
|
-
declare function createModelCallToUIChunkTransform(): TransformStream<
|
|
1007
|
+
declare function createModelCallToUIChunkTransform(): TransformStream<ModelCallStreamPart<ToolSet>, UIMessageChunk>;
|
|
1004
1008
|
|
|
1005
1009
|
interface SendMessagesOptions<UI_MESSAGE extends UIMessage> {
|
|
1006
1010
|
trigger: 'submit-message' | 'regenerate-message';
|
|
@@ -1209,4 +1213,4 @@ declare class WorkflowChatTransport<UI_MESSAGE extends UIMessage> implements Cha
|
|
|
1209
1213
|
*/
|
|
1210
1214
|
declare function normalizeUIMessageStreamParts(source: AsyncIterable<UIMessageChunk>): AsyncGenerator<UIMessageChunk>;
|
|
1211
1215
|
|
|
1212
|
-
export { type CompatibleLanguageModel, type DownloadFunction, type GenerationSettings, type InferWorkflowAgentTools, type InferWorkflowAgentUIMessage, type OutputSpecification, type PrepareCallCallback, type PrepareCallOptions, type PrepareCallResult, type PrepareStepCallback, type PrepareStepInfo, type PrepareStepResult, type ProviderOptions, type ReconnectToStreamOptions, type SendMessagesOptions, type StreamTextTransform, type TelemetryOptions, WorkflowAgent, type WorkflowAgentOnAbortCallback, type WorkflowAgentOnEndCallback, type WorkflowAgentOnErrorCallback, type WorkflowAgentOnFinishCallback, type WorkflowAgentOnStartCallback, type WorkflowAgentOnStepEndCallback, type WorkflowAgentOnStepFinishCallback, type WorkflowAgentOnStepStartCallback, type WorkflowAgentOnToolExecutionEndCallback, type WorkflowAgentOnToolExecutionStartCallback, type WorkflowAgentOptions, type WorkflowAgentStreamOptions, type WorkflowAgentStreamResult, WorkflowChatTransport, type WorkflowChatTransportOptions, createModelCallToUIChunkTransform, normalizeUIMessageStreamParts, toUIMessageChunk };
|
|
1216
|
+
export { type CompatibleLanguageModel, type DownloadFunction, type GenerationSettings, type InferWorkflowAgentTools, type InferWorkflowAgentUIMessage, type ModelCallStreamPart, type OutputSpecification, type PrepareCallCallback, type PrepareCallOptions, type PrepareCallResult, type PrepareStepCallback, type PrepareStepInfo, type PrepareStepResult, type ProviderOptions, type ReconnectToStreamOptions, type SendMessagesOptions, type StreamTextTransform, type TelemetryOptions, WorkflowAgent, type WorkflowAgentOnAbortCallback, type WorkflowAgentOnEndCallback, type WorkflowAgentOnErrorCallback, type WorkflowAgentOnFinishCallback, type WorkflowAgentOnStartCallback, type WorkflowAgentOnStepEndCallback, type WorkflowAgentOnStepFinishCallback, type WorkflowAgentOnStepStartCallback, type WorkflowAgentOnToolExecutionEndCallback, type WorkflowAgentOnToolExecutionStartCallback, type WorkflowAgentOptions, type WorkflowAgentStreamOptions, type WorkflowAgentStreamResult, WorkflowChatTransport, type WorkflowChatTransportOptions, createModelCallToUIChunkTransform, normalizeUIMessageStreamParts, toUIMessageChunk };
|
package/dist/index.js
CHANGED
|
@@ -245,6 +245,7 @@ async function doStreamStep(conversationPrompt, modelInit, writable, serializedT
|
|
|
245
245
|
let hasTerminalError = false;
|
|
246
246
|
const writer = writable == null ? void 0 : writable.getWriter();
|
|
247
247
|
try {
|
|
248
|
+
await (writer == null ? void 0 : writer.write({ type: "reset-step" }));
|
|
248
249
|
for await (const part of modelStream) {
|
|
249
250
|
switch (part.type) {
|
|
250
251
|
case "text-delta":
|
|
@@ -2119,6 +2120,8 @@ async function executeTool(toolCall, tools, messages, context, download, sandbox
|
|
|
2119
2120
|
function toUIMessageChunk(part) {
|
|
2120
2121
|
var _a;
|
|
2121
2122
|
switch (part.type) {
|
|
2123
|
+
case "reset-step":
|
|
2124
|
+
return { type: "reset-step" };
|
|
2122
2125
|
case "text-start":
|
|
2123
2126
|
return {
|
|
2124
2127
|
type: "text-start",
|
|
@@ -2324,6 +2327,13 @@ async function* normalizeUIMessageStreamParts(source) {
|
|
|
2324
2327
|
const reasoning = newPartFrameState();
|
|
2325
2328
|
for await (const chunk of source) {
|
|
2326
2329
|
switch (chunk.type) {
|
|
2330
|
+
case "reset-step":
|
|
2331
|
+
text.open.clear();
|
|
2332
|
+
text.ended.clear();
|
|
2333
|
+
reasoning.open.clear();
|
|
2334
|
+
reasoning.ended.clear();
|
|
2335
|
+
yield chunk;
|
|
2336
|
+
break;
|
|
2327
2337
|
case "finish-step":
|
|
2328
2338
|
text.open.clear();
|
|
2329
2339
|
text.ended.clear();
|
|
@@ -2381,6 +2391,10 @@ function createOrphanFilter() {
|
|
|
2381
2391
|
}
|
|
2382
2392
|
function shouldDrop(chunk) {
|
|
2383
2393
|
switch (chunk.type) {
|
|
2394
|
+
case "reset-step":
|
|
2395
|
+
seenStartedIds.clear();
|
|
2396
|
+
seenStartedToolCallIds.clear();
|
|
2397
|
+
return false;
|
|
2384
2398
|
case "text-start":
|
|
2385
2399
|
case "reasoning-start":
|
|
2386
2400
|
seenStartedIds.add(chunk.id);
|