@ai-sdk/workflow 1.0.0-beta.2 → 1.0.0-beta.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 +139 -0
- package/dist/index.d.mts +128 -38
- package/dist/index.mjs +98 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/do-stream-step.ts +10 -25
- package/src/index.ts +5 -4
- package/src/providers/mock.ts +79 -92
- package/src/stream-text-iterator.ts +22 -47
- package/src/telemetry.ts +5 -5
- package/src/workflow-agent.ts +430 -317
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,144 @@
|
|
|
1
1
|
# @ai-sdk/workflow
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fbea042: refactor: replace duplicate `filterTools`/`filterToolSet` with shared `experimental_filterActiveTools` from `ai`
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.20
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ai@7.0.0-beta.106
|
|
14
|
+
|
|
15
|
+
## 1.0.0-beta.19
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [33d099c]
|
|
20
|
+
- ai@7.0.0-beta.105
|
|
21
|
+
|
|
22
|
+
## 1.0.0-beta.18
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- eba685c: Remove `maxSteps` option from `WorkflowAgent`. Use `stopWhen` with stop conditions like `isStepCount()` instead.
|
|
27
|
+
- Updated dependencies [2a74d43]
|
|
28
|
+
- ai@7.0.0-beta.104
|
|
29
|
+
|
|
30
|
+
## 1.0.0-beta.17
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- 382d53b: refactoring: rename context to runtimeContext
|
|
35
|
+
- c3d4019: chore(ai): rename 'TelemetrySettings' to 'TelemetryOptions'
|
|
36
|
+
- 083947b: feat(ai): separate toolsContext from context
|
|
37
|
+
- Updated dependencies [382d53b]
|
|
38
|
+
- Updated dependencies [7bf7d7f]
|
|
39
|
+
- Updated dependencies [c3d4019]
|
|
40
|
+
- Updated dependencies [083947b]
|
|
41
|
+
- ai@7.0.0-beta.103
|
|
42
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
43
|
+
|
|
44
|
+
## 1.0.0-beta.16
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- ai@7.0.0-beta.102
|
|
49
|
+
|
|
50
|
+
## 1.0.0-beta.15
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [4873966]
|
|
55
|
+
- ai@7.0.0-beta.101
|
|
56
|
+
|
|
57
|
+
## 1.0.0-beta.14
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies [add1126]
|
|
62
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
63
|
+
- ai@7.0.0-beta.100
|
|
64
|
+
|
|
65
|
+
## 1.0.0-beta.13
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [2a9c144]
|
|
70
|
+
- ai@7.0.0-beta.99
|
|
71
|
+
|
|
72
|
+
## 1.0.0-beta.12
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- ai@7.0.0-beta.98
|
|
77
|
+
|
|
78
|
+
## 1.0.0-beta.11
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- Updated dependencies [208d045]
|
|
83
|
+
- ai@7.0.0-beta.97
|
|
84
|
+
|
|
85
|
+
## 1.0.0-beta.10
|
|
86
|
+
|
|
87
|
+
### Patch Changes
|
|
88
|
+
|
|
89
|
+
- ai@7.0.0-beta.96
|
|
90
|
+
|
|
91
|
+
## 1.0.0-beta.9
|
|
92
|
+
|
|
93
|
+
### Patch Changes
|
|
94
|
+
|
|
95
|
+
- Updated dependencies [c4f4b5f]
|
|
96
|
+
- ai@7.0.0-beta.95
|
|
97
|
+
|
|
98
|
+
## 1.0.0-beta.8
|
|
99
|
+
|
|
100
|
+
### Patch Changes
|
|
101
|
+
|
|
102
|
+
- 0455f24: Enrich WorkflowAgent callback event shapes to align with ToolLoopAgent:
|
|
103
|
+
- Add `stepNumber` to `onToolCallStart` and `onToolCallFinish`
|
|
104
|
+
- Add `steps` (previous step results) to `onStepStart`
|
|
105
|
+
- Adopt discriminated union pattern (`success: true/false`) for `onToolCallFinish`
|
|
106
|
+
- Add `durationMs` to `onToolCallFinish`
|
|
107
|
+
|
|
108
|
+
## 1.0.0-beta.7
|
|
109
|
+
|
|
110
|
+
### Patch Changes
|
|
111
|
+
|
|
112
|
+
- Updated dependencies [1582efa]
|
|
113
|
+
- ai@7.0.0-beta.94
|
|
114
|
+
|
|
115
|
+
## 1.0.0-beta.6
|
|
116
|
+
|
|
117
|
+
### Patch Changes
|
|
118
|
+
|
|
119
|
+
- Updated dependencies [bc47739]
|
|
120
|
+
- ai@7.0.0-beta.93
|
|
121
|
+
|
|
122
|
+
## 1.0.0-beta.5
|
|
123
|
+
|
|
124
|
+
### Patch Changes
|
|
125
|
+
|
|
126
|
+
- bf6c17b: Add `id` property to WorkflowAgent for telemetry identification, matching ToolLoopAgent's API surface.
|
|
127
|
+
- 3ca592a: Add `prompt` as an alternative to `messages` in `WorkflowAgent.stream()`, matching the `AgentCallParameters` pattern from ToolLoopAgent.
|
|
128
|
+
- eb49d29: Add constructor-level defaults for `stopWhen`, `activeTools`, `output`, `experimental_repairToolCall`, and `experimental_download` to WorkflowAgent, matching ToolLoopAgent's pattern. Stream-level values override constructor defaults.
|
|
129
|
+
|
|
130
|
+
## 1.0.0-beta.4
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- ai@7.0.0-beta.92
|
|
135
|
+
|
|
136
|
+
## 1.0.0-beta.3
|
|
137
|
+
|
|
138
|
+
### Patch Changes
|
|
139
|
+
|
|
140
|
+
- 0e462a7: Use `LanguageModel` type for model parameter, aligning with `ToolLoopAgent`. Remove async factory model form. Rename callback types to use `WorkflowAgentOn*` prefix.
|
|
141
|
+
|
|
3
142
|
## 1.0.0-beta.2
|
|
4
143
|
|
|
5
144
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LanguageModelV4, SharedV4ProviderOptions,
|
|
2
|
-
import { ToolSet, SystemModelMessage, ToolChoice,
|
|
1
|
+
import { LanguageModelV4, SharedV4ProviderOptions, LanguageModelV4CallOptions, LanguageModelV4Prompt, LanguageModelV4StreamPart } from '@ai-sdk/provider';
|
|
2
|
+
import { ToolSet, LanguageModel, SystemModelMessage, ToolChoice, StopCondition, LanguageModelResponseMetadata, LanguageModelUsage, FinishReason, ToolCallRepairFunction, StepResult, StreamTextOnStepFinishCallback, ModelMessage, Experimental_LanguageModelStreamPart, UIMessage, UIMessageChunk, ChatTransport, PrepareSendMessagesRequest, PrepareReconnectToStreamRequest, ChatRequestOptions } from 'ai';
|
|
3
3
|
export { Experimental_LanguageModelStreamPart as ModelCallStreamPart, Output, ToolCallRepairFunction } from 'ai';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -13,6 +13,12 @@ export { Experimental_LanguageModelStreamPart as ModelCallStreamPart, Output, To
|
|
|
13
13
|
*/
|
|
14
14
|
type CompatibleLanguageModel = LanguageModelV4;
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Callback function to be called after each step completes.
|
|
18
|
+
* Alias for the AI SDK's StreamTextOnStepFinishCallback, using
|
|
19
|
+
* WorkflowAgent-consistent naming.
|
|
20
|
+
*/
|
|
21
|
+
type WorkflowAgentOnStepFinishCallback<TTools extends ToolSet = ToolSet> = StreamTextOnStepFinishCallback<TTools, any>;
|
|
16
22
|
/**
|
|
17
23
|
* Infer the type of the tools of a workflow agent.
|
|
18
24
|
*/
|
|
@@ -49,7 +55,7 @@ type ProviderOptions = SharedV4ProviderOptions;
|
|
|
49
55
|
/**
|
|
50
56
|
* Telemetry settings for observability.
|
|
51
57
|
*/
|
|
52
|
-
interface
|
|
58
|
+
interface TelemetryOptions {
|
|
53
59
|
/**
|
|
54
60
|
* Enable or disable telemetry. Defaults to true.
|
|
55
61
|
*/
|
|
@@ -181,7 +187,7 @@ interface PrepareStepInfo<TTools extends ToolSet = ToolSet> {
|
|
|
181
187
|
* The current model configuration (string or function).
|
|
182
188
|
* The function should return a LanguageModelV4 instance.
|
|
183
189
|
*/
|
|
184
|
-
model:
|
|
190
|
+
model: LanguageModel;
|
|
185
191
|
/**
|
|
186
192
|
* The current step number (0-indexed).
|
|
187
193
|
*/
|
|
@@ -207,9 +213,8 @@ interface PrepareStepInfo<TTools extends ToolSet = ToolSet> {
|
|
|
207
213
|
interface PrepareStepResult extends Partial<GenerationSettings> {
|
|
208
214
|
/**
|
|
209
215
|
* Override the model for this step.
|
|
210
|
-
* The function should return a LanguageModelV4 instance.
|
|
211
216
|
*/
|
|
212
|
-
model?:
|
|
217
|
+
model?: LanguageModel;
|
|
213
218
|
/**
|
|
214
219
|
* Override the system message for this step.
|
|
215
220
|
*/
|
|
@@ -243,11 +248,11 @@ type PrepareStepCallback<TTools extends ToolSet = ToolSet> = (info: PrepareStepI
|
|
|
243
248
|
* Options passed to the prepareCall callback.
|
|
244
249
|
*/
|
|
245
250
|
interface PrepareCallOptions<TTools extends ToolSet = ToolSet> extends Partial<GenerationSettings> {
|
|
246
|
-
model:
|
|
251
|
+
model: LanguageModel;
|
|
247
252
|
tools: TTools;
|
|
248
253
|
instructions?: string | SystemModelMessage | Array<SystemModelMessage>;
|
|
249
254
|
toolChoice?: ToolChoice<TTools>;
|
|
250
|
-
experimental_telemetry?:
|
|
255
|
+
experimental_telemetry?: TelemetryOptions;
|
|
251
256
|
experimental_context?: unknown;
|
|
252
257
|
messages: ModelMessage[];
|
|
253
258
|
}
|
|
@@ -266,13 +271,17 @@ type PrepareCallCallback<TTools extends ToolSet = ToolSet> = (options: PrepareCa
|
|
|
266
271
|
* Configuration options for creating a {@link WorkflowAgent} instance.
|
|
267
272
|
*/
|
|
268
273
|
interface WorkflowAgentOptions<TTools extends ToolSet = ToolSet> extends GenerationSettings {
|
|
274
|
+
/**
|
|
275
|
+
* The id of the agent.
|
|
276
|
+
*/
|
|
277
|
+
id?: string;
|
|
269
278
|
/**
|
|
270
279
|
* The model provider to use for the agent.
|
|
271
280
|
*
|
|
272
281
|
* This should be a string compatible with the Vercel AI Gateway (e.g., 'anthropic/claude-opus'),
|
|
273
|
-
* or a
|
|
282
|
+
* or a LanguageModelV4 instance from a provider.
|
|
274
283
|
*/
|
|
275
|
-
model:
|
|
284
|
+
model: LanguageModel;
|
|
276
285
|
/**
|
|
277
286
|
* A set of tools available to the agent.
|
|
278
287
|
* Tools can be implemented as workflow steps for automatic retries and persistence,
|
|
@@ -296,7 +305,7 @@ interface WorkflowAgentOptions<TTools extends ToolSet = ToolSet> extends Generat
|
|
|
296
305
|
/**
|
|
297
306
|
* Optional telemetry configuration (experimental).
|
|
298
307
|
*/
|
|
299
|
-
experimental_telemetry?:
|
|
308
|
+
experimental_telemetry?: TelemetryOptions;
|
|
300
309
|
/**
|
|
301
310
|
* Default context that is passed into tool execution for every stream call on this agent.
|
|
302
311
|
*
|
|
@@ -305,6 +314,39 @@ interface WorkflowAgentOptions<TTools extends ToolSet = ToolSet> extends Generat
|
|
|
305
314
|
* @default undefined
|
|
306
315
|
*/
|
|
307
316
|
experimental_context?: unknown;
|
|
317
|
+
/**
|
|
318
|
+
* Default stop condition for the agent loop. When the condition is an array,
|
|
319
|
+
* any of the conditions can be met to stop the generation.
|
|
320
|
+
*
|
|
321
|
+
* Per-stream `stopWhen` values passed to `stream()` override this default.
|
|
322
|
+
*/
|
|
323
|
+
stopWhen?: StopCondition<NoInfer<ToolSet>, any> | Array<StopCondition<NoInfer<ToolSet>, any>>;
|
|
324
|
+
/**
|
|
325
|
+
* Default set of active tools that limits which tools the model can call,
|
|
326
|
+
* without changing the tool call and result types in the result.
|
|
327
|
+
*
|
|
328
|
+
* Per-stream `activeTools` values passed to `stream()` override this default.
|
|
329
|
+
*/
|
|
330
|
+
activeTools?: Array<keyof NoInfer<TTools>>;
|
|
331
|
+
/**
|
|
332
|
+
* Default output specification for structured outputs.
|
|
333
|
+
* Use `Output.object({ schema })` for structured output or `Output.text()` for text output.
|
|
334
|
+
*
|
|
335
|
+
* Per-stream `output` values passed to `stream()` override this default.
|
|
336
|
+
*/
|
|
337
|
+
output?: OutputSpecification<any, any>;
|
|
338
|
+
/**
|
|
339
|
+
* Default function that attempts to repair a tool call that failed to parse.
|
|
340
|
+
*
|
|
341
|
+
* Per-stream `experimental_repairToolCall` values passed to `stream()` override this default.
|
|
342
|
+
*/
|
|
343
|
+
experimental_repairToolCall?: ToolCallRepairFunction<TTools>;
|
|
344
|
+
/**
|
|
345
|
+
* Default custom download function to use for URLs.
|
|
346
|
+
*
|
|
347
|
+
* Per-stream `experimental_download` values passed to `stream()` override this default.
|
|
348
|
+
*/
|
|
349
|
+
experimental_download?: DownloadFunction;
|
|
308
350
|
/**
|
|
309
351
|
* Default callback function called before each step in the agent loop.
|
|
310
352
|
* Use this to modify settings, manage context, or inject messages dynamically
|
|
@@ -316,11 +358,11 @@ interface WorkflowAgentOptions<TTools extends ToolSet = ToolSet> extends Generat
|
|
|
316
358
|
/**
|
|
317
359
|
* Callback function to be called after each step completes.
|
|
318
360
|
*/
|
|
319
|
-
onStepFinish?:
|
|
361
|
+
onStepFinish?: WorkflowAgentOnStepFinishCallback<ToolSet>;
|
|
320
362
|
/**
|
|
321
363
|
* Callback that is called when the LLM response and all request tool executions are finished.
|
|
322
364
|
*/
|
|
323
|
-
onFinish?:
|
|
365
|
+
onFinish?: WorkflowAgentOnFinishCallback<ToolSet>;
|
|
324
366
|
/**
|
|
325
367
|
* Callback called when the agent starts streaming, before any LLM calls.
|
|
326
368
|
*/
|
|
@@ -347,7 +389,7 @@ interface WorkflowAgentOptions<TTools extends ToolSet = ToolSet> extends Generat
|
|
|
347
389
|
/**
|
|
348
390
|
* Callback that is called when the LLM response and all request tool executions are finished.
|
|
349
391
|
*/
|
|
350
|
-
type
|
|
392
|
+
type WorkflowAgentOnFinishCallback<TTools extends ToolSet = ToolSet, OUTPUT = never> = (event: {
|
|
351
393
|
/**
|
|
352
394
|
* Details for all steps.
|
|
353
395
|
*/
|
|
@@ -381,13 +423,13 @@ type StreamTextOnFinishCallback<TTools extends ToolSet = ToolSet, OUTPUT = never
|
|
|
381
423
|
/**
|
|
382
424
|
* Callback that is invoked when an error occurs during streaming.
|
|
383
425
|
*/
|
|
384
|
-
type
|
|
426
|
+
type WorkflowAgentOnErrorCallback = (event: {
|
|
385
427
|
error: unknown;
|
|
386
428
|
}) => PromiseLike<void> | void;
|
|
387
429
|
/**
|
|
388
430
|
* Callback that is set using the `onAbort` option.
|
|
389
431
|
*/
|
|
390
|
-
type
|
|
432
|
+
type WorkflowAgentOnAbortCallback<TTools extends ToolSet = ToolSet> = (event: {
|
|
391
433
|
/**
|
|
392
434
|
* Details for all previously finished steps.
|
|
393
435
|
*/
|
|
@@ -398,20 +440,22 @@ type StreamTextOnAbortCallback<TTools extends ToolSet = ToolSet> = (event: {
|
|
|
398
440
|
*/
|
|
399
441
|
type WorkflowAgentOnStartCallback = (event: {
|
|
400
442
|
/** The model being used */
|
|
401
|
-
readonly model:
|
|
443
|
+
readonly model: LanguageModel;
|
|
402
444
|
/** The messages being sent */
|
|
403
445
|
readonly messages: ModelMessage[];
|
|
404
446
|
}) => PromiseLike<void> | void;
|
|
405
447
|
/**
|
|
406
448
|
* Callback that is called before each step (LLM call) begins.
|
|
407
449
|
*/
|
|
408
|
-
type WorkflowAgentOnStepStartCallback = (event: {
|
|
450
|
+
type WorkflowAgentOnStepStartCallback<TTools extends ToolSet = ToolSet> = (event: {
|
|
409
451
|
/** The current step number (0-based) */
|
|
410
452
|
readonly stepNumber: number;
|
|
411
453
|
/** The model being used for this step */
|
|
412
|
-
readonly model:
|
|
454
|
+
readonly model: LanguageModel;
|
|
413
455
|
/** The messages being sent for this step */
|
|
414
456
|
readonly messages: ModelMessage[];
|
|
457
|
+
/** Results from all previously finished steps */
|
|
458
|
+
readonly steps: ReadonlyArray<StepResult<TTools, any>>;
|
|
415
459
|
}) => PromiseLike<void> | void;
|
|
416
460
|
/**
|
|
417
461
|
* Callback that is called before a tool's execute function runs.
|
|
@@ -419,26 +463,69 @@ type WorkflowAgentOnStepStartCallback = (event: {
|
|
|
419
463
|
type WorkflowAgentOnToolCallStartCallback = (event: {
|
|
420
464
|
/** The tool call being executed */
|
|
421
465
|
readonly toolCall: ToolCall;
|
|
466
|
+
/** The current step number (0-based) */
|
|
467
|
+
readonly stepNumber: number;
|
|
422
468
|
}) => PromiseLike<void> | void;
|
|
423
469
|
/**
|
|
424
470
|
* Callback that is called after a tool execution completes.
|
|
471
|
+
* Uses a discriminated union pattern: check `success` to determine
|
|
472
|
+
* whether `output` or `error` is available.
|
|
425
473
|
*/
|
|
426
474
|
type WorkflowAgentOnToolCallFinishCallback = (event: {
|
|
427
475
|
/** The tool call that was executed */
|
|
428
476
|
readonly toolCall: ToolCall;
|
|
429
|
-
/** The
|
|
430
|
-
readonly
|
|
431
|
-
/**
|
|
432
|
-
readonly
|
|
477
|
+
/** The current step number (0-based) */
|
|
478
|
+
readonly stepNumber: number;
|
|
479
|
+
/** Execution time in milliseconds */
|
|
480
|
+
readonly durationMs: number;
|
|
481
|
+
/** Whether the tool call succeeded */
|
|
482
|
+
readonly success: true;
|
|
483
|
+
/** The tool result */
|
|
484
|
+
readonly output: unknown;
|
|
485
|
+
readonly error?: never;
|
|
486
|
+
} | {
|
|
487
|
+
/** The tool call that was executed */
|
|
488
|
+
readonly toolCall: ToolCall;
|
|
489
|
+
/** The current step number (0-based) */
|
|
490
|
+
readonly stepNumber: number;
|
|
491
|
+
/** Execution time in milliseconds */
|
|
492
|
+
readonly durationMs: number;
|
|
493
|
+
/** Whether the tool call succeeded */
|
|
494
|
+
readonly success: false;
|
|
495
|
+
/** The error that occurred */
|
|
496
|
+
readonly error: unknown;
|
|
497
|
+
readonly output?: never;
|
|
433
498
|
}) => PromiseLike<void> | void;
|
|
434
499
|
/**
|
|
435
500
|
* Options for the {@link WorkflowAgent.stream} method.
|
|
436
501
|
*/
|
|
437
|
-
|
|
502
|
+
type WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, OUTPUT = never, PARTIAL_OUTPUT = never> = Partial<GenerationSettings> & ({
|
|
503
|
+
/**
|
|
504
|
+
* A prompt. It can be either a text prompt or a list of messages.
|
|
505
|
+
*
|
|
506
|
+
* You can either use `prompt` or `messages` but not both.
|
|
507
|
+
*/
|
|
508
|
+
prompt: string | Array<ModelMessage>;
|
|
509
|
+
/**
|
|
510
|
+
* A list of messages.
|
|
511
|
+
*
|
|
512
|
+
* You can either use `prompt` or `messages` but not both.
|
|
513
|
+
*/
|
|
514
|
+
messages?: never;
|
|
515
|
+
} | {
|
|
438
516
|
/**
|
|
439
517
|
* The conversation messages to process. Should follow the AI SDK's ModelMessage format.
|
|
518
|
+
*
|
|
519
|
+
* You can either use `prompt` or `messages` but not both.
|
|
440
520
|
*/
|
|
441
|
-
messages: ModelMessage
|
|
521
|
+
messages: Array<ModelMessage>;
|
|
522
|
+
/**
|
|
523
|
+
* A prompt. It can be either a text prompt or a list of messages.
|
|
524
|
+
*
|
|
525
|
+
* You can either use `prompt` or `messages` but not both.
|
|
526
|
+
*/
|
|
527
|
+
prompt?: never;
|
|
528
|
+
}) & {
|
|
442
529
|
/**
|
|
443
530
|
* Optional system prompt override. If provided, overrides the system prompt from the constructor.
|
|
444
531
|
*/
|
|
@@ -471,12 +558,6 @@ interface WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, OUTPUT =
|
|
|
471
558
|
* When the condition is an array, any of the conditions can be met to stop the generation.
|
|
472
559
|
*/
|
|
473
560
|
stopWhen?: StopCondition<NoInfer<ToolSet>, any> | Array<StopCondition<NoInfer<ToolSet>, any>>;
|
|
474
|
-
/**
|
|
475
|
-
* Maximum number of sequential LLM calls (steps), e.g. when you use tool calls.
|
|
476
|
-
* A maximum number can be set to prevent infinite loops in the case of misconfigured tools.
|
|
477
|
-
* By default, it's unlimited (the agent loops until completion).
|
|
478
|
-
*/
|
|
479
|
-
maxSteps?: number;
|
|
480
561
|
/**
|
|
481
562
|
* The tool choice strategy. Default: 'auto'.
|
|
482
563
|
* Overrides the toolChoice from the constructor if provided.
|
|
@@ -490,7 +571,7 @@ interface WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, OUTPUT =
|
|
|
490
571
|
/**
|
|
491
572
|
* Optional telemetry configuration (experimental).
|
|
492
573
|
*/
|
|
493
|
-
experimental_telemetry?:
|
|
574
|
+
experimental_telemetry?: TelemetryOptions;
|
|
494
575
|
/**
|
|
495
576
|
* Context that is passed into tool execution.
|
|
496
577
|
* Experimental (can break in patch releases).
|
|
@@ -546,21 +627,21 @@ interface WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, OUTPUT =
|
|
|
546
627
|
/**
|
|
547
628
|
* Callback function to be called after each step completes.
|
|
548
629
|
*/
|
|
549
|
-
onStepFinish?:
|
|
630
|
+
onStepFinish?: WorkflowAgentOnStepFinishCallback<TTools>;
|
|
550
631
|
/**
|
|
551
632
|
* Callback that is invoked when an error occurs during streaming.
|
|
552
633
|
* You can use it to log errors.
|
|
553
634
|
*/
|
|
554
|
-
onError?:
|
|
635
|
+
onError?: WorkflowAgentOnErrorCallback;
|
|
555
636
|
/**
|
|
556
637
|
* Callback that is called when the LLM response and all request tool executions
|
|
557
638
|
* (for tools that have an `execute` function) are finished.
|
|
558
639
|
*/
|
|
559
|
-
onFinish?:
|
|
640
|
+
onFinish?: WorkflowAgentOnFinishCallback<TTools, OUTPUT>;
|
|
560
641
|
/**
|
|
561
642
|
* Callback that is called when the operation is aborted.
|
|
562
643
|
*/
|
|
563
|
-
onAbort?:
|
|
644
|
+
onAbort?: WorkflowAgentOnAbortCallback<TTools>;
|
|
564
645
|
/**
|
|
565
646
|
* Callback called when the agent starts streaming, before any LLM calls.
|
|
566
647
|
*/
|
|
@@ -612,7 +693,7 @@ interface WorkflowAgentStreamOptions<TTools extends ToolSet = ToolSet, OUTPUT =
|
|
|
612
693
|
* @default false
|
|
613
694
|
*/
|
|
614
695
|
preventClose?: boolean;
|
|
615
|
-
}
|
|
696
|
+
};
|
|
616
697
|
/**
|
|
617
698
|
* A tool call made by the model. Matches the AI SDK's tool call shape.
|
|
618
699
|
*/
|
|
@@ -712,6 +793,10 @@ interface WorkflowAgentStreamResult<TTools extends ToolSet = ToolSet, OUTPUT = n
|
|
|
712
793
|
* ```
|
|
713
794
|
*/
|
|
714
795
|
declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet> {
|
|
796
|
+
/**
|
|
797
|
+
* The id of the agent.
|
|
798
|
+
*/
|
|
799
|
+
readonly id: string | undefined;
|
|
715
800
|
private model;
|
|
716
801
|
/**
|
|
717
802
|
* The tool set configured for this agent.
|
|
@@ -722,6 +807,11 @@ declare class WorkflowAgent<TBaseTools extends ToolSet = ToolSet> {
|
|
|
722
807
|
private toolChoice?;
|
|
723
808
|
private telemetry?;
|
|
724
809
|
private experimentalContext;
|
|
810
|
+
private stopWhen?;
|
|
811
|
+
private activeTools?;
|
|
812
|
+
private output?;
|
|
813
|
+
private experimentalRepairToolCall?;
|
|
814
|
+
private experimentalDownload?;
|
|
725
815
|
private prepareStep?;
|
|
726
816
|
private constructorOnStepFinish?;
|
|
727
817
|
private constructorOnFinish?;
|
|
@@ -901,4 +991,4 @@ declare class WorkflowChatTransport<UI_MESSAGE extends UIMessage> implements Cha
|
|
|
901
991
|
private onFinish;
|
|
902
992
|
}
|
|
903
993
|
|
|
904
|
-
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
|
|
994
|
+
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 WorkflowAgentOnErrorCallback, type WorkflowAgentOnFinishCallback, type WorkflowAgentOnStartCallback, type WorkflowAgentOnStepFinishCallback, type WorkflowAgentOnStepStartCallback, type WorkflowAgentOnToolCallFinishCallback, type WorkflowAgentOnToolCallStartCallback, type WorkflowAgentOptions, type WorkflowAgentStreamOptions, type WorkflowAgentStreamResult, WorkflowChatTransport, type WorkflowChatTransportOptions, createModelCallToUIChunkTransform, toUIMessageChunk };
|