@ai-sdk/workflow 2.0.19 → 2.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 +18 -0
- package/dist/index.d.ts +10 -9
- package/dist/index.js +480 -106
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/do-stream-step.ts +165 -12
- package/src/resolve-tool-context.ts +28 -0
- package/src/serializable-schema.ts +99 -30
- package/src/stream-text-iterator.ts +273 -51
- package/src/workflow-agent.ts +169 -88
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/workflow
|
|
2
2
|
|
|
3
|
+
## 2.0.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 180ce77: fix(workflow): preserve tool behavior across workflow step boundaries
|
|
8
|
+
- 82a16c9: fix(workflow): retain model files and sources in provider order across durable agent results and message history
|
|
9
|
+
- 30306cf: fix(workflow): include executed tool results in completed agent steps
|
|
10
|
+
- 19d8f30: fix(workflow): infer constructor-level structured output in stream results
|
|
11
|
+
- Updated dependencies [6bcc0f8]
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.36
|
|
13
|
+
- ai@7.0.90
|
|
14
|
+
|
|
15
|
+
## 2.0.20
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 85d2081: fix(workflow): preserve configured tool and runtime context types in stop conditions
|
|
20
|
+
|
|
3
21
|
## 2.0.19
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ type WorkflowAgentOnStepFinishCallback<TTools extends ToolSet = ToolSet, TRuntim
|
|
|
39
39
|
/**
|
|
40
40
|
* Infer the type of the tools of a workflow agent.
|
|
41
41
|
*/
|
|
42
|
-
type InferWorkflowAgentTools<WORKFLOW_AGENT> = WORKFLOW_AGENT extends WorkflowAgent<infer TOOLS, any> ? TOOLS : never;
|
|
42
|
+
type InferWorkflowAgentTools<WORKFLOW_AGENT> = WORKFLOW_AGENT extends WorkflowAgent<infer TOOLS, any, any, any> ? TOOLS : never;
|
|
43
43
|
/**
|
|
44
44
|
* Infer the UI message type of a workflow agent.
|
|
45
45
|
*/
|
|
@@ -65,6 +65,7 @@ interface OutputSpecification<OUTPUT, PARTIAL> {
|
|
|
65
65
|
finishReason: FinishReason;
|
|
66
66
|
}): Promise<OUTPUT>;
|
|
67
67
|
}
|
|
68
|
+
type DefaultWorkflowAgentOutput<OUTPUT> = 0 extends 1 & OUTPUT ? never : OUTPUT;
|
|
68
69
|
/**
|
|
69
70
|
* Provider-specific options type. This is equivalent to SharedV4ProviderOptions from @ai-sdk/provider.
|
|
70
71
|
*/
|
|
@@ -284,7 +285,7 @@ interface PrepareCallOptions<TTools extends ToolSet = ToolSet, TRuntimeContext e
|
|
|
284
285
|
tools: TTools;
|
|
285
286
|
instructions?: Instructions;
|
|
286
287
|
toolChoice?: ToolChoice<TTools>;
|
|
287
|
-
stopWhen?: StopCondition<NoInfer<
|
|
288
|
+
stopWhen?: StopCondition<NoInfer<TTools>, TRuntimeContext> | Array<StopCondition<NoInfer<TTools>, TRuntimeContext>>;
|
|
288
289
|
activeTools?: ActiveTools<NoInfer<TTools>>;
|
|
289
290
|
experimental_download?: DownloadFunction;
|
|
290
291
|
telemetry?: TelemetryOptions<TRuntimeContext, TTools>;
|
|
@@ -313,7 +314,7 @@ type PrepareCallCallback<TTools extends ToolSet = ToolSet, TRuntimeContext exten
|
|
|
313
314
|
/**
|
|
314
315
|
* Configuration options for creating a {@link WorkflowAgent} instance.
|
|
315
316
|
*/
|
|
316
|
-
type WorkflowAgentOptions<TTools extends ToolSet = ToolSet, TRuntimeContext extends Context = Context> = GenerationSettings & WorkflowAgentToolsContextParameter<TTools> & {
|
|
317
|
+
type WorkflowAgentOptions<TTools extends ToolSet = ToolSet, TRuntimeContext extends Context = Context, OUTPUT = any, PARTIAL_OUTPUT = any> = GenerationSettings & WorkflowAgentToolsContextParameter<TTools> & {
|
|
317
318
|
/**
|
|
318
319
|
* The id of the agent.
|
|
319
320
|
*/
|
|
@@ -369,7 +370,7 @@ type WorkflowAgentOptions<TTools extends ToolSet = ToolSet, TRuntimeContext exte
|
|
|
369
370
|
*
|
|
370
371
|
* Per-stream `stopWhen` values passed to `stream()` override this default.
|
|
371
372
|
*/
|
|
372
|
-
stopWhen?: StopCondition<NoInfer<
|
|
373
|
+
stopWhen?: StopCondition<NoInfer<TTools>, TRuntimeContext> | Array<StopCondition<NoInfer<TTools>, TRuntimeContext>>;
|
|
373
374
|
/**
|
|
374
375
|
* Default set of active tools that limits which tools the model can call,
|
|
375
376
|
* without changing the tool call and result types in the result.
|
|
@@ -383,7 +384,7 @@ type WorkflowAgentOptions<TTools extends ToolSet = ToolSet, TRuntimeContext exte
|
|
|
383
384
|
*
|
|
384
385
|
* Per-stream `output` values passed to `stream()` override this default.
|
|
385
386
|
*/
|
|
386
|
-
output?: OutputSpecification<
|
|
387
|
+
output?: OutputSpecification<OUTPUT, PARTIAL_OUTPUT>;
|
|
387
388
|
/**
|
|
388
389
|
* Default function that attempts to repair a tool call that failed to parse.
|
|
389
390
|
*
|
|
@@ -705,7 +706,7 @@ type WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, TRuntimeContex
|
|
|
705
706
|
* Condition for stopping the generation when there are tool results in the last step.
|
|
706
707
|
* When the condition is an array, any of the conditions can be met to stop the generation.
|
|
707
708
|
*/
|
|
708
|
-
stopWhen?: StopCondition<NoInfer<
|
|
709
|
+
stopWhen?: StopCondition<NoInfer<TTools>, TRuntimeContext> | Array<StopCondition<NoInfer<TTools>, TRuntimeContext>>;
|
|
709
710
|
/**
|
|
710
711
|
* The tool choice strategy. Default: 'auto'.
|
|
711
712
|
* Overrides the toolChoice from the constructor if provided.
|
|
@@ -1020,7 +1021,7 @@ interface WorkflowAgentStreamResult<TTools extends ToolSet = ToolSet, OUTPUT = n
|
|
|
1020
1021
|
* });
|
|
1021
1022
|
* ```
|
|
1022
1023
|
*/
|
|
1023
|
-
declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet, TRuntimeContext extends Context = Context> {
|
|
1024
|
+
declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet, TRuntimeContext extends Context = Context, OUTPUT = any, PARTIAL_OUTPUT = any> {
|
|
1024
1025
|
/**
|
|
1025
1026
|
* The id of the agent.
|
|
1026
1027
|
*/
|
|
@@ -1052,9 +1053,9 @@ declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet, TRuntimeContex
|
|
|
1052
1053
|
private constructorOnToolExecutionStart?;
|
|
1053
1054
|
private constructorOnToolExecutionEnd?;
|
|
1054
1055
|
private prepareCall?;
|
|
1055
|
-
constructor(options: WorkflowAgentOptions<TBaseTools, TRuntimeContext>);
|
|
1056
|
+
constructor(options: WorkflowAgentOptions<TBaseTools, TRuntimeContext, OUTPUT, PARTIAL_OUTPUT>);
|
|
1056
1057
|
generate(): void;
|
|
1057
|
-
stream<TTools extends TBaseTools = TBaseTools,
|
|
1058
|
+
stream<TTools extends TBaseTools = TBaseTools, TOutput = DefaultWorkflowAgentOutput<OUTPUT>, TPartialOutput = DefaultWorkflowAgentOutput<PARTIAL_OUTPUT>>(options: WorkflowAgentStreamOptions<TTools, TRuntimeContext, TOutput, TPartialOutput>): Promise<WorkflowAgentStreamResult<TTools, TOutput>>;
|
|
1058
1059
|
}
|
|
1059
1060
|
|
|
1060
1061
|
/**
|