|
1 | 1 | import { ModelMessage } from '@ai-sdk/provider-utils'; |
2 | 2 | import { GenerateTextResult } from '../generate-text/generate-text-result'; |
3 | 3 | import { Output } from '../generate-text/output'; |
| 4 | +import { StreamTextTransform } from '../generate-text/stream-text'; |
4 | 5 | import { StreamTextResult } from '../generate-text/stream-text-result'; |
5 | 6 | import { ToolSet } from '../generate-text/tool-set'; |
6 | 7 |
|
| 8 | +/** |
| 9 | + * Parameters for calling an agent. |
| 10 | + */ |
7 | 11 | export type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] |
8 | 12 | ? { options?: never } |
9 | 13 | : { options: CALL_OPTIONS }) & |
@@ -45,6 +49,23 @@ export type AgentCallParameters<CALL_OPTIONS> = ([CALL_OPTIONS] extends [never] |
45 | 49 | abortSignal?: AbortSignal; |
46 | 50 | }; |
47 | 51 |
|
| 52 | +/** |
| 53 | + * Parameters for streaming an output from an agent. |
| 54 | + */ |
| 55 | +export type AgentStreamParameters< |
| 56 | + CALL_OPTIONS, |
| 57 | + TOOLS extends ToolSet, |
| 58 | +> = AgentCallParameters<CALL_OPTIONS> & { |
| 59 | + /** |
| 60 | + * Optional stream transformations. |
| 61 | + * They are applied in the order they are provided. |
| 62 | + * The stream transformations must maintain the stream structure for streamText to work correctly. |
| 63 | + */ |
| 64 | + experimental_transform?: |
| 65 | + | StreamTextTransform<TOOLS> |
| 66 | + | Array<StreamTextTransform<TOOLS>>; |
| 67 | +}; |
| 68 | + |
48 | 69 | /** |
49 | 70 | * An Agent receives a prompt (text or messages) and generates or streams an output |
50 | 71 | * that consists of steps, tool calls, data parts, etc. |
@@ -84,6 +105,6 @@ export interface Agent< |
84 | 105 | * Streams an output from the agent (streaming). |
85 | 106 | */ |
86 | 107 | stream( |
87 | | - options: AgentCallParameters<CALL_OPTIONS>, |
| 108 | + options: AgentStreamParameters<CALL_OPTIONS, TOOLS>, |
88 | 109 | ): PromiseLike<StreamTextResult<TOOLS, OUTPUT>>; |
89 | 110 | } |
0 commit comments