ai 7.0.122 → 7.0.124

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.
Files changed (91) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/index.d.ts +7598 -7268
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +19555 -22545
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +2235 -2004
  7. package/dist/internal/index.d.ts.map +1 -0
  8. package/dist/internal/index.js +3261 -3921
  9. package/dist/internal/index.js.map +1 -1
  10. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  11. package/dist/test/index.d.ts +294 -273
  12. package/dist/test/index.d.ts.map +1 -0
  13. package/dist/test/index.js +325 -469
  14. package/dist/test/index.js.map +1 -1
  15. package/docs/02-foundations/03-prompts.mdx +3 -1
  16. package/docs/02-foundations/06-provider-options.mdx +1 -1
  17. package/docs/02-getting-started/06-nodejs.mdx +4 -4
  18. package/docs/02-getting-started/08-tanstack-start.mdx +1 -1
  19. package/docs/03-agents/05-configuring-call-options.mdx +1 -1
  20. package/docs/03-ai-sdk-core/10-generating-structured-data.mdx +1 -1
  21. package/docs/03-ai-sdk-core/15-tools-and-tool-calling.mdx +3 -0
  22. package/docs/03-ai-sdk-core/17-mcp-apps.mdx +5 -5
  23. package/docs/03-ai-sdk-core/36-transcription.mdx +36 -0
  24. package/docs/03-ai-sdk-core/37-speech.mdx +22 -1
  25. package/docs/03-ai-sdk-core/42-batch.mdx +1 -1
  26. package/docs/03-ai-sdk-core/60-telemetry.mdx +51 -3
  27. package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +24 -0
  28. package/docs/03-ai-sdk-harnesses/05-harness-adapters.mdx +12 -12
  29. package/docs/04-ai-sdk-ui/03-chatbot-message-persistence.mdx +9 -7
  30. package/docs/04-ai-sdk-ui/03-chatbot-resume-streams.mdx +2 -2
  31. package/docs/04-ai-sdk-ui/03-chatbot-tool-usage.mdx +7 -9
  32. package/docs/04-ai-sdk-ui/05-completion.mdx +1 -1
  33. package/docs/04-ai-sdk-ui/50-stream-protocol.mdx +2 -2
  34. package/docs/05-ai-sdk-rsc/03-generative-ui-state.mdx +8 -7
  35. package/docs/05-ai-sdk-rsc/06-loading-state.mdx +19 -10
  36. package/docs/05-ai-sdk-rsc/08-error-handling.mdx +2 -0
  37. package/docs/05-ai-sdk-rsc/10-migrating-to-ui.mdx +4 -3
  38. package/docs/06-advanced/02-stopping-streams.mdx +2 -2
  39. package/docs/06-advanced/04-caching.mdx +9 -5
  40. package/docs/06-advanced/05-multiple-streamables.mdx +1 -1
  41. package/docs/06-advanced/07-rendering-ui-with-language-models.mdx +16 -16
  42. package/docs/06-advanced/09-multistep-interfaces.mdx +1 -1
  43. package/docs/07-reference/01-ai-sdk-core/01-generate-text.mdx +4 -4
  44. package/docs/07-reference/01-ai-sdk-core/02-stream-text.mdx +4 -4
  45. package/docs/07-reference/01-ai-sdk-core/11-stream-transcribe.mdx +7 -0
  46. package/docs/07-reference/01-ai-sdk-core/11-transcribe.mdx +7 -0
  47. package/docs/07-reference/01-ai-sdk-core/12-generate-speech.mdx +7 -0
  48. package/docs/07-reference/01-ai-sdk-core/14-upload-file.mdx +4 -4
  49. package/docs/07-reference/01-ai-sdk-core/14-upload-skill.mdx +1 -1
  50. package/docs/07-reference/01-ai-sdk-core/15-agent.mdx +1 -1
  51. package/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +1 -4
  52. package/docs/07-reference/01-ai-sdk-core/22-dynamic-tool.mdx +1 -1
  53. package/docs/07-reference/01-ai-sdk-core/23-create-mcp-client.mdx +1 -1
  54. package/docs/07-reference/01-ai-sdk-core/30-model-message.mdx +2 -2
  55. package/docs/07-reference/01-ai-sdk-core/69-add-tool-input-examples-middleware.mdx +1 -1
  56. package/docs/07-reference/01-ai-sdk-core/80-smooth-stream.mdx +1 -1
  57. package/docs/07-reference/02-ai-sdk-ui/31-convert-to-model-messages.mdx +5 -4
  58. package/docs/07-reference/02-ai-sdk-ui/40-create-ui-message-stream.mdx +3 -2
  59. package/docs/07-reference/02-ai-sdk-ui/41-create-ui-message-stream-response.mdx +7 -0
  60. package/docs/07-reference/02-ai-sdk-ui/42-pipe-ui-message-stream-to-response.mdx +7 -0
  61. package/docs/07-reference/02-ai-sdk-ui/50-direct-chat-transport.mdx +2 -2
  62. package/docs/07-reference/03-ai-sdk-rsc/01-stream-ui.mdx +2 -2
  63. package/docs/07-reference/04-ai-sdk-workflow/01-workflow-agent.mdx +1 -1
  64. package/docs/08-migration-guides/25-migration-guide-5-0-data.mdx +4 -5
  65. package/docs/08-migration-guides/26-migration-guide-5-0.mdx +2 -1
  66. package/docs/08-migration-guides/29-migration-guide-4-0.mdx +4 -4
  67. package/docs/08-migration-guides/38-migration-guide-3-2.mdx +1 -1
  68. package/docs/08-migration-guides/39-migration-guide-3-1.mdx +1 -1
  69. package/docs/09-troubleshooting/12-use-chat-an-error-occurred.mdx +8 -6
  70. package/docs/09-troubleshooting/50-react-maximum-update-depth-exceeded.mdx +6 -6
  71. package/docs/09-troubleshooting/70-high-memory-usage-with-images.mdx +1 -1
  72. package/package.json +17 -17
  73. package/src/agent/create-agent-ui-stream-response.ts +3 -0
  74. package/src/agent/pipe-agent-ui-stream-to-response.ts +3 -0
  75. package/src/generate-speech/generate-speech.ts +163 -38
  76. package/src/generate-speech/index.ts +4 -0
  77. package/src/generate-speech/speech-events.ts +91 -0
  78. package/src/generate-text/prune-messages.ts +1 -1
  79. package/src/middleware/extract-reasoning-middleware.ts +27 -11
  80. package/src/telemetry/create-telemetry-dispatcher.ts +18 -5
  81. package/src/telemetry/telemetry.ts +38 -6
  82. package/src/telemetry/tracing-channel.ts +3 -0
  83. package/src/transcribe/index.ts +6 -0
  84. package/src/transcribe/stream-transcribe.ts +182 -31
  85. package/src/transcribe/transcribe.ts +186 -33
  86. package/src/transcribe/transcription-events.ts +111 -0
  87. package/src/ui/convert-to-model-messages.ts +18 -6
  88. package/src/ui-message-stream/create-sse-stream-with-keep-alive.ts +89 -0
  89. package/src/ui-message-stream/create-ui-message-stream-response.ts +7 -1
  90. package/src/ui-message-stream/pipe-ui-message-stream-to-response.ts +7 -1
  91. package/src/ui-message-stream/ui-message-stream-response-init.ts +7 -0
@@ -1,54 +1,51 @@
1
- import * as _ai_sdk_provider from '@ai-sdk/provider';
2
- import { EmbeddingModelV4Embedding, LanguageModelV4Source, SharedV4Warning, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4ProviderMetadata, JSONObject, LanguageModelV4Usage, Experimental_EvaluationModelV4Question, Experimental_EvaluationModelV4Result, Experimental_EvaluationModelV4CallOptions, LanguageModelV4CallOptions, LanguageModelV4Prompt, AISDKError, LanguageModelV4ToolCall, JSONSchema7, ProviderV4, ProviderV3, ProviderV2, LanguageModelV4ToolResultOutput, LanguageModelV4ToolChoice, LanguageModelV4FunctionTool, LanguageModelV4ProviderTool } from '@ai-sdk/provider';
3
- import { GatewayModelId } from '@ai-sdk/gateway';
4
- import { ModelMessage, AssistantModelMessage, ToolModelMessage, Context, ProviderOptions, ToolSet, SystemModelMessage, InferToolSetContext, Arrayable, InferToolInput, InferToolOutput, ReasoningPart, ReasoningFilePart, MaybePromiseLike, ToolExecutionOptions, InferToolContext, HasRequiredKey, ToolResultOutput, Tool, Experimental_SandboxSession, ShouldRetryFunction, RetryFunction, FlexibleSchema, ToolApprovalRequest, ToolApprovalResponse, ToolResultPart } from '@ai-sdk/provider-utils';
5
- export { convertAsyncIteratorToReadableStream } from '@ai-sdk/provider-utils';
6
-
1
+ import { Arrayable, AssistantModelMessage, AssistantModelMessage as AssistantModelMessage$1, Context, Experimental_SandboxSession, FlexibleSchema, HasRequiredKey, InferToolContext, InferToolInput, InferToolOutput, InferToolSetContext, MaybePromiseLike, ModelMessage, ModelMessage as ModelMessage$1, ProviderOptions, ReasoningFilePart, ReasoningPart, RetryFunction, ShouldRetryFunction, SystemModelMessage, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolExecutionOptions, ToolModelMessage, ToolModelMessage as ToolModelMessage$1, ToolResultOutput, ToolResultPart, ToolSet, convertAsyncIteratorToReadableStream } from "@ai-sdk/provider-utils";
2
+ import { AISDKError, EmbeddingModelV4Embedding, Experimental_EvaluationModelV4CallOptions, Experimental_EvaluationModelV4Question, Experimental_EvaluationModelV4Result, JSONObject, JSONSchema7, LanguageModelV2, LanguageModelV3, LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4FunctionTool, LanguageModelV4Prompt, LanguageModelV4ProviderTool, LanguageModelV4Source, LanguageModelV4ToolCall, LanguageModelV4ToolChoice, LanguageModelV4ToolResultOutput, LanguageModelV4Usage, ProviderV2, ProviderV3, ProviderV4, SharedV4AudioFormat, SharedV4ProviderMetadata, SharedV4Warning } from "@ai-sdk/provider";
3
+ import { array, boolean, custom, discriminatedUnion, enum as enum$1, instanceof as instanceof$1, lazy, literal, looseObject, never, null as null$1, number, object, record, string, union, unknown } from "zod/v4";
4
+ import { GatewayModelId } from "@ai-sdk/gateway";
5
+ //#region src/types/embedding-model.d.ts
7
6
  /**
8
7
  * Embedding.
9
8
  */
10
9
  type Embedding = EmbeddingModelV4Embedding;
11
-
10
+ //#endregion
11
+ //#region src/types/language-model.d.ts
12
12
  declare global {
13
- /**
14
- * Global interface that can be augmented by third-party packages to register custom model IDs.
15
- *
16
- * You can register model IDs in two ways:
17
- *
18
- * 1. Register based on Model IDs from a provider package:
19
- * @example
20
- * ```typescript
21
- * import { openai } from '@ai-sdk/openai';
22
- * type OpenAIResponsesModelId = Parameters<typeof openai>[0];
23
- *
24
- * declare global {
25
- * interface RegisteredProviderModels {
26
- * openai: OpenAIResponsesModelId;
27
- * }
28
- * }
29
- * ```
30
- *
31
- * 2. Register individual model IDs directly as keys:
32
- * @example
33
- * ```typescript
34
- * declare global {
35
- * interface RegisteredProviderModels {
36
- * 'my-provider:my-model': any;
37
- * 'my-provider:another-model': any;
38
- * }
39
- * }
40
- * ```
41
- */
42
- interface RegisteredProviderModels {
43
- }
13
+ /**
14
+ * Global interface that can be augmented by third-party packages to register custom model IDs.
15
+ *
16
+ * You can register model IDs in two ways:
17
+ *
18
+ * 1. Register based on Model IDs from a provider package:
19
+ * @example
20
+ * ```typescript
21
+ * import { openai } from '@ai-sdk/openai';
22
+ * type OpenAIResponsesModelId = Parameters<typeof openai>[0];
23
+ *
24
+ * declare global {
25
+ * interface RegisteredProviderModels {
26
+ * openai: OpenAIResponsesModelId;
27
+ * }
28
+ * }
29
+ * ```
30
+ *
31
+ * 2. Register individual model IDs directly as keys:
32
+ * @example
33
+ * ```typescript
34
+ * declare global {
35
+ * interface RegisteredProviderModels {
36
+ * 'my-provider:my-model': any;
37
+ * 'my-provider:another-model': any;
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ interface RegisteredProviderModels {}
44
43
  }
45
44
  /**
46
45
  * Global provider model ID type that defaults to GatewayModelId but can be augmented
47
46
  * by third-party packages via declaration merging.
48
47
  */
49
- type GlobalProviderModelId = [keyof RegisteredProviderModels] extends [
50
- never
51
- ] ? GatewayModelId : keyof RegisteredProviderModels | RegisteredProviderModels[keyof RegisteredProviderModels];
48
+ type GlobalProviderModelId = [keyof RegisteredProviderModels] extends [never] ? GatewayModelId : keyof RegisteredProviderModels | RegisteredProviderModels[keyof RegisteredProviderModels];
52
49
  /**
53
50
  * Language model that is used by the AI SDK.
54
51
  */
@@ -83,62 +80,66 @@ type Source = LanguageModelV4Source;
83
80
  * - `{ type: 'tool', toolName: string (typed) }`: the model must call the specified tool
84
81
  */
85
82
  type ToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | 'required' | {
86
- type: 'tool';
87
- toolName: Extract<keyof TOOLS, string>;
83
+ type: 'tool';
84
+ toolName: Extract<keyof TOOLS, string>;
88
85
  };
89
-
86
+ //#endregion
87
+ //#region src/types/language-model-request-metadata.d.ts
90
88
  /**
91
89
  * Metadata for a language model request.
92
90
  */
93
91
  type LanguageModelRequestMetadata = {
94
- /**
95
- * The input messages that were sent to the model for this step.
96
- */
97
- readonly messages?: Array<ModelMessage>;
98
- /**
99
- * Request HTTP body that was sent to the provider API.
100
- */
101
- readonly body?: unknown;
102
- };
103
-
92
+ /**
93
+ * The input messages that were sent to the model for this step.
94
+ */
95
+ readonly messages?: Array<ModelMessage>;
96
+ /**
97
+ * Request HTTP body that was sent to the provider API.
98
+ */
99
+ readonly body?: unknown;
100
+ };
101
+ //#endregion
102
+ //#region src/generate-text/response-message.d.ts
104
103
  /**
105
104
  * A message that was generated during the generation process.
106
105
  * It can be either an assistant message or a tool message.
107
106
  */
108
107
  type ResponseMessage = AssistantModelMessage | ToolModelMessage;
109
-
108
+ //#endregion
109
+ //#region src/types/language-model-response-metadata.d.ts
110
110
  /**
111
111
  * Metadata for a language model response.
112
112
  */
113
113
  type LanguageModelResponseMetadata = {
114
- /**
115
- * The response messages that were generated during the call.
116
- * Response messages can be either assistant messages or tool messages.
117
- * They contain a generated id.
118
- */
119
- readonly messages: Array<ResponseMessage>;
120
- /**
121
- * ID for the generated response.
122
- */
123
- readonly id: string;
124
- /**
125
- * Timestamp for the start of the generated response.
126
- */
127
- readonly timestamp: Date;
128
- /**
129
- * The ID of the response model that was used to generate the response.
130
- */
131
- readonly modelId: string;
132
- /**
133
- * Response headers (available only for providers that use HTTP requests).
134
- */
135
- readonly headers?: Record<string, string>;
136
- /**
137
- * Response body (available only for providers that use HTTP requests).
138
- */
139
- readonly body?: unknown;
140
- };
141
-
114
+ /**
115
+ * The response messages that were generated during the call.
116
+ * Response messages can be either assistant messages or tool messages.
117
+ * They contain a generated id.
118
+ */
119
+ readonly messages: Array<ResponseMessage>;
120
+ /**
121
+ * ID for the generated response.
122
+ */
123
+ readonly id: string;
124
+ /**
125
+ * Timestamp for the start of the generated response.
126
+ */
127
+ readonly timestamp: Date;
128
+ /**
129
+ * The ID of the response model that was used to generate the response.
130
+ */
131
+ readonly modelId: string;
132
+ /**
133
+ * Response headers (available only for providers that use HTTP requests).
134
+ */
135
+ readonly headers?: Record<string, string>;
136
+ /**
137
+ * Response body (available only for providers that use HTTP requests).
138
+ */
139
+ readonly body?: unknown;
140
+ };
141
+ //#endregion
142
+ //#region src/types/provider-metadata.d.ts
142
143
  /**
143
144
  * Additional provider-specific metadata that is returned from the provider.
144
145
  *
@@ -146,80 +147,119 @@ type LanguageModelResponseMetadata = {
146
147
  * fully encapsulated in the provider.
147
148
  */
148
149
  type ProviderMetadata = SharedV4ProviderMetadata;
149
-
150
+ //#endregion
151
+ //#region src/types/speech-model-response-metadata.d.ts
152
+ type SpeechModelResponseMetadata = {
153
+ /**
154
+ * Timestamp for the start of the generated response.
155
+ */
156
+ timestamp: Date;
157
+ /**
158
+ * The ID of the response model that was used to generate the response.
159
+ */
160
+ modelId: string;
161
+ /**
162
+ * Response headers.
163
+ */
164
+ headers?: Record<string, string>;
165
+ /**
166
+ * Response body.
167
+ */
168
+ body?: unknown;
169
+ };
170
+ //#endregion
171
+ //#region src/types/transcription-model-response-metadata.d.ts
172
+ type TranscriptionModelResponseMetadata = {
173
+ /**
174
+ * Timestamp for the start of the generated response.
175
+ */
176
+ timestamp: Date;
177
+ /**
178
+ * The ID of the response model that was used to generate the response.
179
+ */
180
+ modelId: string;
181
+ /**
182
+ * Response headers.
183
+ */
184
+ headers?: Record<string, string>;
185
+ };
186
+ //#endregion
187
+ //#region src/types/usage.d.ts
150
188
  /**
151
189
  * Represents the number of tokens used in a prompt and completion.
152
190
  */
153
191
  type LanguageModelUsage = {
192
+ /**
193
+ * The total number of input (prompt) tokens used.
194
+ */
195
+ inputTokens: number | undefined;
196
+ /**
197
+ * Detailed information about the input tokens.
198
+ */
199
+ inputTokenDetails: {
154
200
  /**
155
- * The total number of input (prompt) tokens used.
201
+ * The number of non-cached input (prompt) tokens used.
156
202
  */
157
- inputTokens: number | undefined;
203
+ noCacheTokens: number | undefined;
158
204
  /**
159
- * Detailed information about the input tokens.
205
+ * The number of cached input (prompt) tokens read.
160
206
  */
161
- inputTokenDetails: {
162
- /**
163
- * The number of non-cached input (prompt) tokens used.
164
- */
165
- noCacheTokens: number | undefined;
166
- /**
167
- * The number of cached input (prompt) tokens read.
168
- */
169
- cacheReadTokens: number | undefined;
170
- /**
171
- * The number of cached input (prompt) tokens written.
172
- */
173
- cacheWriteTokens: number | undefined;
174
- };
207
+ cacheReadTokens: number | undefined;
175
208
  /**
176
- * The number of total output (completion) tokens used.
209
+ * The number of cached input (prompt) tokens written.
177
210
  */
178
- outputTokens: number | undefined;
211
+ cacheWriteTokens: number | undefined;
212
+ };
213
+ /**
214
+ * The number of total output (completion) tokens used.
215
+ */
216
+ outputTokens: number | undefined;
217
+ /**
218
+ * Detailed information about the output tokens.
219
+ */
220
+ outputTokenDetails: {
179
221
  /**
180
- * Detailed information about the output tokens.
222
+ * The number of text tokens used.
181
223
  */
182
- outputTokenDetails: {
183
- /**
184
- * The number of text tokens used.
185
- */
186
- textTokens: number | undefined;
187
- /**
188
- * The number of reasoning tokens used.
189
- */
190
- reasoningTokens: number | undefined;
191
- };
192
- /**
193
- * The total number of tokens used.
194
- */
195
- totalTokens: number | undefined;
224
+ textTokens: number | undefined;
196
225
  /**
197
- * Raw usage information from the provider.
198
- *
199
- * This is the usage information in the shape that the provider returns.
200
- * It can include additional information that is not part of the standard usage information.
226
+ * The number of reasoning tokens used.
201
227
  */
202
- raw?: JSONObject;
228
+ reasoningTokens: number | undefined;
229
+ };
230
+ /**
231
+ * The total number of tokens used.
232
+ */
233
+ totalTokens: number | undefined;
234
+ /**
235
+ * Raw usage information from the provider.
236
+ *
237
+ * This is the usage information in the shape that the provider returns.
238
+ * It can include additional information that is not part of the standard usage information.
239
+ */
240
+ raw?: JSONObject;
203
241
  };
204
242
  /**
205
243
  * Represents the number of tokens used in an embedding.
206
244
  */
207
245
  type EmbeddingModelUsage = {
208
- /**
209
- * The number of tokens used in the embedding.
210
- */
211
- tokens: number;
246
+ /**
247
+ * The number of tokens used in the embedding.
248
+ */
249
+ tokens: number;
212
250
  };
213
- declare function asLanguageModelUsage(usage: LanguageModelV4Usage): LanguageModelUsage;
214
- declare function createNullLanguageModelUsage(): LanguageModelUsage;
215
- declare function addLanguageModelUsage(usage1: LanguageModelUsage, usage2: LanguageModelUsage): LanguageModelUsage;
216
-
251
+ export declare function asLanguageModelUsage(usage: LanguageModelV4Usage): LanguageModelUsage;
252
+ export declare function createNullLanguageModelUsage(): LanguageModelUsage;
253
+ export declare function addLanguageModelUsage(usage1: LanguageModelUsage, usage2: LanguageModelUsage): LanguageModelUsage;
254
+ //#endregion
255
+ //#region src/types/warning.d.ts
217
256
  /**
218
257
  * Warning from the model provider for this call. The call will proceed, but e.g.
219
258
  * some settings might not be supported, which can lead to suboptimal results.
220
259
  */
221
260
  type Warning = SharedV4Warning;
222
-
261
+ //#endregion
262
+ //#region src/logger/log-warnings.d.ts
223
263
  /**
224
264
  * A function for logging warnings.
225
265
  *
@@ -233,44 +273,45 @@ type Warning = SharedV4Warning;
233
273
  * ```
234
274
  */
235
275
  type LogWarningsFunction = (options: {
236
- /**
237
- * The warnings returned by the model provider.
238
- */
239
- warnings: Warning[];
240
- /**
241
- * The provider id used for the call, if scoped to a specific provider.
242
- */
243
- provider?: string;
244
- /**
245
- * The model id used for the call, if scoped to a specific provider.
246
- */
247
- model?: string;
276
+ /**
277
+ * The warnings returned by the model provider.
278
+ */
279
+ warnings: Warning[];
280
+ /**
281
+ * The provider id used for the call, if scoped to a specific provider.
282
+ */
283
+ provider?: string;
284
+ /**
285
+ * The model id used for the call, if scoped to a specific provider.
286
+ */
287
+ model?: string;
248
288
  }) => void;
249
-
289
+ //#endregion
290
+ //#region src/embed/embed-events.d.ts
250
291
  /**
251
292
  * Event passed to the `onStart` callback for embed and embedMany operations.
252
293
  *
253
294
  * Called when the operation begins, before the embedding model is called.
254
295
  */
255
296
  type EmbedStartEvent<RUNTIME_CONTEXT extends Context = Context> = {
256
- /** User-defined runtime context. */
257
- readonly runtimeContext: RUNTIME_CONTEXT;
258
- /** Unique identifier for this embed call, used to correlate events. */
259
- readonly callId: string;
260
- /** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
261
- readonly operationId: string;
262
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
263
- readonly provider: string;
264
- /** The specific model identifier (e.g., 'text-embedding-3-small'). */
265
- readonly modelId: string;
266
- /** The value(s) being embedded. A string for embed, an array for embedMany. */
267
- readonly value: string | Array<string>;
268
- /** Maximum number of retries for failed requests. */
269
- readonly maxRetries: number;
270
- /** Additional HTTP headers sent with the request. */
271
- readonly headers: Record<string, string | undefined> | undefined;
272
- /** Additional provider-specific options. */
273
- readonly providerOptions: ProviderOptions | undefined;
297
+ /** User-defined runtime context. */
298
+ readonly runtimeContext: RUNTIME_CONTEXT;
299
+ /** Unique identifier for this embed call, used to correlate events. */
300
+ readonly callId: string;
301
+ /** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
302
+ readonly operationId: string;
303
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
304
+ readonly provider: string;
305
+ /** The specific model identifier (e.g., 'text-embedding-3-small'). */
306
+ readonly modelId: string;
307
+ /** The value(s) being embedded. A string for embed, an array for embedMany. */
308
+ readonly value: string | Array<string>;
309
+ /** Maximum number of retries for failed requests. */
310
+ readonly maxRetries: number;
311
+ /** Additional HTTP headers sent with the request. */
312
+ readonly headers: Record<string, string | undefined> | undefined;
313
+ /** Additional provider-specific options. */
314
+ readonly providerOptions: ProviderOptions | undefined;
274
315
  };
275
316
  /**
276
317
  * Event passed to the `onEnd` callback for embed and embedMany operations.
@@ -278,34 +319,34 @@ type EmbedStartEvent<RUNTIME_CONTEXT extends Context = Context> = {
278
319
  * Called when the operation completes, after the embedding model returns.
279
320
  */
280
321
  type EmbedEndEvent<RUNTIME_CONTEXT extends Context = Context> = {
281
- /** User-defined runtime context. */
282
- readonly runtimeContext: RUNTIME_CONTEXT;
283
- /** Unique identifier for this embed call, used to correlate events. */
284
- readonly callId: string;
285
- /** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
286
- readonly operationId: string;
287
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
288
- readonly provider: string;
289
- /** The specific model identifier (e.g., 'text-embedding-3-small'). */
290
- readonly modelId: string;
291
- /** The value(s) that were embedded. A string for embed, an array for embedMany. */
292
- readonly value: string | Array<string>;
293
- /** The resulting embedding(s). A single vector for embed, an array for embedMany. */
294
- readonly embedding: Embedding | Array<Embedding>;
295
- /** Token usage for the embedding operation. */
296
- readonly usage: EmbeddingModelUsage;
297
- /** Warnings from the embedding model, e.g. unsupported settings. */
298
- readonly warnings: Array<Warning>;
299
- /** Optional provider-specific metadata. */
300
- readonly providerMetadata: ProviderMetadata | undefined;
301
- /** Response data including headers and body. A single response for embed, an array for embedMany. */
302
- readonly response: {
303
- headers?: Record<string, string>;
304
- body?: unknown;
305
- } | Array<{
306
- headers?: Record<string, string>;
307
- body?: unknown;
308
- } | undefined> | undefined;
322
+ /** User-defined runtime context. */
323
+ readonly runtimeContext: RUNTIME_CONTEXT;
324
+ /** Unique identifier for this embed call, used to correlate events. */
325
+ readonly callId: string;
326
+ /** Identifies the operation type (e.g. 'ai.embed' or 'ai.embedMany'). */
327
+ readonly operationId: string;
328
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
329
+ readonly provider: string;
330
+ /** The specific model identifier (e.g., 'text-embedding-3-small'). */
331
+ readonly modelId: string;
332
+ /** The value(s) that were embedded. A string for embed, an array for embedMany. */
333
+ readonly value: string | Array<string>;
334
+ /** The resulting embedding(s). A single vector for embed, an array for embedMany. */
335
+ readonly embedding: Embedding | Array<Embedding>;
336
+ /** Token usage for the embedding operation. */
337
+ readonly usage: EmbeddingModelUsage;
338
+ /** Warnings from the embedding model, e.g. unsupported settings. */
339
+ readonly warnings: Array<Warning>;
340
+ /** Optional provider-specific metadata. */
341
+ readonly providerMetadata: ProviderMetadata | undefined;
342
+ /** Response data including headers and body. A single response for embed, an array for embedMany. */
343
+ readonly response: {
344
+ headers?: Record<string, string>;
345
+ body?: unknown;
346
+ } | Array<{
347
+ headers?: Record<string, string>;
348
+ body?: unknown;
349
+ } | undefined> | undefined;
309
350
  };
310
351
  /**
311
352
  * Event fired when an individual embedding model call (inner operation doEmbed) begins.
@@ -314,18 +355,18 @@ type EmbedEndEvent<RUNTIME_CONTEXT extends Context = Context> = {
314
355
  * calls when values are chunked.
315
356
  */
316
357
  type EmbeddingModelCallStartEvent = {
317
- /** Unique identifier for this embed call, used to correlate events. */
318
- readonly callId: string;
319
- /** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
320
- readonly embedCallId: string;
321
- /** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
322
- readonly operationId: string;
323
- /** The provider identifier. */
324
- readonly provider: string;
325
- /** The specific model identifier. */
326
- readonly modelId: string;
327
- /** The values being embedded in this particular model call. */
328
- readonly values: Array<string>;
358
+ /** Unique identifier for this embed call, used to correlate events. */
359
+ readonly callId: string;
360
+ /** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
361
+ readonly embedCallId: string;
362
+ /** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
363
+ readonly operationId: string;
364
+ /** The provider identifier. */
365
+ readonly provider: string;
366
+ /** The specific model identifier. */
367
+ readonly modelId: string;
368
+ /** The values being embedded in this particular model call. */
369
+ readonly values: Array<string>;
329
370
  };
330
371
  /**
331
372
  * Event fired when an individual embedding model call (doEmbed) completes.
@@ -333,86 +374,86 @@ type EmbeddingModelCallStartEvent = {
333
374
  * Contains the embeddings, usage, and any warnings from the model response.
334
375
  */
335
376
  type EmbeddingModelCallEndEvent = {
336
- /** Unique identifier for this embed call, used to correlate events. */
337
- readonly callId: string;
338
- /** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
339
- readonly embedCallId: string;
340
- /** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
341
- readonly operationId: string;
342
- /** The provider identifier. */
343
- readonly provider: string;
344
- /** The specific model identifier. */
345
- readonly modelId: string;
346
- /** The values that were embedded in this particular model call. */
347
- readonly values: Array<string>;
348
- /** The resulting embeddings from the model call. */
349
- readonly embeddings: Array<Embedding>;
350
- /** Token usage for this model call. */
351
- readonly usage: EmbeddingModelUsage;
352
- };
353
-
377
+ /** Unique identifier for this embed call, used to correlate events. */
378
+ readonly callId: string;
379
+ /** Unique identifier for this individual doEmbed invocation, used to correlate start/finish within parallel chunks. */
380
+ readonly embedCallId: string;
381
+ /** Identifies the inner operation (e.g. 'ai.embed.doEmbed' or 'ai.embedMany.doEmbed'). */
382
+ readonly operationId: string;
383
+ /** The provider identifier. */
384
+ readonly provider: string;
385
+ /** The specific model identifier. */
386
+ readonly modelId: string;
387
+ /** The values that were embedded in this particular model call. */
388
+ readonly values: Array<string>;
389
+ /** The resulting embeddings from the model call. */
390
+ readonly embeddings: Array<Embedding>;
391
+ /** Token usage for this model call. */
392
+ readonly usage: EmbeddingModelUsage;
393
+ };
394
+ //#endregion
395
+ //#region src/evaluate/evaluation-result.d.ts
354
396
  type EvaluationQuestion = Experimental_EvaluationModelV4Question;
355
397
  type EvaluationAnswer<QUESTION extends EvaluationQuestion> = QUESTION extends {
356
- type: 'choice';
357
- criteria: infer CRITERIA;
398
+ type: 'choice';
399
+ criteria: infer CRITERIA;
358
400
  } ? {
359
- type: 'choice';
360
- choice: Extract<keyof CRITERIA, string>;
361
- probabilities?: Record<Extract<keyof CRITERIA, string>, number>;
401
+ type: 'choice';
402
+ choice: Extract<keyof CRITERIA, string>;
403
+ probabilities?: Record<Extract<keyof CRITERIA, string>, number>;
362
404
  } : QUESTION extends {
363
- type: 'score';
405
+ type: 'score';
364
406
  } ? {
365
- type: 'score';
366
- score: number;
367
- probabilities?: Record<string, number>;
407
+ type: 'score';
408
+ score: number;
409
+ probabilities?: Record<string, number>;
368
410
  } : {
369
- type: 'boolean';
370
- probability: number;
411
+ type: 'boolean';
412
+ probability: number;
371
413
  };
372
414
  type EvaluationResult<QUESTIONS extends Record<string, EvaluationQuestion>> = {
373
- readonly answers: {
374
- [ID in keyof QUESTIONS]: EvaluationAnswer<QUESTIONS[ID]>;
375
- };
376
- readonly usage: {
377
- inputTokens: number | undefined;
378
- outputTokens: number | undefined;
379
- totalTokens: number | undefined;
380
- };
381
- readonly warnings: Experimental_EvaluationModelV4Result['warnings'];
382
- readonly rounding: Experimental_EvaluationModelV4Result['rounding'];
383
- readonly providerMetadata: Experimental_EvaluationModelV4Result['providerMetadata'];
384
- readonly response: NonNullable<Experimental_EvaluationModelV4Result['response']> & {
385
- timestamp: Date;
386
- modelId: string;
387
- };
388
- };
389
-
415
+ readonly answers: { [ID in keyof QUESTIONS]: EvaluationAnswer<QUESTIONS[ID]>; };
416
+ readonly usage: {
417
+ inputTokens: number | undefined;
418
+ outputTokens: number | undefined;
419
+ totalTokens: number | undefined;
420
+ };
421
+ readonly warnings: Experimental_EvaluationModelV4Result['warnings'];
422
+ readonly rounding: Experimental_EvaluationModelV4Result['rounding'];
423
+ readonly providerMetadata: Experimental_EvaluationModelV4Result['providerMetadata'];
424
+ readonly response: NonNullable<Experimental_EvaluationModelV4Result['response']> & {
425
+ timestamp: Date;
426
+ modelId: string;
427
+ };
428
+ };
429
+ //#endregion
430
+ //#region src/evaluate/evaluate-events.d.ts
390
431
  /**
391
432
  * Event passed to the `onStart` callback for evaluation operations.
392
433
  *
393
434
  * Called when the operation begins, before the evaluation model is called.
394
435
  */
395
436
  type EvaluateStartEvent<RUNTIME_CONTEXT extends Context = Context> = {
396
- /** User-defined runtime context. */
397
- readonly runtimeContext: RUNTIME_CONTEXT;
398
- /** Unique identifier for this evaluation call, used to correlate events. */
399
- readonly callId: string;
400
- /** Identifies the operation type (`ai.evaluate`). */
401
- readonly operationId: 'ai.evaluate';
402
- /** The provider identifier. */
403
- readonly provider: string;
404
- /** The evaluation model identifier. */
405
- readonly modelId: string;
406
- /** The shared state being evaluated. */
407
- readonly state: Experimental_EvaluationModelV4CallOptions['state'];
408
- /** The questions being evaluated against the shared state. */
409
- readonly questions: Readonly<Record<string, EvaluationQuestion>>;
410
- /** Maximum number of retries for the evaluation model call. */
411
- readonly maxRetries: number;
412
- /** Additional HTTP headers sent with the request. */
413
- readonly headers: Record<string, string> | undefined;
414
- /** Additional provider-specific options. */
415
- readonly providerOptions: ProviderOptions;
437
+ /** User-defined runtime context. */
438
+ readonly runtimeContext: RUNTIME_CONTEXT;
439
+ /** Unique identifier for this evaluation call, used to correlate events. */
440
+ readonly callId: string;
441
+ /** Identifies the operation type (`ai.evaluate`). */
442
+ readonly operationId: 'ai.evaluate';
443
+ /** The provider identifier. */
444
+ readonly provider: string;
445
+ /** The evaluation model identifier. */
446
+ readonly modelId: string;
447
+ /** The shared state being evaluated. */
448
+ readonly state: Experimental_EvaluationModelV4CallOptions['state'];
449
+ /** The questions being evaluated against the shared state. */
450
+ readonly questions: Readonly<Record<string, EvaluationQuestion>>;
451
+ /** Maximum number of retries for the evaluation model call. */
452
+ readonly maxRetries: number;
453
+ /** Additional HTTP headers sent with the request. */
454
+ readonly headers: Record<string, string> | undefined;
455
+ /** Additional provider-specific options. */
456
+ readonly providerOptions: ProviderOptions;
416
457
  };
417
458
  /**
418
459
  * Event passed to the `onEnd` callback for evaluation operations.
@@ -420,18 +461,18 @@ type EvaluateStartEvent<RUNTIME_CONTEXT extends Context = Context> = {
420
461
  * Called when the operation completes successfully.
421
462
  */
422
463
  type EvaluateEndEvent<RUNTIME_CONTEXT extends Context = Context> = EvaluateStartEvent<RUNTIME_CONTEXT> & {
423
- /** Exactly one typed answer per question ID. */
424
- readonly answers: EvaluationResult<Record<string, EvaluationQuestion>>['answers'];
425
- /** Token usage for the evaluation operation. */
426
- readonly usage: EvaluationResult<Record<string, EvaluationQuestion>>['usage'];
427
- /** Warnings from the evaluation model. */
428
- readonly warnings: EvaluationResult<Record<string, EvaluationQuestion>>['warnings'];
429
- /** Provider-declared decimal precision for probabilities and scores. */
430
- readonly rounding: EvaluationResult<Record<string, EvaluationQuestion>>['rounding'];
431
- /** Optional provider-specific metadata. */
432
- readonly providerMetadata: EvaluationResult<Record<string, EvaluationQuestion>>['providerMetadata'];
433
- /** Response metadata, including the resolved model ID and timestamp. */
434
- readonly response: EvaluationResult<Record<string, EvaluationQuestion>>['response'];
464
+ /** Exactly one typed answer per question ID. */
465
+ readonly answers: EvaluationResult<Record<string, EvaluationQuestion>>['answers'];
466
+ /** Token usage for the evaluation operation. */
467
+ readonly usage: EvaluationResult<Record<string, EvaluationQuestion>>['usage'];
468
+ /** Warnings from the evaluation model. */
469
+ readonly warnings: EvaluationResult<Record<string, EvaluationQuestion>>['warnings'];
470
+ /** Provider-declared decimal precision for probabilities and scores. */
471
+ readonly rounding: EvaluationResult<Record<string, EvaluationQuestion>>['rounding'];
472
+ /** Optional provider-specific metadata. */
473
+ readonly providerMetadata: EvaluationResult<Record<string, EvaluationQuestion>>['providerMetadata'];
474
+ /** Response metadata, including the resolved model ID and timestamp. */
475
+ readonly response: EvaluationResult<Record<string, EvaluationQuestion>>['response'];
435
476
  };
436
477
  /**
437
478
  * Event fired when the evaluation model call begins.
@@ -439,18 +480,18 @@ type EvaluateEndEvent<RUNTIME_CONTEXT extends Context = Context> = EvaluateStart
439
480
  * The logical model call includes any provider retries.
440
481
  */
441
482
  type EvaluationModelCallStartEvent = {
442
- /** Unique identifier for the outer evaluation call. */
443
- readonly callId: string;
444
- /** Identifies the inner operation (`ai.evaluate.doEvaluate`). */
445
- readonly operationId: 'ai.evaluate.doEvaluate';
446
- /** The provider identifier. */
447
- readonly provider: string;
448
- /** The evaluation model identifier. */
449
- readonly modelId: string;
450
- /** The shared state being evaluated. */
451
- readonly state: Experimental_EvaluationModelV4CallOptions['state'];
452
- /** The questions being evaluated against the shared state. */
453
- readonly questions: Readonly<Record<string, EvaluationQuestion>>;
483
+ /** Unique identifier for the outer evaluation call. */
484
+ readonly callId: string;
485
+ /** Identifies the inner operation (`ai.evaluate.doEvaluate`). */
486
+ readonly operationId: 'ai.evaluate.doEvaluate';
487
+ /** The provider identifier. */
488
+ readonly provider: string;
489
+ /** The evaluation model identifier. */
490
+ readonly modelId: string;
491
+ /** The shared state being evaluated. */
492
+ readonly state: Experimental_EvaluationModelV4CallOptions['state'];
493
+ /** The questions being evaluated against the shared state. */
494
+ readonly questions: Readonly<Record<string, EvaluationQuestion>>;
454
495
  };
455
496
  /**
456
497
  * Event fired after the evaluation model response has been validated.
@@ -458,89 +499,91 @@ type EvaluationModelCallStartEvent = {
458
499
  * Contains the result of the logical model call, including any retries.
459
500
  */
460
501
  type EvaluationModelCallEndEvent = EvaluationModelCallStartEvent & {
461
- /** Exactly one answer per question ID. */
462
- readonly answers: Experimental_EvaluationModelV4Result['answers'];
463
- /** Token usage reported by the evaluation model. */
464
- readonly usage?: Experimental_EvaluationModelV4Result['usage'];
465
- /** Warnings from the evaluation model. */
466
- readonly warnings: Experimental_EvaluationModelV4Result['warnings'];
467
- /** Provider-declared decimal precision for probabilities and scores. */
468
- readonly rounding?: Experimental_EvaluationModelV4Result['rounding'];
469
- /** Optional provider-specific metadata. */
470
- readonly providerMetadata?: Experimental_EvaluationModelV4Result['providerMetadata'];
471
- /** Optional raw response metadata from the provider. */
472
- readonly response?: Experimental_EvaluationModelV4Result['response'];
473
- };
474
-
502
+ /** Exactly one answer per question ID. */
503
+ readonly answers: Experimental_EvaluationModelV4Result['answers'];
504
+ /** Token usage reported by the evaluation model. */
505
+ readonly usage?: Experimental_EvaluationModelV4Result['usage'];
506
+ /** Warnings from the evaluation model. */
507
+ readonly warnings: Experimental_EvaluationModelV4Result['warnings'];
508
+ /** Provider-declared decimal precision for probabilities and scores. */
509
+ readonly rounding?: Experimental_EvaluationModelV4Result['rounding'];
510
+ /** Optional provider-specific metadata. */
511
+ readonly providerMetadata?: Experimental_EvaluationModelV4Result['providerMetadata'];
512
+ /** Optional raw response metadata from the provider. */
513
+ readonly response?: Experimental_EvaluationModelV4Result['response'];
514
+ };
515
+ //#endregion
516
+ //#region src/prompt/language-model-call-options.d.ts
475
517
  /**
476
518
  * Model-facing generation controls. These settings influence how the model
477
519
  * generates its response (token limits, sampling, penalties, stop sequences,
478
520
  * seed, reasoning).
479
521
  */
480
522
  type LanguageModelCallOptions = {
481
- /**
482
- * Maximum number of tokens to generate.
483
- */
484
- maxOutputTokens?: number;
485
- /**
486
- * Temperature setting. The range depends on the provider and model.
487
- *
488
- * It is recommended to set either `temperature` or `topP`, but not both.
489
- */
490
- temperature?: number;
491
- /**
492
- * Nucleus sampling. This is a number between 0 and 1.
493
- *
494
- * E.g. 0.1 would mean that only tokens with the top 10% probability mass
495
- * are considered.
496
- *
497
- * It is recommended to set either `temperature` or `topP`, but not both.
498
- */
499
- topP?: number;
500
- /**
501
- * Only sample from the top K options for each subsequent token.
502
- *
503
- * Used to remove "long tail" low probability responses.
504
- * Recommended for advanced use cases only. You usually only need to use temperature.
505
- */
506
- topK?: number;
507
- /**
508
- * Presence penalty setting. It affects the likelihood of the model to
509
- * repeat information that is already in the prompt.
510
- *
511
- * The presence penalty is a number between -1 (increase repetition)
512
- * and 1 (maximum penalty, decrease repetition). 0 means no penalty.
513
- */
514
- presencePenalty?: number;
515
- /**
516
- * Frequency penalty setting. It affects the likelihood of the model
517
- * to repeatedly use the same words or phrases.
518
- *
519
- * The frequency penalty is a number between -1 (increase repetition)
520
- * and 1 (maximum penalty, decrease repetition). 0 means no penalty.
521
- */
522
- frequencyPenalty?: number;
523
- /**
524
- * Stop sequences.
525
- * If set, the model will stop generating text when one of the stop sequences is generated.
526
- * Providers may have limits on the number of stop sequences.
527
- */
528
- stopSequences?: string[];
529
- /**
530
- * The seed (integer) to use for random sampling. If set and supported
531
- * by the model, calls will generate deterministic results.
532
- */
533
- seed?: number;
534
- /**
535
- * Reasoning effort level for the model. Controls how much reasoning
536
- * the model performs before generating a response.
537
- *
538
- * Use `'provider-default'` to use the provider's default reasoning level.
539
- * Use `'none'` to disable reasoning (if supported by the provider).
540
- */
541
- reasoning?: LanguageModelV4CallOptions['reasoning'];
542
- };
543
-
523
+ /**
524
+ * Maximum number of tokens to generate.
525
+ */
526
+ maxOutputTokens?: number;
527
+ /**
528
+ * Temperature setting. The range depends on the provider and model.
529
+ *
530
+ * It is recommended to set either `temperature` or `topP`, but not both.
531
+ */
532
+ temperature?: number;
533
+ /**
534
+ * Nucleus sampling. This is a number between 0 and 1.
535
+ *
536
+ * E.g. 0.1 would mean that only tokens with the top 10% probability mass
537
+ * are considered.
538
+ *
539
+ * It is recommended to set either `temperature` or `topP`, but not both.
540
+ */
541
+ topP?: number;
542
+ /**
543
+ * Only sample from the top K options for each subsequent token.
544
+ *
545
+ * Used to remove "long tail" low probability responses.
546
+ * Recommended for advanced use cases only. You usually only need to use temperature.
547
+ */
548
+ topK?: number;
549
+ /**
550
+ * Presence penalty setting. It affects the likelihood of the model to
551
+ * repeat information that is already in the prompt.
552
+ *
553
+ * The presence penalty is a number between -1 (increase repetition)
554
+ * and 1 (maximum penalty, decrease repetition). 0 means no penalty.
555
+ */
556
+ presencePenalty?: number;
557
+ /**
558
+ * Frequency penalty setting. It affects the likelihood of the model
559
+ * to repeatedly use the same words or phrases.
560
+ *
561
+ * The frequency penalty is a number between -1 (increase repetition)
562
+ * and 1 (maximum penalty, decrease repetition). 0 means no penalty.
563
+ */
564
+ frequencyPenalty?: number;
565
+ /**
566
+ * Stop sequences.
567
+ * If set, the model will stop generating text when one of the stop sequences is generated.
568
+ * Providers may have limits on the number of stop sequences.
569
+ */
570
+ stopSequences?: string[];
571
+ /**
572
+ * The seed (integer) to use for random sampling. If set and supported
573
+ * by the model, calls will generate deterministic results.
574
+ */
575
+ seed?: number;
576
+ /**
577
+ * Reasoning effort level for the model. Controls how much reasoning
578
+ * the model performs before generating a response.
579
+ *
580
+ * Use `'provider-default'` to use the provider's default reasoning level.
581
+ * Use `'none'` to disable reasoning (if supported by the provider).
582
+ */
583
+ reasoning?: LanguageModelV4CallOptions['reasoning'];
584
+ };
585
+ //#endregion
586
+ //#region src/prompt/request-options.d.ts
544
587
  /**
545
588
  * Timeout configuration for API calls. Can be specified as:
546
589
  * - A number representing milliseconds
@@ -552,14 +595,15 @@ type LanguageModelCallOptions = {
552
595
  * - An object with `tools` property for per-tool timeout overrides using `{toolName}Ms` keys
553
596
  */
554
597
  type TimeoutConfiguration<TOOLS extends ToolSet> = number | {
555
- totalMs?: number;
556
- stepMs?: number;
557
- firstChunkMs?: number;
558
- chunkMs?: number;
559
- toolMs?: number;
560
- tools?: Partial<Record<`${keyof TOOLS & string}Ms`, number>>;
598
+ totalMs?: number;
599
+ stepMs?: number;
600
+ firstChunkMs?: number;
601
+ chunkMs?: number;
602
+ toolMs?: number;
603
+ tools?: Partial<Record<`${keyof TOOLS & string}Ms`, number>>;
561
604
  };
562
-
605
+ //#endregion
606
+ //#region src/prompt/prompt.d.ts
563
607
  /**
564
608
  * Instructions to include in the prompt. Can be used with `prompt` or `messages`.
565
609
  */
@@ -569,53 +613,54 @@ type Instructions = string | SystemModelMessage | Array<SystemModelMessage>;
569
613
  * It contains instructions, a simple text prompt, or a list of messages.
570
614
  */
571
615
  type Prompt = {
572
- /**
573
- * Instructions to include in the prompt. Can be used with `prompt` or `messages`.
574
- */
575
- instructions?: Instructions;
576
- /**
577
- * Instructions to include in the prompt. Can be used with `prompt` or `messages`.
578
- *
579
- * @deprecated Use `instructions` instead.
580
- */
581
- system?: Instructions;
582
- /**
583
- * Whether system messages are allowed in the `prompt` or `messages` fields.
584
- *
585
- * When disabled, system messages must be provided through the `instructions`
586
- * option.
587
- *
588
- * @default false
589
- */
590
- allowSystemInMessages?: boolean;
616
+ /**
617
+ * Instructions to include in the prompt. Can be used with `prompt` or `messages`.
618
+ */
619
+ instructions?: Instructions;
620
+ /**
621
+ * Instructions to include in the prompt. Can be used with `prompt` or `messages`.
622
+ *
623
+ * @deprecated Use `instructions` instead.
624
+ */
625
+ system?: Instructions;
626
+ /**
627
+ * Whether system messages are allowed in the `prompt` or `messages` fields.
628
+ *
629
+ * When disabled, system messages must be provided through the `instructions`
630
+ * option.
631
+ *
632
+ * @default false
633
+ */
634
+ allowSystemInMessages?: boolean;
591
635
  } & ({
592
- /**
593
- * A prompt. It can be either a text prompt or a list of messages.
594
- *
595
- * You can either use `prompt` or `messages` but not both.
596
- */
597
- prompt: string | Array<ModelMessage>;
598
- /**
599
- * A list of messages.
600
- *
601
- * You can either use `prompt` or `messages` but not both.
602
- */
603
- messages?: never;
636
+ /**
637
+ * A prompt. It can be either a text prompt or a list of messages.
638
+ *
639
+ * You can either use `prompt` or `messages` but not both.
640
+ */
641
+ prompt: string | Array<ModelMessage>;
642
+ /**
643
+ * A list of messages.
644
+ *
645
+ * You can either use `prompt` or `messages` but not both.
646
+ */
647
+ messages?: never;
604
648
  } | {
605
- /**
606
- * A list of messages.
607
- *
608
- * You can either use `prompt` or `messages` but not both.
609
- */
610
- messages: Array<ModelMessage>;
611
- /**
612
- * A prompt. It can be either a text prompt or a list of messages.
613
- *
614
- * You can either use `prompt` or `messages` but not both.
615
- */
616
- prompt?: never;
649
+ /**
650
+ * A list of messages.
651
+ *
652
+ * You can either use `prompt` or `messages` but not both.
653
+ */
654
+ messages: Array<ModelMessage>;
655
+ /**
656
+ * A prompt. It can be either a text prompt or a list of messages.
657
+ *
658
+ * You can either use `prompt` or `messages` but not both.
659
+ */
660
+ prompt?: never;
617
661
  });
618
-
662
+ //#endregion
663
+ //#region src/generate-object/structured-output-events.d.ts
619
664
  /**
620
665
  * Event passed to the `onStart` callback of
621
666
  * `generateObject` and `streamObject`.
@@ -625,48 +670,48 @@ type Prompt = {
625
670
  * @deprecated
626
671
  */
627
672
  interface GenerateObjectStartEvent {
628
- /** Unique identifier for this generation call, used to correlate events. */
629
- readonly callId: string;
630
- /** Identifies the operation type (e.g. `'ai.generateObject'` or `'ai.streamObject'`). */
631
- readonly operationId: string;
632
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
633
- readonly provider: string;
634
- /** The specific model identifier (e.g., 'gpt-4o'). */
635
- readonly modelId: string;
636
- /** The system message(s) provided to the model. */
637
- readonly system: Instructions | undefined;
638
- /** The prompt string or array of messages if using the prompt option. */
639
- readonly prompt: string | Array<ModelMessage> | undefined;
640
- /** The messages array if using the messages option. */
641
- readonly messages: Array<ModelMessage> | undefined;
642
- /** Maximum number of tokens to generate. */
643
- readonly maxOutputTokens: number | undefined;
644
- /** Sampling temperature for generation. */
645
- readonly temperature: number | undefined;
646
- /** Top-p (nucleus) sampling parameter. */
647
- readonly topP: number | undefined;
648
- /** Top-k sampling parameter. */
649
- readonly topK: number | undefined;
650
- /** Presence penalty for generation. */
651
- readonly presencePenalty: number | undefined;
652
- /** Frequency penalty for generation. */
653
- readonly frequencyPenalty: number | undefined;
654
- /** Random seed for reproducible generation. */
655
- readonly seed: number | undefined;
656
- /** Maximum number of retries for failed requests. */
657
- readonly maxRetries: number;
658
- /** Additional HTTP headers sent with the request. */
659
- readonly headers: Record<string, string | undefined> | undefined;
660
- /** Additional provider-specific options. */
661
- readonly providerOptions: ProviderOptions | undefined;
662
- /** The output strategy type. */
663
- readonly output: 'object' | 'array' | 'enum' | 'no-schema';
664
- /** The JSON Schema used for object generation, if any. */
665
- readonly schema: Record<string, unknown> | undefined;
666
- /** Optional name of the schema. */
667
- readonly schemaName: string | undefined;
668
- /** Optional description of the schema. */
669
- readonly schemaDescription: string | undefined;
673
+ /** Unique identifier for this generation call, used to correlate events. */
674
+ readonly callId: string;
675
+ /** Identifies the operation type (e.g. `'ai.generateObject'` or `'ai.streamObject'`). */
676
+ readonly operationId: string;
677
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
678
+ readonly provider: string;
679
+ /** The specific model identifier (e.g., 'gpt-4o'). */
680
+ readonly modelId: string;
681
+ /** The system message(s) provided to the model. */
682
+ readonly system: Instructions | undefined;
683
+ /** The prompt string or array of messages if using the prompt option. */
684
+ readonly prompt: string | Array<ModelMessage> | undefined;
685
+ /** The messages array if using the messages option. */
686
+ readonly messages: Array<ModelMessage> | undefined;
687
+ /** Maximum number of tokens to generate. */
688
+ readonly maxOutputTokens: number | undefined;
689
+ /** Sampling temperature for generation. */
690
+ readonly temperature: number | undefined;
691
+ /** Top-p (nucleus) sampling parameter. */
692
+ readonly topP: number | undefined;
693
+ /** Top-k sampling parameter. */
694
+ readonly topK: number | undefined;
695
+ /** Presence penalty for generation. */
696
+ readonly presencePenalty: number | undefined;
697
+ /** Frequency penalty for generation. */
698
+ readonly frequencyPenalty: number | undefined;
699
+ /** Random seed for reproducible generation. */
700
+ readonly seed: number | undefined;
701
+ /** Maximum number of retries for failed requests. */
702
+ readonly maxRetries: number;
703
+ /** Additional HTTP headers sent with the request. */
704
+ readonly headers: Record<string, string | undefined> | undefined;
705
+ /** Additional provider-specific options. */
706
+ readonly providerOptions: ProviderOptions | undefined;
707
+ /** The output strategy type. */
708
+ readonly output: 'object' | 'array' | 'enum' | 'no-schema';
709
+ /** The JSON Schema used for object generation, if any. */
710
+ readonly schema: Record<string, unknown> | undefined;
711
+ /** Optional name of the schema. */
712
+ readonly schemaName: string | undefined;
713
+ /** Optional description of the schema. */
714
+ readonly schemaDescription: string | undefined;
670
715
  }
671
716
  /**
672
717
  * Event passed to the `onStepStart` callback of
@@ -678,20 +723,20 @@ interface GenerateObjectStartEvent {
678
723
  * @deprecated
679
724
  */
680
725
  interface GenerateObjectStepStartEvent {
681
- /** Unique identifier for this generation call, used to correlate events. */
682
- readonly callId: string;
683
- /** Zero-based index of the current step. Always `0` for object generation. */
684
- readonly stepNumber: 0;
685
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
686
- readonly provider: string;
687
- /** The specific model identifier (e.g., 'gpt-4o'). */
688
- readonly modelId: string;
689
- /** Additional provider-specific options. */
690
- readonly providerOptions: ProviderOptions | undefined;
691
- /** Additional HTTP headers sent with the request. */
692
- readonly headers: Record<string, string | undefined> | undefined;
693
- /** The prompt messages in provider format (for telemetry). */
694
- readonly promptMessages?: LanguageModelV4Prompt;
726
+ /** Unique identifier for this generation call, used to correlate events. */
727
+ readonly callId: string;
728
+ /** Zero-based index of the current step. Always `0` for object generation. */
729
+ readonly stepNumber: 0;
730
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
731
+ readonly provider: string;
732
+ /** The specific model identifier (e.g., 'gpt-4o'). */
733
+ readonly modelId: string;
734
+ /** Additional provider-specific options. */
735
+ readonly providerOptions: ProviderOptions | undefined;
736
+ /** Additional HTTP headers sent with the request. */
737
+ readonly headers: Record<string, string | undefined> | undefined;
738
+ /** The prompt messages in provider format (for telemetry). */
739
+ readonly promptMessages?: LanguageModelV4Prompt;
695
740
  }
696
741
  /**
697
742
  * Event passed to the `onStepEnd` callback of
@@ -703,32 +748,32 @@ interface GenerateObjectStepStartEvent {
703
748
  * @deprecated
704
749
  */
705
750
  interface GenerateObjectStepEndEvent {
706
- /** Unique identifier for this generation call, used to correlate events. */
707
- readonly callId: string;
708
- /** Zero-based index of the current step. Always `0` for object generation. */
709
- readonly stepNumber: 0;
710
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
711
- readonly provider: string;
712
- /** The specific model identifier (e.g., 'gpt-4o'). */
713
- readonly modelId: string;
714
- /** The unified reason why the generation finished. */
715
- readonly finishReason: FinishReason;
716
- /** The token usage of the generated response. */
717
- readonly usage: LanguageModelUsage;
718
- /** The raw text output from the model (before JSON parsing). */
719
- readonly objectText: string;
720
- /** The reasoning generated by the model, if any. */
721
- readonly reasoning: string | undefined;
722
- /** Warnings from the model provider (e.g. unsupported settings). */
723
- readonly warnings: CallWarning[] | undefined;
724
- /** Additional request information. */
725
- readonly request: Omit<LanguageModelRequestMetadata, 'messages'>;
726
- /** Additional response information. */
727
- readonly response: Omit<LanguageModelResponseMetadata, 'messages'>;
728
- /** Additional provider-specific metadata. */
729
- readonly providerMetadata: ProviderMetadata | undefined;
730
- /** Milliseconds from the start of the stream to the first chunk (streaming only). */
731
- readonly msToFirstChunk: number | undefined;
751
+ /** Unique identifier for this generation call, used to correlate events. */
752
+ readonly callId: string;
753
+ /** Zero-based index of the current step. Always `0` for object generation. */
754
+ readonly stepNumber: 0;
755
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
756
+ readonly provider: string;
757
+ /** The specific model identifier (e.g., 'gpt-4o'). */
758
+ readonly modelId: string;
759
+ /** The unified reason why the generation finished. */
760
+ readonly finishReason: FinishReason;
761
+ /** The token usage of the generated response. */
762
+ readonly usage: LanguageModelUsage;
763
+ /** The raw text output from the model (before JSON parsing). */
764
+ readonly objectText: string;
765
+ /** The reasoning generated by the model, if any. */
766
+ readonly reasoning: string | undefined;
767
+ /** Warnings from the model provider (e.g. unsupported settings). */
768
+ readonly warnings: CallWarning[] | undefined;
769
+ /** Additional request information. */
770
+ readonly request: Omit<LanguageModelRequestMetadata, 'messages'>;
771
+ /** Additional response information. */
772
+ readonly response: Omit<LanguageModelResponseMetadata, 'messages'>;
773
+ /** Additional provider-specific metadata. */
774
+ readonly providerMetadata: ProviderMetadata | undefined;
775
+ /** Milliseconds from the start of the stream to the first chunk (streaming only). */
776
+ readonly msToFirstChunk: number | undefined;
732
777
  }
733
778
  /**
734
779
  * Event passed to the `onFinish` callback of
@@ -741,44 +786,45 @@ interface GenerateObjectStepEndEvent {
741
786
  * @deprecated
742
787
  */
743
788
  interface GenerateObjectEndEvent<RESULT> {
744
- /** Unique identifier for this generation call, used to correlate events. */
745
- readonly callId: string;
746
- /**
747
- * The generated object (typed according to the schema).
748
- * Always defined for `generateObject`. May be `undefined` for `streamObject`
749
- * when parsing or validation fails.
750
- */
751
- readonly object: RESULT | undefined;
752
- /**
753
- * Error from parsing or schema validation, if any.
754
- * Always `undefined` for `generateObject` (which throws instead).
755
- */
756
- readonly error: unknown | undefined;
757
- /** The reasoning generated by the model, if any. */
758
- readonly reasoning: string | undefined;
759
- /** The unified reason why the generation finished. */
760
- readonly finishReason: FinishReason;
761
- /** The token usage of the generated response. */
762
- readonly usage: LanguageModelUsage;
763
- /** Warnings from the model provider (e.g. unsupported settings). */
764
- readonly warnings: CallWarning[] | undefined;
765
- /** Additional request information. */
766
- readonly request: Omit<LanguageModelRequestMetadata, 'messages'>;
767
- /** Additional response information. */
768
- readonly response: Omit<LanguageModelResponseMetadata, 'messages'>;
769
- /** Additional provider-specific metadata. */
770
- readonly providerMetadata: ProviderMetadata | undefined;
789
+ /** Unique identifier for this generation call, used to correlate events. */
790
+ readonly callId: string;
791
+ /**
792
+ * The generated object (typed according to the schema).
793
+ * Always defined for `generateObject`. May be `undefined` for `streamObject`
794
+ * when parsing or validation fails.
795
+ */
796
+ readonly object: RESULT | undefined;
797
+ /**
798
+ * Error from parsing or schema validation, if any.
799
+ * Always `undefined` for `generateObject` (which throws instead).
800
+ */
801
+ readonly error: unknown | undefined;
802
+ /** The reasoning generated by the model, if any. */
803
+ readonly reasoning: string | undefined;
804
+ /** The unified reason why the generation finished. */
805
+ readonly finishReason: FinishReason;
806
+ /** The token usage of the generated response. */
807
+ readonly usage: LanguageModelUsage;
808
+ /** Warnings from the model provider (e.g. unsupported settings). */
809
+ readonly warnings: CallWarning[] | undefined;
810
+ /** Additional request information. */
811
+ readonly request: Omit<LanguageModelRequestMetadata, 'messages'>;
812
+ /** Additional response information. */
813
+ readonly response: Omit<LanguageModelResponseMetadata, 'messages'>;
814
+ /** Additional provider-specific metadata. */
815
+ readonly providerMetadata: ProviderMetadata | undefined;
771
816
  }
772
-
817
+ //#endregion
818
+ //#region src/prompt/standardize-prompt.d.ts
773
819
  type StandardizedPrompt = {
774
- /**
775
- * Instructions.
776
- */
777
- instructions: Instructions | undefined;
778
- /**
779
- * Messages.
780
- */
781
- messages: ModelMessage[];
820
+ /**
821
+ * Instructions.
822
+ */
823
+ instructions: Instructions | undefined;
824
+ /**
825
+ * Messages.
826
+ */
827
+ messages: ModelMessage[];
782
828
  };
783
829
  /**
784
830
  * Converts a prompt input into a standardized prompt with validated model
@@ -791,13 +837,15 @@ type StandardizedPrompt = {
791
837
  * @returns The standardized prompt.
792
838
  * @throws {InvalidPromptError} When the prompt is invalid.
793
839
  */
794
- declare function standardizePrompt({ allowSystemInMessages, system, instructions, prompt, messages, }: Prompt): Promise<StandardizedPrompt>;
795
-
840
+ export declare function standardizePrompt({ allowSystemInMessages, system, instructions, prompt, messages }: Prompt): Promise<StandardizedPrompt>;
841
+ //#endregion
842
+ //#region src/util/callback.d.ts
796
843
  /**
797
844
  * A callback function that can be used with `notify`.
798
845
  */
799
846
  type Callback<EVENT> = (event: EVENT) => PromiseLike<void> | void;
800
-
847
+ //#endregion
848
+ //#region src/generate-text/active-tools.d.ts
801
849
  /**
802
850
  * Tool names that are enabled for a generation step.
803
851
  *
@@ -806,61 +854,59 @@ type Callback<EVENT> = (event: EVENT) => PromiseLike<void> | void;
806
854
  * tool set.
807
855
  */
808
856
  type ActiveTools<TOOLS extends ToolSet> = ReadonlyArray<keyof TOOLS & string> | undefined;
809
-
810
- type IncludedContext<CONTEXT extends Context | unknown | never> = {
811
- [KEY in keyof NoInfer<CONTEXT>]?: boolean;
812
- } | undefined;
813
- type IncludedToolsContext<TOOLS extends ToolSet> = {
814
- [TOOL_NAME in keyof NoInfer<InferToolSetContext<TOOLS>>]?: IncludedContext<NoInfer<InferToolSetContext<TOOLS>[TOOL_NAME]>>;
815
- } | undefined;
857
+ //#endregion
858
+ //#region src/telemetry/telemetry-options.d.ts
859
+ type IncludedContext<CONTEXT extends Context | unknown | never> = { [KEY in keyof NoInfer<CONTEXT>]?: boolean; } | undefined;
860
+ type IncludedToolsContext<TOOLS extends ToolSet> = { [TOOL_NAME in keyof NoInfer<InferToolSetContext<TOOLS>>]?: IncludedContext<NoInfer<InferToolSetContext<TOOLS>[TOOL_NAME]>>; } | undefined;
816
861
  /**
817
862
  * Telemetry configuration.
818
863
  */
819
864
  type TelemetryOptions<RUNTIME_CONTEXT extends Context = Context, TOOLS extends ToolSet = ToolSet> = {
820
- /**
821
- * Enable or disable telemetry. Enabled by default when a telemetry
822
- * integration is registered. Set to `false` to opt out.
823
- */
824
- isEnabled?: boolean;
825
- /**
826
- * Enable or disable input recording. Enabled by default.
827
- *
828
- * You might want to disable input recording to avoid recording sensitive
829
- * information, to reduce data transfers, or to increase performance.
830
- */
831
- recordInputs?: boolean;
832
- /**
833
- * Enable or disable output recording. Enabled by default.
834
- *
835
- * You might want to disable output recording to avoid recording sensitive
836
- * information, to reduce data transfers, or to increase performance.
837
- */
838
- recordOutputs?: boolean;
839
- /**
840
- * Identifier for this function. Used to group telemetry data by function.
841
- */
842
- functionId?: string;
843
- /**
844
- * Top-level runtime context properties that should be included in telemetry.
845
- * Runtime context properties are excluded unless they are explicitly set to `true`.
846
- */
847
- includeRuntimeContext?: IncludedContext<RUNTIME_CONTEXT>;
848
- /**
849
- * Top-level tool context properties that should be included in telemetry,
850
- * configured per tool.
851
- *
852
- * Tool context properties are excluded unless they are explicitly set to `true`.
853
- */
854
- includeToolsContext?: IncludedToolsContext<TOOLS>;
855
- /**
856
- * Per-call telemetry integrations that receive lifecycle events during generation.
857
- *
858
- * When provided, these integrations will take precedence over the globally registered
859
- * integrations for this call.
860
- */
861
- integrations?: Arrayable<Telemetry>;
862
- };
863
-
865
+ /**
866
+ * Enable or disable telemetry. Enabled by default when a telemetry
867
+ * integration is registered. Set to `false` to opt out.
868
+ */
869
+ isEnabled?: boolean;
870
+ /**
871
+ * Enable or disable input recording. Enabled by default.
872
+ *
873
+ * You might want to disable input recording to avoid recording sensitive
874
+ * information, to reduce data transfers, or to increase performance.
875
+ */
876
+ recordInputs?: boolean;
877
+ /**
878
+ * Enable or disable output recording. Enabled by default.
879
+ *
880
+ * You might want to disable output recording to avoid recording sensitive
881
+ * information, to reduce data transfers, or to increase performance.
882
+ */
883
+ recordOutputs?: boolean;
884
+ /**
885
+ * Identifier for this function. Used to group telemetry data by function.
886
+ */
887
+ functionId?: string;
888
+ /**
889
+ * Top-level runtime context properties that should be included in telemetry.
890
+ * Runtime context properties are excluded unless they are explicitly set to `true`.
891
+ */
892
+ includeRuntimeContext?: IncludedContext<RUNTIME_CONTEXT>;
893
+ /**
894
+ * Top-level tool context properties that should be included in telemetry,
895
+ * configured per tool.
896
+ *
897
+ * Tool context properties are excluded unless they are explicitly set to `true`.
898
+ */
899
+ includeToolsContext?: IncludedToolsContext<TOOLS>;
900
+ /**
901
+ * Per-call telemetry integrations that receive lifecycle events during generation.
902
+ *
903
+ * When provided, these integrations will take precedence over the globally registered
904
+ * integrations for this call.
905
+ */
906
+ integrations?: Arrayable<Telemetry>;
907
+ };
908
+ //#endregion
909
+ //#region src/util/download/download.d.ts
864
910
  /**
865
911
  * Download a file from a URL.
866
912
  *
@@ -871,15 +917,16 @@ type TelemetryOptions<RUNTIME_CONTEXT extends Context = Context, TOOLS extends T
871
917
  *
872
918
  * @throws DownloadError if the download fails or exceeds maxBytes.
873
919
  */
874
- declare const download: ({ url, maxBytes, abortSignal, }: {
875
- url: URL;
876
- maxBytes?: number;
877
- abortSignal?: AbortSignal;
920
+ declare const download$1: ({ url, maxBytes, abortSignal }: {
921
+ url: URL;
922
+ maxBytes?: number;
923
+ abortSignal?: AbortSignal;
878
924
  }) => Promise<{
879
- data: Uint8Array<ArrayBufferLike>;
880
- mediaType: string | undefined;
925
+ data: Uint8Array<ArrayBufferLike>;
926
+ mediaType: string | undefined;
881
927
  }>;
882
-
928
+ //#endregion
929
+ //#region src/util/download/download-function.d.ts
883
930
  /**
884
931
  * Experimental. Can change in patch versions without warning.
885
932
  *
@@ -898,76 +945,79 @@ declare const download: ({ url, maxBytes, abortSignal, }: {
898
945
  * For each object, the data should be null if the URL should be passed through as is.
899
946
  */
900
947
  type DownloadFunction = (options: Array<{
901
- url: URL;
902
- isUrlSupportedByModel: boolean;
948
+ url: URL;
949
+ isUrlSupportedByModel: boolean;
903
950
  }>) => PromiseLike<Array<{
904
- data: Uint8Array;
905
- mediaType: string | undefined;
951
+ data: Uint8Array;
952
+ mediaType: string | undefined;
906
953
  } | null>>;
907
954
  /**
908
955
  * Default download function.
909
956
  * Downloads the file if it is not supported by the model.
910
957
  */
911
- declare const createDefaultDownloadFunction: (download?: typeof download, abortSignal?: AbortSignal) => DownloadFunction;
912
-
958
+ export declare const createDefaultDownloadFunction: (download?: typeof download$1, abortSignal?: AbortSignal) => DownloadFunction;
959
+ //#endregion
960
+ //#region src/generate-text/generated-file.d.ts
913
961
  /**
914
962
  * A generated file.
915
963
  */
916
964
  interface GeneratedFile {
917
- /**
918
- * File as a base64 encoded string.
919
- */
920
- readonly base64: string;
921
- /**
922
- * File as a Uint8Array.
923
- */
924
- readonly uint8Array: Uint8Array;
925
- /**
926
- * The IANA media type of the file.
927
- *
928
- * @see https://www.iana.org/assignments/media-types/media-types.xhtml
929
- */
930
- readonly mediaType: string;
931
- /**
932
- * Provider-specific metadata for this file.
933
- */
934
- readonly providerMetadata?: Record<string, JSONObject>;
965
+ /**
966
+ * File as a base64 encoded string.
967
+ */
968
+ readonly base64: string;
969
+ /**
970
+ * File as a Uint8Array.
971
+ */
972
+ readonly uint8Array: Uint8Array;
973
+ /**
974
+ * The IANA media type of the file.
975
+ *
976
+ * @see https://www.iana.org/assignments/media-types/media-types.xhtml
977
+ */
978
+ readonly mediaType: string;
979
+ /**
980
+ * Provider-specific metadata for this file.
981
+ */
982
+ readonly providerMetadata?: Record<string, JSONObject>;
935
983
  }
936
-
984
+ //#endregion
985
+ //#region src/generate-text/reasoning-output.d.ts
937
986
  /**
938
987
  * Reasoning output of a text generation. It contains a reasoning.
939
988
  */
940
989
  interface ReasoningOutput {
941
- type: 'reasoning';
942
- /**
943
- * The reasoning text.
944
- */
945
- text: string;
946
- /**
947
- * Additional provider-specific metadata. They are passed through
948
- * to the provider from the AI SDK and enable provider-specific
949
- * functionality that can be fully encapsulated in the provider.
950
- */
951
- providerMetadata?: ProviderMetadata;
990
+ type: 'reasoning';
991
+ /**
992
+ * The reasoning text.
993
+ */
994
+ text: string;
995
+ /**
996
+ * Additional provider-specific metadata. They are passed through
997
+ * to the provider from the AI SDK and enable provider-specific
998
+ * functionality that can be fully encapsulated in the provider.
999
+ */
1000
+ providerMetadata?: ProviderMetadata;
952
1001
  }
953
1002
  /**
954
1003
  * Reasoning file output of a text generation.
955
1004
  * It contains a file generated as part of reasoning.
956
1005
  */
957
1006
  interface ReasoningFileOutput {
958
- type: 'reasoning-file';
959
- /**
960
- * The generated file.
961
- */
962
- file: GeneratedFile;
963
- /**
964
- * Additional provider-specific metadata. They are passed through
965
- * to the provider from the AI SDK and enable provider-specific
966
- * functionality that can be fully encapsulated in the provider.
967
- */
968
- providerMetadata?: ProviderMetadata;
1007
+ type: 'reasoning-file';
1008
+ /**
1009
+ * The generated file.
1010
+ */
1011
+ file: GeneratedFile;
1012
+ /**
1013
+ * Additional provider-specific metadata. They are passed through
1014
+ * to the provider from the AI SDK and enable provider-specific
1015
+ * functionality that can be fully encapsulated in the provider.
1016
+ */
1017
+ providerMetadata?: ProviderMetadata;
969
1018
  }
970
-
1019
+ //#endregion
1020
+ //#region src/util/value-of.d.ts
971
1021
  /**
972
1022
  * Create a union of the given object's values, and optionally specify which keys to get the values from.
973
1023
  *
@@ -1009,499 +1059,501 @@ interface ReasoningFileOutput {
1009
1059
  * @see https://github.com/sindresorhus/type-fest/blob/main/source/value-of.d.ts
1010
1060
  */
1011
1061
  type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType> = ObjectType[ValueType];
1012
-
1062
+ //#endregion
1063
+ //#region src/generate-text/tool-call.d.ts
1013
1064
  type BaseToolCall = {
1014
- type: 'tool-call';
1015
- toolCallId: string;
1016
- providerExecuted?: boolean;
1017
- providerMetadata?: ProviderMetadata;
1018
- toolMetadata?: JSONObject;
1065
+ type: 'tool-call';
1066
+ toolCallId: string;
1067
+ providerExecuted?: boolean;
1068
+ providerMetadata?: ProviderMetadata;
1069
+ toolMetadata?: JSONObject;
1019
1070
  };
1020
1071
  /**
1021
1072
  * A tool call whose `toolName` maps to a tool in the declared tool set,
1022
1073
  * with an `input` type inferred from that tool's input schema.
1023
1074
  */
1024
- type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
1025
- [NAME in keyof TOOLS]: BaseToolCall & {
1026
- toolName: NAME & string;
1027
- input: InferToolInput<TOOLS[NAME]>;
1028
- dynamic?: false | undefined;
1029
- invalid?: false | undefined;
1030
- error?: never;
1031
- title?: string;
1032
- };
1033
- }>;
1075
+ type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: BaseToolCall & {
1076
+ toolName: NAME & string;
1077
+ input: InferToolInput<TOOLS[NAME]>;
1078
+ dynamic?: false | undefined;
1079
+ invalid?: false | undefined;
1080
+ error?: never;
1081
+ title?: string;
1082
+ }; }>;
1034
1083
  /**
1035
1084
  * A tool call whose `toolName` is only known at runtime, such as an invalid
1036
1085
  * or otherwise untyped call that cannot be matched to the declared tool set.
1037
1086
  */
1038
1087
  type DynamicToolCall = BaseToolCall & {
1039
- toolName: string;
1040
- input: unknown;
1041
- dynamic: true;
1042
- title?: string;
1043
- /**
1044
- * True if this is caused by an unparsable tool call or
1045
- * a tool that does not exist.
1046
- */
1047
- invalid?: boolean;
1048
- /**
1049
- * The error that caused the tool call to be invalid.
1050
- */
1051
- error?: unknown;
1088
+ toolName: string;
1089
+ input: unknown;
1090
+ dynamic: true;
1091
+ title?: string;
1092
+ /**
1093
+ * True if this is caused by an unparsable tool call or
1094
+ * a tool that does not exist.
1095
+ */
1096
+ invalid?: boolean;
1097
+ /**
1098
+ * The error that caused the tool call to be invalid.
1099
+ */
1100
+ error?: unknown;
1052
1101
  };
1053
1102
  /**
1054
1103
  * A tool call returned by text generation, either statically typed from the
1055
1104
  * declared tool set or dynamically typed when the tool cannot be inferred.
1056
1105
  */
1057
1106
  type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
1058
-
1107
+ //#endregion
1108
+ //#region src/generate-text/tool-approval-request-output.d.ts
1059
1109
  /**
1060
1110
  * Output part that indicates that a tool approval request has been made.
1061
1111
  *
1062
1112
  * The tool approval request can be approved or denied in the next tool message.
1063
1113
  */
1064
1114
  type ToolApprovalRequestOutput<TOOLS extends ToolSet> = {
1065
- type: 'tool-approval-request';
1066
- /**
1067
- * ID of the tool approval request.
1068
- */
1069
- approvalId: string;
1070
- /**
1071
- * Tool call that the approval request is for.
1072
- */
1073
- toolCall: TypedToolCall<TOOLS>;
1074
- /**
1075
- * Reason why the tool call requires approval.
1076
- */
1077
- reason?: string;
1078
- /**
1079
- * Flag indicating whether the tool was automatically approved or denied.
1080
- *
1081
- * @default false
1082
- */
1083
- isAutomatic?: boolean;
1084
- /**
1085
- * HMAC-SHA256 signature binding this approval request to its tool call.
1086
- */
1087
- signature?: string;
1088
- };
1089
-
1115
+ type: 'tool-approval-request';
1116
+ /**
1117
+ * ID of the tool approval request.
1118
+ */
1119
+ approvalId: string;
1120
+ /**
1121
+ * Tool call that the approval request is for.
1122
+ */
1123
+ toolCall: TypedToolCall<TOOLS>;
1124
+ /**
1125
+ * Reason why the tool call requires approval.
1126
+ */
1127
+ reason?: string;
1128
+ /**
1129
+ * Flag indicating whether the tool was automatically approved or denied.
1130
+ *
1131
+ * @default false
1132
+ */
1133
+ isAutomatic?: boolean;
1134
+ /**
1135
+ * HMAC-SHA256 signature binding this approval request to its tool call.
1136
+ */
1137
+ signature?: string;
1138
+ };
1139
+ //#endregion
1140
+ //#region src/generate-text/tool-approval-response-output.d.ts
1090
1141
  /**
1091
1142
  * Output part that indicates that a tool approval response is available.
1092
1143
  */
1093
1144
  type ToolApprovalResponseOutput<TOOLS extends ToolSet> = {
1094
- type: 'tool-approval-response';
1095
- /**
1096
- * ID of the tool approval.
1097
- */
1098
- approvalId: string;
1099
- /**
1100
- * Tool call that the approval response is for.
1101
- */
1102
- toolCall: TypedToolCall<TOOLS>;
1103
- /**
1104
- * Flag indicating whether the approval was granted or denied.
1105
- */
1106
- approved: boolean;
1107
- /**
1108
- * Optional reason for the approval or denial.
1109
- */
1110
- reason?: string;
1111
- /**
1112
- * Flag indicating whether the tool call is provider-executed.
1113
- * Only provider-executed tool approval responses should be sent to the model.
1114
- */
1115
- providerExecuted?: boolean;
1116
- };
1117
-
1118
- type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
1119
- [NAME in keyof TOOLS]: {
1120
- type: 'tool-error';
1121
- toolCallId: string;
1122
- toolName: NAME & string;
1123
- input: InferToolInput<TOOLS[NAME]>;
1124
- error: unknown;
1125
- providerExecuted?: boolean;
1126
- providerMetadata?: ProviderMetadata;
1127
- toolMetadata?: JSONObject;
1128
- dynamic?: false | undefined;
1129
- title?: string;
1130
- };
1131
- }>;
1145
+ type: 'tool-approval-response';
1146
+ /**
1147
+ * ID of the tool approval.
1148
+ */
1149
+ approvalId: string;
1150
+ /**
1151
+ * Tool call that the approval response is for.
1152
+ */
1153
+ toolCall: TypedToolCall<TOOLS>;
1154
+ /**
1155
+ * Flag indicating whether the approval was granted or denied.
1156
+ */
1157
+ approved: boolean;
1158
+ /**
1159
+ * Optional reason for the approval or denial.
1160
+ */
1161
+ reason?: string;
1162
+ /**
1163
+ * Flag indicating whether the tool call is provider-executed.
1164
+ * Only provider-executed tool approval responses should be sent to the model.
1165
+ */
1166
+ providerExecuted?: boolean;
1167
+ };
1168
+ //#endregion
1169
+ //#region src/generate-text/tool-error.d.ts
1170
+ type StaticToolError<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: {
1171
+ type: 'tool-error';
1172
+ toolCallId: string;
1173
+ toolName: NAME & string;
1174
+ input: InferToolInput<TOOLS[NAME]>;
1175
+ error: unknown;
1176
+ providerExecuted?: boolean;
1177
+ providerMetadata?: ProviderMetadata;
1178
+ toolMetadata?: JSONObject;
1179
+ dynamic?: false | undefined;
1180
+ title?: string;
1181
+ }; }>;
1132
1182
  type DynamicToolError = {
1133
- type: 'tool-error';
1134
- toolCallId: string;
1135
- toolName: string;
1136
- input: unknown;
1137
- error: unknown;
1138
- providerExecuted?: boolean;
1139
- providerMetadata?: ProviderMetadata;
1140
- toolMetadata?: JSONObject;
1141
- dynamic: true;
1142
- title?: string;
1183
+ type: 'tool-error';
1184
+ toolCallId: string;
1185
+ toolName: string;
1186
+ input: unknown;
1187
+ error: unknown;
1188
+ providerExecuted?: boolean;
1189
+ providerMetadata?: ProviderMetadata;
1190
+ toolMetadata?: JSONObject;
1191
+ dynamic: true;
1192
+ title?: string;
1143
1193
  };
1144
1194
  type TypedToolError<TOOLS extends ToolSet> = StaticToolError<TOOLS> | DynamicToolError;
1145
-
1146
- type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
1147
- [NAME in keyof TOOLS]: {
1148
- type: 'tool-result';
1149
- toolCallId: string;
1150
- toolName: NAME & string;
1151
- input: InferToolInput<TOOLS[NAME]>;
1152
- output: InferToolOutput<TOOLS[NAME]>;
1153
- providerExecuted?: boolean;
1154
- providerMetadata?: ProviderMetadata;
1155
- toolMetadata?: JSONObject;
1156
- dynamic?: false | undefined;
1157
- preliminary?: boolean;
1158
- title?: string;
1159
- };
1160
- }>;
1195
+ //#endregion
1196
+ //#region src/generate-text/tool-result.d.ts
1197
+ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: {
1198
+ type: 'tool-result';
1199
+ toolCallId: string;
1200
+ toolName: NAME & string;
1201
+ input: InferToolInput<TOOLS[NAME]>;
1202
+ output: InferToolOutput<TOOLS[NAME]>;
1203
+ providerExecuted?: boolean;
1204
+ providerMetadata?: ProviderMetadata;
1205
+ toolMetadata?: JSONObject;
1206
+ dynamic?: false | undefined;
1207
+ preliminary?: boolean;
1208
+ title?: string;
1209
+ }; }>;
1161
1210
  type DynamicToolResult = {
1162
- type: 'tool-result';
1163
- toolCallId: string;
1164
- toolName: string;
1165
- input: unknown;
1166
- output: unknown;
1167
- providerExecuted?: boolean;
1168
- providerMetadata?: ProviderMetadata;
1169
- toolMetadata?: JSONObject;
1170
- dynamic: true;
1171
- preliminary?: boolean;
1172
- title?: string;
1211
+ type: 'tool-result';
1212
+ toolCallId: string;
1213
+ toolName: string;
1214
+ input: unknown;
1215
+ output: unknown;
1216
+ providerExecuted?: boolean;
1217
+ providerMetadata?: ProviderMetadata;
1218
+ toolMetadata?: JSONObject;
1219
+ dynamic: true;
1220
+ preliminary?: boolean;
1221
+ title?: string;
1173
1222
  };
1174
1223
  type TypedToolResult<TOOLS extends ToolSet> = StaticToolResult<TOOLS> | DynamicToolResult;
1175
-
1224
+ //#endregion
1225
+ //#region src/generate-text/content-part.d.ts
1176
1226
  type ContentPart<TOOLS extends ToolSet> = {
1177
- type: 'text';
1178
- text: string;
1179
- providerMetadata?: ProviderMetadata;
1227
+ type: 'text';
1228
+ text: string;
1229
+ providerMetadata?: ProviderMetadata;
1180
1230
  } | {
1181
- type: 'custom';
1182
- kind: `${string}.${string}`;
1183
- providerMetadata?: ProviderMetadata;
1231
+ type: 'custom';
1232
+ kind: `${string}.${string}`;
1233
+ providerMetadata?: ProviderMetadata;
1184
1234
  } | ReasoningOutput | ReasoningFileOutput | ({
1185
- type: 'source';
1235
+ type: 'source';
1186
1236
  } & Source) | {
1187
- type: 'file';
1188
- file: GeneratedFile;
1189
- providerMetadata?: ProviderMetadata;
1237
+ type: 'file';
1238
+ file: GeneratedFile;
1239
+ providerMetadata?: ProviderMetadata;
1190
1240
  } | ({
1191
- type: 'tool-call';
1241
+ type: 'tool-call';
1192
1242
  } & TypedToolCall<TOOLS> & {
1193
- providerMetadata?: ProviderMetadata;
1243
+ providerMetadata?: ProviderMetadata;
1194
1244
  }) | ({
1195
- type: 'tool-result';
1245
+ type: 'tool-result';
1196
1246
  } & TypedToolResult<TOOLS> & {
1197
- providerMetadata?: ProviderMetadata;
1247
+ providerMetadata?: ProviderMetadata;
1198
1248
  }) | ({
1199
- type: 'tool-error';
1249
+ type: 'tool-error';
1200
1250
  } & TypedToolError<TOOLS> & {
1201
- providerMetadata?: ProviderMetadata;
1251
+ providerMetadata?: ProviderMetadata;
1202
1252
  }) | ToolApprovalRequestOutput<TOOLS> | ToolApprovalResponseOutput<TOOLS>;
1203
-
1253
+ //#endregion
1254
+ //#region src/generate-text/step-result.d.ts
1204
1255
  /**
1205
1256
  * Timing statistics for the gaps between generated output chunks.
1206
1257
  */
1207
1258
  type OutputChunkTimingStats = {
1208
- /** Shortest observed time between output chunks in milliseconds. */
1209
- readonly min: number;
1210
- /** 10th percentile time between output chunks in milliseconds. */
1211
- readonly p10: number;
1212
- /** Median time between output chunks in milliseconds. */
1213
- readonly median: number;
1214
- /** Average time between output chunks in milliseconds. */
1215
- readonly avg: number;
1216
- /** 90th percentile time between output chunks in milliseconds. */
1217
- readonly p90: number;
1218
- /** Longest observed time between output chunks in milliseconds. */
1219
- readonly max: number;
1259
+ /** Shortest observed time between output chunks in milliseconds. */
1260
+ readonly min: number;
1261
+ /** 10th percentile time between output chunks in milliseconds. */
1262
+ readonly p10: number;
1263
+ /** Median time between output chunks in milliseconds. */
1264
+ readonly median: number;
1265
+ /** Average time between output chunks in milliseconds. */
1266
+ readonly avg: number;
1267
+ /** 90th percentile time between output chunks in milliseconds. */
1268
+ readonly p90: number;
1269
+ /** Longest observed time between output chunks in milliseconds. */
1270
+ readonly max: number;
1220
1271
  };
1221
1272
  /**
1222
1273
  * Performance metrics for a single step in the generation process.
1223
- */
1224
- type StepResultPerformance = {
1225
- /**
1226
- * Effective number of output tokens per second over the full language model
1227
- * response.
1228
- *
1229
- * Calculated as `outputTokens / requestSeconds`.
1230
- */
1231
- readonly effectiveOutputTokensPerSecond: number;
1232
- /**
1233
- * Number of output tokens per second after the first generated output chunk
1234
- * was received.
1235
- *
1236
- * Only available for streaming steps.
1237
- *
1238
- * Calculated as `outputTokens / outputStreamSeconds`.
1239
- */
1240
- readonly outputTokensPerSecond: number | undefined;
1241
- /**
1242
- * Number of input tokens processed per second before the first generated
1243
- * output chunk was received.
1244
- *
1245
- * Only available for streaming steps.
1246
- *
1247
- * Calculated as `inputTokens / ttftSeconds`.
1248
- */
1249
- readonly inputTokensPerSecond: number | undefined;
1250
- /**
1251
- * Effective number of input and output tokens per second over the full
1252
- * language model response.
1253
- *
1254
- * Calculated as `(inputTokens + outputTokens) / requestSeconds`.
1255
- */
1256
- readonly effectiveTotalTokensPerSecond: number;
1257
- /**
1258
- * Total time spent on the step in milliseconds.
1259
- */
1260
- readonly stepTimeMs: number;
1261
- /**
1262
- * Time spent waiting for the language model response in milliseconds.
1263
- */
1264
- readonly responseTimeMs: number;
1265
- /**
1266
- * Time spent executing each client-side tool call in milliseconds, keyed by
1267
- * tool call ID.
1268
- */
1269
- readonly toolExecutionMs: Readonly<Record<string, number>>;
1270
- /**
1271
- * Time until the first generated output chunk was received in milliseconds.
1272
- *
1273
- * This includes text deltas, reasoning deltas, generated files, reasoning
1274
- * files, tool input deltas, and tool calls.
1275
- *
1276
- * Only available for streaming steps.
1277
- */
1278
- readonly timeToFirstOutputMs: number | undefined;
1279
- /**
1280
- * Timing statistics for the gaps between generated output chunks in
1281
- * milliseconds.
1282
- *
1283
- * Only available for streaming steps with at least two generated output
1284
- * chunks.
1285
- */
1286
- readonly timeBetweenOutputChunksMs?: OutputChunkTimingStats;
1287
- };
1288
- /**
1289
- * The result of a single step in the generation process.
1290
- */
1291
- type StepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context = Context> = {
1292
- /**
1293
- * Unique identifier for the generation call this step belongs to.
1294
- */
1295
- readonly callId: string;
1296
- /**
1297
- * Zero-based index of this step.
1298
- */
1299
- readonly stepNumber: number;
1300
- /**
1301
- * Information about the model that produced this step.
1302
- */
1303
- readonly model: {
1304
- /** The provider of the model. */
1305
- readonly provider: string;
1306
- /** The ID of the model. */
1307
- readonly modelId: string;
1308
- };
1309
- /**
1310
- * Tool context.
1311
- */
1312
- readonly toolsContext: InferToolSetContext<TOOLS>;
1313
- /**
1314
- * The runtime context that was used as input for the step.
1315
- */
1316
- readonly runtimeContext: RUNTIME_CONTEXT;
1317
- /**
1318
- * The content that was generated in the last step.
1319
- */
1320
- readonly content: Array<ContentPart<TOOLS>>;
1321
- /**
1322
- * The concatenation of all text parts generated in this step.
1323
- * It is an empty string if the step contains no text parts.
1324
- */
1325
- readonly text: string;
1326
- /**
1327
- * The reasoning that was generated during the generation.
1328
- */
1329
- readonly reasoning: Array<ReasoningPart | ReasoningFilePart>;
1330
- /**
1331
- * The reasoning text that was generated during the generation.
1332
- *
1333
- * It is a concatenation of all reasoning parts (but excluding reasoning file parts).
1334
- * Can be undefined if the model has only generated text.
1335
- */
1336
- readonly reasoningText: string | undefined;
1337
- /**
1338
- * The files that were generated during the generation.
1339
- */
1340
- readonly files: Array<GeneratedFile>;
1341
- /**
1342
- * The sources that were used to generate the text.
1343
- */
1344
- readonly sources: Array<Source>;
1345
- /**
1346
- * The tool calls that were made during the generation.
1347
- */
1348
- readonly toolCalls: Array<TypedToolCall<TOOLS>>;
1349
- /**
1350
- * The static tool calls that were made in the last step.
1351
- */
1352
- readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
1353
- /**
1354
- * The dynamic tool calls that were made in the last step.
1355
- */
1356
- readonly dynamicToolCalls: Array<DynamicToolCall>;
1357
- /**
1358
- * The results of the tool calls.
1359
- */
1360
- readonly toolResults: Array<TypedToolResult<TOOLS>>;
1361
- /**
1362
- * The static tool results that were made in the last step.
1363
- */
1364
- readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
1365
- /**
1366
- * The dynamic tool results that were made in the last step.
1367
- */
1368
- readonly dynamicToolResults: Array<DynamicToolResult>;
1369
- /**
1370
- * The unified reason why the generation finished.
1371
- */
1372
- readonly finishReason: FinishReason;
1373
- /**
1374
- * The raw reason why the generation finished (from the provider).
1375
- */
1376
- readonly rawFinishReason: string | undefined;
1377
- /**
1378
- * The token usage of the generated text.
1379
- */
1380
- readonly usage: LanguageModelUsage;
1381
- /**
1382
- * Performance metrics for the step.
1383
- */
1384
- readonly performance: StepResultPerformance;
1385
- /**
1386
- * Warnings from the model provider (e.g. unsupported settings).
1387
- */
1388
- readonly warnings: CallWarning[] | undefined;
1389
- /**
1390
- * Additional request information.
1391
- */
1392
- readonly request: LanguageModelRequestMetadata;
1393
- /**
1394
- * Additional response information.
1395
- */
1396
- readonly response: LanguageModelResponseMetadata;
1397
- /**
1398
- * Additional provider-specific metadata. They are passed through
1399
- * from the provider to the AI SDK and enable provider-specific
1400
- * results that can be fully encapsulated in the provider.
1401
- */
1402
- readonly providerMetadata: ProviderMetadata | undefined;
1403
- };
1404
- declare class DefaultStepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context = Context> implements StepResult<TOOLS, RUNTIME_CONTEXT> {
1405
- readonly callId: StepResult<TOOLS, RUNTIME_CONTEXT>['callId'];
1406
- readonly stepNumber: StepResult<TOOLS, RUNTIME_CONTEXT>['stepNumber'];
1407
- readonly model: StepResult<TOOLS, RUNTIME_CONTEXT>['model'];
1408
- readonly toolsContext: StepResult<TOOLS, RUNTIME_CONTEXT>['toolsContext'];
1409
- readonly runtimeContext: StepResult<TOOLS, RUNTIME_CONTEXT>['runtimeContext'];
1410
- readonly content: StepResult<TOOLS, RUNTIME_CONTEXT>['content'];
1411
- readonly finishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['finishReason'];
1412
- readonly rawFinishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['rawFinishReason'];
1413
- readonly usage: StepResult<TOOLS, RUNTIME_CONTEXT>['usage'];
1414
- readonly performance: StepResult<TOOLS, RUNTIME_CONTEXT>['performance'];
1415
- readonly warnings: StepResult<TOOLS, RUNTIME_CONTEXT>['warnings'];
1416
- readonly request: StepResult<TOOLS, RUNTIME_CONTEXT>['request'];
1417
- readonly response: StepResult<TOOLS, RUNTIME_CONTEXT>['response'];
1418
- readonly providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
1419
- constructor({ callId, stepNumber, provider, modelId, runtimeContext, toolsContext, content, finishReason, rawFinishReason, usage, performance, warnings, request, response, providerMetadata, }: {
1420
- callId: StepResult<TOOLS, RUNTIME_CONTEXT>['callId'];
1421
- stepNumber: StepResult<TOOLS, RUNTIME_CONTEXT>['stepNumber'];
1422
- provider: StepResult<TOOLS, RUNTIME_CONTEXT>['model']['provider'];
1423
- modelId: StepResult<TOOLS, RUNTIME_CONTEXT>['model']['modelId'];
1424
- runtimeContext: StepResult<TOOLS, RUNTIME_CONTEXT>['runtimeContext'];
1425
- toolsContext: StepResult<TOOLS, RUNTIME_CONTEXT>['toolsContext'];
1426
- content: StepResult<TOOLS, RUNTIME_CONTEXT>['content'];
1427
- finishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['finishReason'];
1428
- rawFinishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['rawFinishReason'];
1429
- usage: StepResult<TOOLS, RUNTIME_CONTEXT>['usage'];
1430
- performance: StepResult<TOOLS, RUNTIME_CONTEXT>['performance'];
1431
- warnings: StepResult<TOOLS, RUNTIME_CONTEXT>['warnings'];
1432
- request: StepResult<TOOLS, RUNTIME_CONTEXT>['request'];
1433
- response: StepResult<TOOLS, RUNTIME_CONTEXT>['response'];
1434
- providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
1435
- });
1436
- get text(): string;
1437
- get reasoning(): Array<ReasoningPart | ReasoningFilePart>;
1438
- get reasoningText(): string | undefined;
1439
- get files(): GeneratedFile[];
1440
- get sources(): (({
1441
- type: "source";
1442
- } & {
1443
- type: "source";
1444
- sourceType: "url";
1445
- id: string;
1446
- url: string;
1447
- title?: string;
1448
- providerMetadata?: _ai_sdk_provider.SharedV4ProviderMetadata;
1449
- }) | ({
1450
- type: "source";
1451
- } & {
1452
- type: "source";
1453
- sourceType: "document";
1454
- id: string;
1455
- mediaType: string;
1456
- title: string;
1457
- filename?: string;
1458
- providerMetadata?: _ai_sdk_provider.SharedV4ProviderMetadata;
1459
- }))[];
1460
- get toolCalls(): (({
1461
- type: "tool-call";
1462
- } & {
1463
- type: "tool-call";
1464
- toolCallId: string;
1465
- providerExecuted?: boolean;
1466
- providerMetadata?: ProviderMetadata;
1467
- toolMetadata?: _ai_sdk_provider.JSONObject;
1468
- } & {
1469
- toolName: string;
1470
- input: unknown;
1471
- dynamic: true;
1472
- title?: string;
1473
- invalid?: boolean;
1474
- error?: unknown;
1475
- } & {
1476
- providerMetadata?: ProviderMetadata;
1477
- }) | ({
1478
- type: "tool-call";
1479
- } & StaticToolCall<TOOLS> & {
1480
- providerMetadata?: ProviderMetadata;
1481
- }))[];
1482
- get staticToolCalls(): StaticToolCall<TOOLS>[];
1483
- get dynamicToolCalls(): DynamicToolCall[];
1484
- get toolResults(): (({
1485
- type: "tool-result";
1486
- } & DynamicToolResult & {
1487
- providerMetadata?: ProviderMetadata;
1488
- }) | ({
1489
- type: "tool-result";
1490
- } & StaticToolResult<TOOLS> & {
1491
- providerMetadata?: ProviderMetadata;
1492
- }))[];
1493
- get staticToolResults(): StaticToolResult<TOOLS>[];
1494
- get dynamicToolResults(): DynamicToolResult[];
1274
+ */
1275
+ type StepResultPerformance = {
1276
+ /**
1277
+ * Effective number of output tokens per second over the full language model
1278
+ * response.
1279
+ *
1280
+ * Calculated as `outputTokens / requestSeconds`.
1281
+ */
1282
+ readonly effectiveOutputTokensPerSecond: number;
1283
+ /**
1284
+ * Number of output tokens per second after the first generated output chunk
1285
+ * was received.
1286
+ *
1287
+ * Only available for streaming steps.
1288
+ *
1289
+ * Calculated as `outputTokens / outputStreamSeconds`.
1290
+ */
1291
+ readonly outputTokensPerSecond: number | undefined;
1292
+ /**
1293
+ * Number of input tokens processed per second before the first generated
1294
+ * output chunk was received.
1295
+ *
1296
+ * Only available for streaming steps.
1297
+ *
1298
+ * Calculated as `inputTokens / ttftSeconds`.
1299
+ */
1300
+ readonly inputTokensPerSecond: number | undefined;
1301
+ /**
1302
+ * Effective number of input and output tokens per second over the full
1303
+ * language model response.
1304
+ *
1305
+ * Calculated as `(inputTokens + outputTokens) / requestSeconds`.
1306
+ */
1307
+ readonly effectiveTotalTokensPerSecond: number;
1308
+ /**
1309
+ * Total time spent on the step in milliseconds.
1310
+ */
1311
+ readonly stepTimeMs: number;
1312
+ /**
1313
+ * Time spent waiting for the language model response in milliseconds.
1314
+ */
1315
+ readonly responseTimeMs: number;
1316
+ /**
1317
+ * Time spent executing each client-side tool call in milliseconds, keyed by
1318
+ * tool call ID.
1319
+ */
1320
+ readonly toolExecutionMs: Readonly<Record<string, number>>;
1321
+ /**
1322
+ * Time until the first generated output chunk was received in milliseconds.
1323
+ *
1324
+ * This includes text deltas, reasoning deltas, generated files, reasoning
1325
+ * files, tool input deltas, and tool calls.
1326
+ *
1327
+ * Only available for streaming steps.
1328
+ */
1329
+ readonly timeToFirstOutputMs: number | undefined;
1330
+ /**
1331
+ * Timing statistics for the gaps between generated output chunks in
1332
+ * milliseconds.
1333
+ *
1334
+ * Only available for streaming steps with at least two generated output
1335
+ * chunks.
1336
+ */
1337
+ readonly timeBetweenOutputChunksMs?: OutputChunkTimingStats;
1338
+ };
1339
+ /**
1340
+ * The result of a single step in the generation process.
1341
+ */
1342
+ type StepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context = Context> = {
1343
+ /**
1344
+ * Unique identifier for the generation call this step belongs to.
1345
+ */
1346
+ readonly callId: string;
1347
+ /**
1348
+ * Zero-based index of this step.
1349
+ */
1350
+ readonly stepNumber: number;
1351
+ /**
1352
+ * Information about the model that produced this step.
1353
+ */
1354
+ readonly model: {
1355
+ /** The provider of the model. */
1356
+ readonly provider: string;
1357
+ /** The ID of the model. */
1358
+ readonly modelId: string;
1359
+ };
1360
+ /**
1361
+ * Tool context.
1362
+ */
1363
+ readonly toolsContext: InferToolSetContext<TOOLS>;
1364
+ /**
1365
+ * The runtime context that was used as input for the step.
1366
+ */
1367
+ readonly runtimeContext: RUNTIME_CONTEXT;
1368
+ /**
1369
+ * The content that was generated in the last step.
1370
+ */
1371
+ readonly content: Array<ContentPart<TOOLS>>;
1372
+ /**
1373
+ * The concatenation of all text parts generated in this step.
1374
+ * It is an empty string if the step contains no text parts.
1375
+ */
1376
+ readonly text: string;
1377
+ /**
1378
+ * The reasoning that was generated during the generation.
1379
+ */
1380
+ readonly reasoning: Array<ReasoningPart | ReasoningFilePart>;
1381
+ /**
1382
+ * The reasoning text that was generated during the generation.
1383
+ *
1384
+ * It is a concatenation of all reasoning parts (but excluding reasoning file parts).
1385
+ * Can be undefined if the model has only generated text.
1386
+ */
1387
+ readonly reasoningText: string | undefined;
1388
+ /**
1389
+ * The files that were generated during the generation.
1390
+ */
1391
+ readonly files: Array<GeneratedFile>;
1392
+ /**
1393
+ * The sources that were used to generate the text.
1394
+ */
1395
+ readonly sources: Array<Source>;
1396
+ /**
1397
+ * The tool calls that were made during the generation.
1398
+ */
1399
+ readonly toolCalls: Array<TypedToolCall<TOOLS>>;
1400
+ /**
1401
+ * The static tool calls that were made in the last step.
1402
+ */
1403
+ readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
1404
+ /**
1405
+ * The dynamic tool calls that were made in the last step.
1406
+ */
1407
+ readonly dynamicToolCalls: Array<DynamicToolCall>;
1408
+ /**
1409
+ * The results of the tool calls.
1410
+ */
1411
+ readonly toolResults: Array<TypedToolResult<TOOLS>>;
1412
+ /**
1413
+ * The static tool results that were made in the last step.
1414
+ */
1415
+ readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
1416
+ /**
1417
+ * The dynamic tool results that were made in the last step.
1418
+ */
1419
+ readonly dynamicToolResults: Array<DynamicToolResult>;
1420
+ /**
1421
+ * The unified reason why the generation finished.
1422
+ */
1423
+ readonly finishReason: FinishReason;
1424
+ /**
1425
+ * The raw reason why the generation finished (from the provider).
1426
+ */
1427
+ readonly rawFinishReason: string | undefined;
1428
+ /**
1429
+ * The token usage of the generated text.
1430
+ */
1431
+ readonly usage: LanguageModelUsage;
1432
+ /**
1433
+ * Performance metrics for the step.
1434
+ */
1435
+ readonly performance: StepResultPerformance;
1436
+ /**
1437
+ * Warnings from the model provider (e.g. unsupported settings).
1438
+ */
1439
+ readonly warnings: CallWarning[] | undefined;
1440
+ /**
1441
+ * Additional request information.
1442
+ */
1443
+ readonly request: LanguageModelRequestMetadata;
1444
+ /**
1445
+ * Additional response information.
1446
+ */
1447
+ readonly response: LanguageModelResponseMetadata;
1448
+ /**
1449
+ * Additional provider-specific metadata. They are passed through
1450
+ * from the provider to the AI SDK and enable provider-specific
1451
+ * results that can be fully encapsulated in the provider.
1452
+ */
1453
+ readonly providerMetadata: ProviderMetadata | undefined;
1454
+ };
1455
+ export declare class DefaultStepResult<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context = Context> implements StepResult<TOOLS, RUNTIME_CONTEXT> {
1456
+ readonly callId: StepResult<TOOLS, RUNTIME_CONTEXT>['callId'];
1457
+ readonly stepNumber: StepResult<TOOLS, RUNTIME_CONTEXT>['stepNumber'];
1458
+ readonly model: StepResult<TOOLS, RUNTIME_CONTEXT>['model'];
1459
+ readonly toolsContext: StepResult<TOOLS, RUNTIME_CONTEXT>['toolsContext'];
1460
+ readonly runtimeContext: StepResult<TOOLS, RUNTIME_CONTEXT>['runtimeContext'];
1461
+ readonly content: StepResult<TOOLS, RUNTIME_CONTEXT>['content'];
1462
+ readonly finishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['finishReason'];
1463
+ readonly rawFinishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['rawFinishReason'];
1464
+ readonly usage: StepResult<TOOLS, RUNTIME_CONTEXT>['usage'];
1465
+ readonly performance: StepResult<TOOLS, RUNTIME_CONTEXT>['performance'];
1466
+ readonly warnings: StepResult<TOOLS, RUNTIME_CONTEXT>['warnings'];
1467
+ readonly request: StepResult<TOOLS, RUNTIME_CONTEXT>['request'];
1468
+ readonly response: StepResult<TOOLS, RUNTIME_CONTEXT>['response'];
1469
+ readonly providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
1470
+ constructor({ callId, stepNumber, provider, modelId, runtimeContext, toolsContext, content, finishReason, rawFinishReason, usage, performance, warnings, request, response, providerMetadata }: {
1471
+ callId: StepResult<TOOLS, RUNTIME_CONTEXT>['callId'];
1472
+ stepNumber: StepResult<TOOLS, RUNTIME_CONTEXT>['stepNumber'];
1473
+ provider: StepResult<TOOLS, RUNTIME_CONTEXT>['model']['provider'];
1474
+ modelId: StepResult<TOOLS, RUNTIME_CONTEXT>['model']['modelId'];
1475
+ runtimeContext: StepResult<TOOLS, RUNTIME_CONTEXT>['runtimeContext'];
1476
+ toolsContext: StepResult<TOOLS, RUNTIME_CONTEXT>['toolsContext'];
1477
+ content: StepResult<TOOLS, RUNTIME_CONTEXT>['content'];
1478
+ finishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['finishReason'];
1479
+ rawFinishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['rawFinishReason'];
1480
+ usage: StepResult<TOOLS, RUNTIME_CONTEXT>['usage'];
1481
+ performance: StepResult<TOOLS, RUNTIME_CONTEXT>['performance'];
1482
+ warnings: StepResult<TOOLS, RUNTIME_CONTEXT>['warnings'];
1483
+ request: StepResult<TOOLS, RUNTIME_CONTEXT>['request'];
1484
+ response: StepResult<TOOLS, RUNTIME_CONTEXT>['response'];
1485
+ providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
1486
+ });
1487
+ get text(): string;
1488
+ get reasoning(): Array<ReasoningPart | ReasoningFilePart>;
1489
+ get reasoningText(): string | undefined;
1490
+ get files(): GeneratedFile[];
1491
+ get sources(): (({
1492
+ type: "source";
1493
+ } & {
1494
+ type: "source";
1495
+ sourceType: "url";
1496
+ id: string;
1497
+ url: string;
1498
+ title?: string;
1499
+ providerMetadata?: import("@ai-sdk/provider").SharedV4ProviderMetadata;
1500
+ }) | ({
1501
+ type: "source";
1502
+ } & {
1503
+ type: "source";
1504
+ sourceType: "document";
1505
+ id: string;
1506
+ mediaType: string;
1507
+ title: string;
1508
+ filename?: string;
1509
+ providerMetadata?: import("@ai-sdk/provider").SharedV4ProviderMetadata;
1510
+ }))[];
1511
+ get toolCalls(): (({
1512
+ type: "tool-call";
1513
+ } & {
1514
+ type: "tool-call";
1515
+ toolCallId: string;
1516
+ providerExecuted?: boolean;
1517
+ providerMetadata?: ProviderMetadata;
1518
+ toolMetadata?: import("@ai-sdk/provider").JSONObject;
1519
+ } & {
1520
+ toolName: string;
1521
+ input: unknown;
1522
+ dynamic: true;
1523
+ title?: string;
1524
+ invalid?: boolean;
1525
+ error?: unknown;
1526
+ } & {
1527
+ providerMetadata?: ProviderMetadata;
1528
+ }) | ({
1529
+ type: "tool-call";
1530
+ } & StaticToolCall<TOOLS> & {
1531
+ providerMetadata?: ProviderMetadata;
1532
+ }))[];
1533
+ get staticToolCalls(): StaticToolCall<TOOLS>[];
1534
+ get dynamicToolCalls(): DynamicToolCall[];
1535
+ get toolResults(): (({
1536
+ type: "tool-result";
1537
+ } & DynamicToolResult & {
1538
+ providerMetadata?: ProviderMetadata;
1539
+ }) | ({
1540
+ type: "tool-result";
1541
+ } & StaticToolResult<TOOLS> & {
1542
+ providerMetadata?: ProviderMetadata;
1543
+ }))[];
1544
+ get staticToolResults(): StaticToolResult<TOOLS>[];
1545
+ get dynamicToolResults(): DynamicToolResult[];
1495
1546
  }
1496
-
1547
+ //#endregion
1548
+ //#region src/generate-text/language-model-events.d.ts
1497
1549
  /**
1498
1550
  * Common model information used across callback events.
1499
1551
  */
1500
1552
  type ModelInfo = {
1501
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
1502
- readonly provider: string;
1503
- /** The specific model identifier (e.g., 'gpt-4o'). */
1504
- readonly modelId: string;
1553
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
1554
+ readonly provider: string;
1555
+ /** The specific model identifier (e.g., 'gpt-4o'). */
1556
+ readonly modelId: string;
1505
1557
  };
1506
1558
  /**
1507
1559
  * Event passed to the `onLanguageModelCallStart` callback.
@@ -1510,10 +1562,10 @@ type ModelInfo = {
1510
1562
  * Unlike `onStepStart`, this only represents model invocation work.
1511
1563
  */
1512
1564
  type LanguageModelCallStartEvent = ModelInfo & {
1513
- /** Unique identifier for this generation call, used to correlate events. */
1514
- readonly callId: string;
1515
- /** Prepared tool definitions for the model call, if any. */
1516
- readonly tools: ReadonlyArray<Record<string, unknown>> | undefined;
1565
+ /** Unique identifier for this generation call, used to correlate events. */
1566
+ readonly callId: string;
1567
+ /** Prepared tool definitions for the model call, if any. */
1568
+ readonly tools: ReadonlyArray<Record<string, unknown>> | undefined;
1517
1569
  } & StandardizedPrompt & LanguageModelCallOptions;
1518
1570
  /**
1519
1571
  * Event passed to the `onLanguageModelCallEnd` callback.
@@ -1522,59 +1574,59 @@ type LanguageModelCallStartEvent = ModelInfo & {
1522
1574
  * any client-side tool execution begins.
1523
1575
  */
1524
1576
  type LanguageModelCallEndEvent<TOOLS extends ToolSet = ToolSet> = ModelInfo & {
1525
- /** Unique identifier for this generation call, used to correlate events. */
1526
- readonly callId: string;
1527
- /** The unified reason why the model call finished. */
1528
- readonly finishReason: FinishReason;
1529
- /** The token usage reported by the model call. */
1530
- readonly usage: LanguageModelUsage;
1531
- /** The content parts produced by the model call. */
1532
- readonly content: ReadonlyArray<ContentPart<TOOLS>>;
1533
- /** The provider-returned response id for this model call. */
1534
- readonly responseId: string;
1535
- /** Optional provider-specific metadata for this model call. */
1536
- readonly providerMetadata?: ProviderMetadata;
1537
- /** Performance metrics for the model call. */
1538
- readonly performance: {
1539
- /** Time spent waiting for the language model response in milliseconds. */
1540
- readonly responseTimeMs: number;
1541
- /**
1542
- * Effective number of output tokens per second over the full language
1543
- * model response.
1544
- */
1545
- readonly effectiveOutputTokensPerSecond: number;
1546
- /**
1547
- * Number of output tokens per second after the first generated output
1548
- * chunk was received.
1549
- *
1550
- * Only available for streaming calls.
1551
- */
1552
- readonly outputTokensPerSecond: number | undefined;
1553
- /**
1554
- * Number of input tokens processed per second before the first generated
1555
- * output chunk was received.
1556
- *
1557
- * Only available for streaming calls.
1558
- */
1559
- readonly inputTokensPerSecond: number | undefined;
1560
- /**
1561
- * Effective number of input and output tokens per second over the full
1562
- * language model response.
1563
- */
1564
- readonly effectiveTotalTokensPerSecond: number;
1565
- /**
1566
- * Time until the first generated output chunk was received in
1567
- * milliseconds.
1568
- */
1569
- readonly timeToFirstOutputMs: number | undefined;
1570
- /**
1571
- * Timing statistics for the gaps between generated output chunks in
1572
- * milliseconds.
1573
- *
1574
- * Only available for streaming calls with at least two output chunks.
1575
- */
1576
- readonly timeBetweenOutputChunksMs?: OutputChunkTimingStats;
1577
- };
1577
+ /** Unique identifier for this generation call, used to correlate events. */
1578
+ readonly callId: string;
1579
+ /** The unified reason why the model call finished. */
1580
+ readonly finishReason: FinishReason;
1581
+ /** The token usage reported by the model call. */
1582
+ readonly usage: LanguageModelUsage;
1583
+ /** The content parts produced by the model call. */
1584
+ readonly content: ReadonlyArray<ContentPart<TOOLS>>;
1585
+ /** The provider-returned response id for this model call. */
1586
+ readonly responseId: string;
1587
+ /** Optional provider-specific metadata for this model call. */
1588
+ readonly providerMetadata?: ProviderMetadata;
1589
+ /** Performance metrics for the model call. */
1590
+ readonly performance: {
1591
+ /** Time spent waiting for the language model response in milliseconds. */
1592
+ readonly responseTimeMs: number;
1593
+ /**
1594
+ * Effective number of output tokens per second over the full language
1595
+ * model response.
1596
+ */
1597
+ readonly effectiveOutputTokensPerSecond: number;
1598
+ /**
1599
+ * Number of output tokens per second after the first generated output
1600
+ * chunk was received.
1601
+ *
1602
+ * Only available for streaming calls.
1603
+ */
1604
+ readonly outputTokensPerSecond: number | undefined;
1605
+ /**
1606
+ * Number of input tokens processed per second before the first generated
1607
+ * output chunk was received.
1608
+ *
1609
+ * Only available for streaming calls.
1610
+ */
1611
+ readonly inputTokensPerSecond: number | undefined;
1612
+ /**
1613
+ * Effective number of input and output tokens per second over the full
1614
+ * language model response.
1615
+ */
1616
+ readonly effectiveTotalTokensPerSecond: number;
1617
+ /**
1618
+ * Time until the first generated output chunk was received in
1619
+ * milliseconds.
1620
+ */
1621
+ readonly timeToFirstOutputMs: number | undefined;
1622
+ /**
1623
+ * Timing statistics for the gaps between generated output chunks in
1624
+ * milliseconds.
1625
+ *
1626
+ * Only available for streaming calls with at least two output chunks.
1627
+ */
1628
+ readonly timeBetweenOutputChunksMs?: OutputChunkTimingStats;
1629
+ };
1578
1630
  };
1579
1631
  /**
1580
1632
  * Callback that is set using the `onLanguageModelCallStart` option.
@@ -1595,7 +1647,8 @@ type OnLanguageModelCallStartCallback = Callback<LanguageModelCallStartEvent>;
1595
1647
  * @param event - The event object containing model-call-specific outputs.
1596
1648
  */
1597
1649
  type OnLanguageModelCallEndCallback<TOOLS extends ToolSet = ToolSet> = Callback<LanguageModelCallEndEvent<TOOLS>>;
1598
-
1650
+ //#endregion
1651
+ //#region src/generate-text/tool-order.d.ts
1599
1652
  /**
1600
1653
  * Tool names that define the order in which tools are sent to the provider.
1601
1654
  *
@@ -1604,7 +1657,8 @@ type OnLanguageModelCallEndCallback<TOOLS extends ToolSet = ToolSet> = Callback<
1604
1657
  * listed in `toolOrder` are sent after the listed tools, sorted alphabetically.
1605
1658
  */
1606
1659
  type ToolOrder<TOOLS extends ToolSet> = ReadonlyArray<keyof TOOLS & string> | undefined;
1607
-
1660
+ //#endregion
1661
+ //#region src/util/async-iterable-stream.d.ts
1608
1662
  /**
1609
1663
  * A type that combines AsyncIterable and ReadableStream.
1610
1664
  * This allows a ReadableStream to be consumed using for-await-of syntax.
@@ -1618,143 +1672,144 @@ type AsyncIterableStream<T> = AsyncIterable<T> & ReadableStream<T>;
1618
1672
  * @param source The source ReadableStream to wrap.
1619
1673
  * @returns An AsyncIterableStream that can be used as both a ReadableStream and an AsyncIterable.
1620
1674
  */
1621
- declare function createAsyncIterableStream<T>(source: ReadableStream<T>): AsyncIterableStream<T>;
1622
-
1675
+ export declare function createAsyncIterableStream<T>(source: ReadableStream<T>): AsyncIterableStream<T>;
1676
+ //#endregion
1677
+ //#region src/generate-text/tool-output-denied.d.ts
1623
1678
  /**
1624
1679
  * Tool output when the tool execution has been denied (for static tools).
1625
1680
  */
1626
- type StaticToolOutputDenied<TOOLS extends ToolSet> = ValueOf<{
1627
- [NAME in keyof TOOLS]: {
1628
- type: 'tool-output-denied';
1629
- toolCallId: string;
1630
- toolName: NAME & string;
1631
- providerExecuted?: boolean;
1632
- dynamic?: false | undefined;
1633
- };
1634
- }>;
1635
-
1681
+ type StaticToolOutputDenied<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: {
1682
+ type: 'tool-output-denied';
1683
+ toolCallId: string;
1684
+ toolName: NAME & string;
1685
+ providerExecuted?: boolean;
1686
+ dynamic?: false | undefined;
1687
+ }; }>;
1688
+ //#endregion
1689
+ //#region src/generate-text/stream-text-result.d.ts
1636
1690
  type TextStreamTextDeltaPart = {
1637
- type: 'text-delta';
1638
- id: string;
1639
- providerMetadata?: ProviderMetadata;
1640
- text: string;
1691
+ type: 'text-delta';
1692
+ id: string;
1693
+ providerMetadata?: ProviderMetadata;
1694
+ text: string;
1641
1695
  };
1642
1696
  type TextStreamTextStartPart = {
1643
- type: 'text-start';
1644
- id: string;
1645
- providerMetadata?: ProviderMetadata;
1697
+ type: 'text-start';
1698
+ id: string;
1699
+ providerMetadata?: ProviderMetadata;
1646
1700
  };
1647
1701
  type TextStreamTextEndPart = {
1648
- type: 'text-end';
1649
- id: string;
1650
- providerMetadata?: ProviderMetadata;
1702
+ type: 'text-end';
1703
+ id: string;
1704
+ providerMetadata?: ProviderMetadata;
1651
1705
  };
1652
1706
  type TextStreamReasoningStartPart = {
1653
- type: 'reasoning-start';
1654
- id: string;
1655
- providerMetadata?: ProviderMetadata;
1707
+ type: 'reasoning-start';
1708
+ id: string;
1709
+ providerMetadata?: ProviderMetadata;
1656
1710
  };
1657
1711
  type TextStreamReasoningEndPart = {
1658
- type: 'reasoning-end';
1659
- id: string;
1660
- providerMetadata?: ProviderMetadata;
1712
+ type: 'reasoning-end';
1713
+ id: string;
1714
+ providerMetadata?: ProviderMetadata;
1661
1715
  };
1662
1716
  type TextStreamReasoningDeltaPart = {
1663
- type: 'reasoning-delta';
1664
- providerMetadata?: ProviderMetadata;
1665
- id: string;
1666
- text: string;
1717
+ type: 'reasoning-delta';
1718
+ providerMetadata?: ProviderMetadata;
1719
+ id: string;
1720
+ text: string;
1667
1721
  };
1668
1722
  type TextStreamCustomPart = {
1669
- type: 'custom';
1670
- kind: `${string}.${string}`;
1671
- providerMetadata?: ProviderMetadata;
1723
+ type: 'custom';
1724
+ kind: `${string}.${string}`;
1725
+ providerMetadata?: ProviderMetadata;
1672
1726
  };
1673
1727
  type TextStreamToolInputStartPart = {
1674
- type: 'tool-input-start';
1675
- id: string;
1676
- toolName: string;
1677
- providerMetadata?: ProviderMetadata;
1678
- toolMetadata?: JSONObject;
1679
- providerExecuted?: boolean;
1680
- dynamic?: boolean;
1681
- title?: string;
1728
+ type: 'tool-input-start';
1729
+ id: string;
1730
+ toolName: string;
1731
+ providerMetadata?: ProviderMetadata;
1732
+ toolMetadata?: JSONObject;
1733
+ providerExecuted?: boolean;
1734
+ dynamic?: boolean;
1735
+ title?: string;
1682
1736
  };
1683
1737
  type TextStreamToolInputEndPart = {
1684
- type: 'tool-input-end';
1685
- id: string;
1686
- providerMetadata?: ProviderMetadata;
1738
+ type: 'tool-input-end';
1739
+ id: string;
1740
+ providerMetadata?: ProviderMetadata;
1687
1741
  };
1688
1742
  type TextStreamToolInputDeltaPart = {
1689
- type: 'tool-input-delta';
1690
- id: string;
1691
- delta: string;
1692
- providerMetadata?: ProviderMetadata;
1743
+ type: 'tool-input-delta';
1744
+ id: string;
1745
+ delta: string;
1746
+ providerMetadata?: ProviderMetadata;
1693
1747
  };
1694
1748
  type TextStreamSourcePart = {
1695
- type: 'source';
1749
+ type: 'source';
1696
1750
  } & Source;
1697
1751
  type TextStreamFilePart = {
1698
- type: 'file';
1699
- file: GeneratedFile;
1700
- providerMetadata?: ProviderMetadata;
1752
+ type: 'file';
1753
+ file: GeneratedFile;
1754
+ providerMetadata?: ProviderMetadata;
1701
1755
  };
1702
1756
  type TextStreamReasoningFilePart = {
1703
- type: 'reasoning-file';
1704
- file: GeneratedFile;
1705
- providerMetadata?: ProviderMetadata;
1757
+ type: 'reasoning-file';
1758
+ file: GeneratedFile;
1759
+ providerMetadata?: ProviderMetadata;
1706
1760
  };
1707
1761
  type TextStreamToolCallPart<TOOLS extends ToolSet> = {
1708
- type: 'tool-call';
1762
+ type: 'tool-call';
1709
1763
  } & TypedToolCall<TOOLS>;
1710
1764
  type TextStreamToolResultPart<TOOLS extends ToolSet> = {
1711
- type: 'tool-result';
1765
+ type: 'tool-result';
1712
1766
  } & TypedToolResult<TOOLS>;
1713
1767
  type TextStreamToolErrorPart<TOOLS extends ToolSet> = {
1714
- type: 'tool-error';
1768
+ type: 'tool-error';
1715
1769
  } & TypedToolError<TOOLS>;
1716
1770
  type TextStreamToolOutputDeniedPart<TOOLS extends ToolSet> = {
1717
- type: 'tool-output-denied';
1771
+ type: 'tool-output-denied';
1718
1772
  } & StaticToolOutputDenied<TOOLS>;
1719
1773
  type TextStreamToolApprovalRequestPart<TOOLS extends ToolSet> = ToolApprovalRequestOutput<TOOLS>;
1720
1774
  type TextStreamToolApprovalResponsePart<TOOLS extends ToolSet> = ToolApprovalResponseOutput<TOOLS>;
1721
1775
  type TextStreamStartStepPart = {
1722
- type: 'start-step';
1723
- request: LanguageModelRequestMetadata;
1724
- warnings: CallWarning[];
1776
+ type: 'start-step';
1777
+ request: LanguageModelRequestMetadata;
1778
+ warnings: CallWarning[];
1725
1779
  };
1726
1780
  type TextStreamFinishStepPart = {
1727
- type: 'finish-step';
1728
- response: Omit<LanguageModelResponseMetadata, 'messages' | 'body'>;
1729
- usage: LanguageModelUsage;
1730
- performance: StepResultPerformance;
1731
- finishReason: FinishReason;
1732
- rawFinishReason: string | undefined;
1733
- providerMetadata: ProviderMetadata | undefined;
1781
+ type: 'finish-step';
1782
+ response: Omit<LanguageModelResponseMetadata, 'messages' | 'body'>;
1783
+ usage: LanguageModelUsage;
1784
+ performance: StepResultPerformance;
1785
+ finishReason: FinishReason;
1786
+ rawFinishReason: string | undefined;
1787
+ providerMetadata: ProviderMetadata | undefined;
1734
1788
  };
1735
1789
  type TextStreamStartPart = {
1736
- type: 'start';
1790
+ type: 'start';
1737
1791
  };
1738
1792
  type TextStreamFinishPart = {
1739
- type: 'finish';
1740
- finishReason: FinishReason;
1741
- rawFinishReason: string | undefined;
1742
- totalUsage: LanguageModelUsage;
1793
+ type: 'finish';
1794
+ finishReason: FinishReason;
1795
+ rawFinishReason: string | undefined;
1796
+ totalUsage: LanguageModelUsage;
1743
1797
  };
1744
1798
  type TextStreamAbortPart = {
1745
- type: 'abort';
1746
- reason?: string;
1799
+ type: 'abort';
1800
+ reason?: string;
1747
1801
  };
1748
1802
  type TextStreamErrorPart = {
1749
- type: 'error';
1750
- error: unknown;
1803
+ type: 'error';
1804
+ error: unknown;
1751
1805
  };
1752
1806
  type TextStreamRawPart = {
1753
- type: 'raw';
1754
- rawValue: unknown;
1807
+ type: 'raw';
1808
+ rawValue: unknown;
1755
1809
  };
1756
1810
  type TextStreamPart<TOOLS extends ToolSet> = TextStreamTextStartPart | TextStreamTextEndPart | TextStreamTextDeltaPart | TextStreamReasoningStartPart | TextStreamReasoningEndPart | TextStreamReasoningDeltaPart | TextStreamCustomPart | TextStreamToolInputStartPart | TextStreamToolInputEndPart | TextStreamToolInputDeltaPart | TextStreamSourcePart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | TextStreamToolOutputDeniedPart<TOOLS> | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamToolApprovalResponsePart<TOOLS> | TextStreamStartStepPart | TextStreamFinishStepPart | TextStreamStartPart | TextStreamFinishPart | TextStreamAbortPart | TextStreamErrorPart | TextStreamRawPart;
1757
-
1811
+ //#endregion
1812
+ //#region src/generate-text/tool-approval-configuration.d.ts
1758
1813
  /**
1759
1814
  * The approval status of a tool configuration. This can be one of the following:
1760
1815
  *
@@ -1770,17 +1825,17 @@ type TextStreamPart<TOOLS extends ToolSet> = TextStreamTextStartPart | TextStrea
1770
1825
  * `undefined` is treated as the `not-applicable` status.
1771
1826
  */
1772
1827
  type ToolApprovalStatus = undefined | 'not-applicable' | 'approved' | 'denied' | 'user-approval' | {
1773
- type: 'not-applicable';
1774
- reason?: never;
1828
+ type: 'not-applicable';
1829
+ reason?: never;
1775
1830
  } | {
1776
- type: 'approved';
1777
- reason?: string;
1831
+ type: 'approved';
1832
+ reason?: string;
1778
1833
  } | {
1779
- type: 'denied';
1780
- reason?: string;
1834
+ type: 'denied';
1835
+ reason?: string;
1781
1836
  } | {
1782
- type: 'user-approval';
1783
- reason?: string;
1837
+ type: 'user-approval';
1838
+ reason?: string;
1784
1839
  };
1785
1840
  /**
1786
1841
  * Function that is called to determine if the tool needs approval before it can be executed.
@@ -1788,8 +1843,8 @@ type ToolApprovalStatus = undefined | 'not-applicable' | 'approved' | 'denied' |
1788
1843
  * Return `undefined` for the same effect as the `not-applicable` status.
1789
1844
  */
1790
1845
  type SingleToolApprovalFunction<INPUT, TOOL_CONTEXT extends Context | unknown | never, RUNTIME_CONTEXT extends Context | unknown | never> = (input: INPUT, options: Omit<ToolExecutionOptions<TOOL_CONTEXT>, 'abortSignal' | 'context'> & {
1791
- toolContext: TOOL_CONTEXT;
1792
- runtimeContext: RUNTIME_CONTEXT;
1846
+ toolContext: TOOL_CONTEXT;
1847
+ runtimeContext: RUNTIME_CONTEXT;
1793
1848
  }) => MaybePromiseLike<ToolApprovalStatus>;
1794
1849
  /**
1795
1850
  * Function that is called to determine if a tool call needs approval before it can be executed.
@@ -1797,27 +1852,27 @@ type SingleToolApprovalFunction<INPUT, TOOL_CONTEXT extends Context | unknown |
1797
1852
  * Return `undefined` for the same effect as the `not-applicable` status.
1798
1853
  */
1799
1854
  type GenericToolApprovalFunction<TOOLS extends ToolSet, TOOLS_CONTEXT extends InferToolSetContext<TOOLS>, RUNTIME_CONTEXT extends Context | unknown | never> = (options: {
1800
- /**
1801
- * The tool call that needs approval.
1802
- */
1803
- toolCall: TypedToolCall<TOOLS>;
1804
- /**
1805
- * All tools that are available for the model to call.
1806
- */
1807
- tools: TOOLS | undefined;
1808
- /**
1809
- * Tool context for all tools that are available for the model to call.
1810
- */
1811
- toolsContext: TOOLS_CONTEXT;
1812
- /**
1813
- * Runtime context.
1814
- */
1815
- runtimeContext: RUNTIME_CONTEXT;
1816
- /**
1817
- * Messages that were sent to the language model to initiate the response that contained the tool call.
1818
- * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
1819
- */
1820
- messages: ModelMessage[];
1855
+ /**
1856
+ * The tool call that needs approval.
1857
+ */
1858
+ toolCall: TypedToolCall<TOOLS>;
1859
+ /**
1860
+ * All tools that are available for the model to call.
1861
+ */
1862
+ tools: TOOLS | undefined;
1863
+ /**
1864
+ * Tool context for all tools that are available for the model to call.
1865
+ */
1866
+ toolsContext: TOOLS_CONTEXT;
1867
+ /**
1868
+ * Runtime context.
1869
+ */
1870
+ runtimeContext: RUNTIME_CONTEXT;
1871
+ /**
1872
+ * Messages that were sent to the language model to initiate the response that contained the tool call.
1873
+ * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
1874
+ */
1875
+ messages: ModelMessage[];
1821
1876
  }) => MaybePromiseLike<ToolApprovalStatus>;
1822
1877
  /**
1823
1878
  * Configure whether individual tools require approval before they can run.
@@ -1838,39 +1893,41 @@ type GenericToolApprovalFunction<TOOLS extends ToolSet, TOOLS_CONTEXT extends In
1838
1893
  * For approved and denied statuses, the reason is emitted on the approval response.
1839
1894
  * For user-approval statuses, the reason is emitted on the approval request so it can be shown to the approver.
1840
1895
  */
1841
- type ToolApprovalConfiguration<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context | unknown | never> = GenericToolApprovalFunction<TOOLS, InferToolSetContext<TOOLS>, RUNTIME_CONTEXT> | {
1842
- [key in keyof TOOLS]?: ToolApprovalStatus | SingleToolApprovalFunction<InferToolInput<TOOLS[key]>, InferToolContext<TOOLS[key]>, RUNTIME_CONTEXT>;
1843
- };
1844
-
1896
+ type ToolApprovalConfiguration<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context | unknown | never> = GenericToolApprovalFunction<TOOLS, InferToolSetContext<TOOLS>, RUNTIME_CONTEXT> | { [key in keyof TOOLS]?: ToolApprovalStatus | SingleToolApprovalFunction<InferToolInput<TOOLS[key]>, InferToolContext<TOOLS[key]>, RUNTIME_CONTEXT>; };
1897
+ //#endregion
1898
+ //#region src/generate-text/tool-caller-configuration.d.ts
1845
1899
  type ResolvedToolCallers = Record<string, ReadonlyArray<string>>;
1846
-
1900
+ //#endregion
1901
+ //#region src/error/invalid-tool-input-error.d.ts
1847
1902
  declare const symbol$1: unique symbol;
1848
1903
  declare class InvalidToolInputError extends AISDKError {
1849
- private readonly [symbol$1];
1850
- readonly toolName: string;
1851
- readonly toolInput: string;
1852
- constructor({ toolInput, toolName, cause, message, }: {
1853
- message?: string;
1854
- toolInput: string;
1855
- toolName: string;
1856
- cause: unknown;
1857
- });
1858
- static isInstance(error: unknown): error is InvalidToolInputError;
1904
+ private readonly [symbol$1];
1905
+ readonly toolName: string;
1906
+ readonly toolInput: string;
1907
+ constructor({ toolInput, toolName, cause, message }: {
1908
+ message?: string;
1909
+ toolInput: string;
1910
+ toolName: string;
1911
+ cause: unknown;
1912
+ });
1913
+ static isInstance(error: unknown): error is InvalidToolInputError;
1859
1914
  }
1860
-
1915
+ //#endregion
1916
+ //#region src/error/no-such-tool-error.d.ts
1861
1917
  declare const symbol: unique symbol;
1862
1918
  declare class NoSuchToolError extends AISDKError {
1863
- private readonly [symbol];
1864
- readonly toolName: string;
1865
- readonly availableTools: string[] | undefined;
1866
- constructor({ toolName, availableTools, message, }: {
1867
- toolName: string;
1868
- availableTools?: string[] | undefined;
1869
- message?: string;
1870
- });
1871
- static isInstance(error: unknown): error is NoSuchToolError;
1919
+ private readonly [symbol];
1920
+ readonly toolName: string;
1921
+ readonly availableTools: string[] | undefined;
1922
+ constructor({ toolName, availableTools, message }: {
1923
+ toolName: string;
1924
+ availableTools?: string[] | undefined;
1925
+ message?: string;
1926
+ });
1927
+ static isInstance(error: unknown): error is NoSuchToolError;
1872
1928
  }
1873
-
1929
+ //#endregion
1930
+ //#region src/generate-text/tool-call-repair-function.d.ts
1874
1931
  /**
1875
1932
  * A function that attempts to repair a tool call that failed to parse.
1876
1933
  *
@@ -1887,38 +1944,38 @@ declare class NoSuchToolError extends AISDKError {
1887
1944
  * @param options.abortSignal - An optional signal for cancelling the repair.
1888
1945
  */
1889
1946
  type ToolCallRepairFunction<TOOLS extends ToolSet> = (options: {
1890
- instructions: Instructions | undefined;
1891
- /**
1892
- * @deprecated Use `instructions` instead.
1893
- */
1894
- system: Instructions | undefined;
1895
- messages: ModelMessage[];
1896
- toolCall: LanguageModelV4ToolCall;
1897
- tools: TOOLS;
1898
- inputSchema: (options: {
1899
- toolName: string;
1900
- }) => PromiseLike<JSONSchema7>;
1901
- error: NoSuchToolError | InvalidToolInputError;
1902
- abortSignal?: AbortSignal;
1947
+ instructions: Instructions | undefined;
1948
+ /**
1949
+ * @deprecated Use `instructions` instead.
1950
+ */
1951
+ system: Instructions | undefined;
1952
+ messages: ModelMessage$1[];
1953
+ toolCall: LanguageModelV4ToolCall;
1954
+ tools: TOOLS;
1955
+ inputSchema: (options: {
1956
+ toolName: string;
1957
+ }) => PromiseLike<JSONSchema7>;
1958
+ error: NoSuchToolError | InvalidToolInputError;
1959
+ abortSignal?: AbortSignal;
1903
1960
  }) => Promise<LanguageModelV4ToolCall | null>;
1904
-
1961
+ //#endregion
1962
+ //#region src/generate-text/tool-output.d.ts
1905
1963
  type ToolOutput<TOOLS extends ToolSet> = TypedToolResult<TOOLS> | TypedToolError<TOOLS>;
1906
-
1964
+ //#endregion
1965
+ //#region src/generate-text/tool-execution-events.d.ts
1907
1966
  /**
1908
1967
  * Resolves a single tool's context type, falling back to `undefined` when the
1909
1968
  * tool does not declare a `contextSchema`.
1910
1969
  */
1911
- type ToolContextFor<TOOL extends ToolSet[keyof ToolSet]> = [
1912
- InferToolContext<TOOL>
1913
- ] extends [never] ? undefined : InferToolContext<TOOL>;
1970
+ type ToolContextFor<TOOL extends ToolSet[keyof ToolSet]> = [InferToolContext<TOOL>] extends [never] ? undefined : InferToolContext<TOOL>;
1914
1971
  type BaseToolExecutionStartFields = {
1915
- /** Unique identifier for this generation call, used to correlate events. */
1916
- readonly callId: string;
1917
- /**
1918
- * Messages that were sent to the language model to initiate the response that contained the tool call.
1919
- * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
1920
- */
1921
- readonly messages: ModelMessage[];
1972
+ /** Unique identifier for this generation call, used to correlate events. */
1973
+ readonly callId: string;
1974
+ /**
1975
+ * Messages that were sent to the language model to initiate the response that contained the tool call.
1976
+ * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
1977
+ */
1978
+ readonly messages: ModelMessage[];
1922
1979
  };
1923
1980
  /**
1924
1981
  * Precise start event union for statically known tools.
@@ -1926,20 +1983,18 @@ type BaseToolExecutionStartFields = {
1926
1983
  * Each union member ties a specific `toolCall.toolName` to that tool's
1927
1984
  * validated `toolContext` type.
1928
1985
  */
1929
- type StaticToolExecutionStartEvent<TOOLS extends ToolSet> = ValueOf<{
1930
- [NAME in keyof TOOLS]: BaseToolExecutionStartFields & {
1931
- readonly toolCall: Extract<StaticToolCall<TOOLS>, {
1932
- toolName: NAME;
1933
- }>;
1934
- readonly toolContext: ToolContextFor<TOOLS[NAME]>;
1935
- };
1936
- }>;
1986
+ type StaticToolExecutionStartEvent<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: BaseToolExecutionStartFields & {
1987
+ readonly toolCall: Extract<StaticToolCall<TOOLS>, {
1988
+ toolName: NAME;
1989
+ }>;
1990
+ readonly toolContext: ToolContextFor<TOOLS[NAME]>;
1991
+ }; }>;
1937
1992
  /**
1938
1993
  * Start event shape for dynamic or untyped tool calls.
1939
1994
  */
1940
1995
  type DynamicToolExecutionStartEvent = BaseToolExecutionStartFields & {
1941
- readonly toolCall: DynamicToolCall;
1942
- readonly toolContext: unknown;
1996
+ readonly toolCall: DynamicToolCall;
1997
+ readonly toolContext: unknown;
1943
1998
  };
1944
1999
  /**
1945
2000
  * Broad start event shape used for the default `ToolSet` specialization.
@@ -1948,27 +2003,25 @@ type DynamicToolExecutionStartEvent = BaseToolExecutionStartFields & {
1948
2003
  * a concrete tool set and therefore cannot benefit from per-tool narrowing.
1949
2004
  */
1950
2005
  type WidenedToolExecutionStartEvent = BaseToolExecutionStartFields & {
1951
- readonly toolCall: StaticToolCall<ToolSet> | DynamicToolCall;
1952
- readonly toolContext: unknown;
2006
+ readonly toolCall: StaticToolCall<ToolSet> | DynamicToolCall;
2007
+ readonly toolContext: unknown;
1953
2008
  };
1954
2009
  /**
1955
2010
  * Event passed to the `onToolExecutionStart` callback.
1956
2011
  *
1957
2012
  * Called when a tool execution begins, before the tool's `execute` function is invoked.
1958
2013
  */
1959
- type ToolExecutionStartEvent<TOOLS extends ToolSet = ToolSet> = [
1960
- ToolSet
1961
- ] extends [TOOLS] ? WidenedToolExecutionStartEvent : StaticToolExecutionStartEvent<TOOLS> | DynamicToolExecutionStartEvent;
2014
+ type ToolExecutionStartEvent<TOOLS extends ToolSet = ToolSet> = [ToolSet] extends [TOOLS] ? WidenedToolExecutionStartEvent : StaticToolExecutionStartEvent<TOOLS> | DynamicToolExecutionStartEvent;
1962
2015
  type BaseToolExecutionEndFields = {
1963
- /** Unique identifier for this generation call, used to correlate events. */
1964
- readonly callId: string;
1965
- /** Execution time of the tool call in milliseconds. */
1966
- readonly toolExecutionMs: number;
1967
- /**
1968
- * Messages that were sent to the language model to initiate the response that contained the tool call.
1969
- * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
1970
- */
1971
- readonly messages: ModelMessage[];
2016
+ /** Unique identifier for this generation call, used to correlate events. */
2017
+ readonly callId: string;
2018
+ /** Execution time of the tool call in milliseconds. */
2019
+ readonly toolExecutionMs: number;
2020
+ /**
2021
+ * Messages that were sent to the language model to initiate the response that contained the tool call.
2022
+ * The messages **do not** include the system prompt nor the assistant response that contained the tool call.
2023
+ */
2024
+ readonly messages: ModelMessage[];
1972
2025
  };
1973
2026
  /**
1974
2027
  * Precise end event union for statically known tools.
@@ -1976,22 +2029,20 @@ type BaseToolExecutionEndFields = {
1976
2029
  * Each union member preserves the link between `toolCall.toolName`, the
1977
2030
  * corresponding validated `toolContext`, and the tool execution result.
1978
2031
  */
1979
- type StaticToolExecutionEndEvent<TOOLS extends ToolSet> = ValueOf<{
1980
- [NAME in keyof TOOLS]: BaseToolExecutionEndFields & {
1981
- readonly toolCall: Extract<StaticToolCall<TOOLS>, {
1982
- toolName: NAME;
1983
- }>;
1984
- readonly toolContext: ToolContextFor<TOOLS[NAME]>;
1985
- readonly toolOutput: ToolOutput<TOOLS>;
1986
- };
1987
- }>;
2032
+ type StaticToolExecutionEndEvent<TOOLS extends ToolSet> = ValueOf<{ [NAME in keyof TOOLS]: BaseToolExecutionEndFields & {
2033
+ readonly toolCall: Extract<StaticToolCall<TOOLS>, {
2034
+ toolName: NAME;
2035
+ }>;
2036
+ readonly toolContext: ToolContextFor<TOOLS[NAME]>;
2037
+ readonly toolOutput: ToolOutput<TOOLS>;
2038
+ }; }>;
1988
2039
  /**
1989
2040
  * End event shape for dynamic or untyped tool calls.
1990
2041
  */
1991
2042
  type DynamicToolExecutionEndEvent<TOOLS extends ToolSet> = BaseToolExecutionEndFields & {
1992
- readonly toolCall: DynamicToolCall;
1993
- readonly toolContext: unknown;
1994
- readonly toolOutput: ToolOutput<TOOLS>;
2043
+ readonly toolCall: DynamicToolCall;
2044
+ readonly toolContext: unknown;
2045
+ readonly toolOutput: ToolOutput<TOOLS>;
1995
2046
  };
1996
2047
  /**
1997
2048
  * Broad end event shape used for the default `ToolSet` specialization.
@@ -2000,9 +2051,9 @@ type DynamicToolExecutionEndEvent<TOOLS extends ToolSet> = BaseToolExecutionEndF
2000
2051
  * the concrete-tool specialization retains full per-tool narrowing.
2001
2052
  */
2002
2053
  type WidenedToolExecutionEndEvent = BaseToolExecutionEndFields & {
2003
- readonly toolCall: StaticToolCall<ToolSet> | DynamicToolCall;
2004
- readonly toolContext: unknown;
2005
- readonly toolOutput: ToolOutput<ToolSet>;
2054
+ readonly toolCall: StaticToolCall<ToolSet> | DynamicToolCall;
2055
+ readonly toolContext: unknown;
2056
+ readonly toolOutput: ToolOutput<ToolSet>;
2006
2057
  };
2007
2058
  /**
2008
2059
  * Event passed to the `onToolExecutionEnd` callback.
@@ -2010,9 +2061,7 @@ type WidenedToolExecutionEndEvent = BaseToolExecutionEndFields & {
2010
2061
  * Called when a tool execution completes, either successfully or with an error.
2011
2062
  * Uses the `toolOutput.type` discriminator to distinguish success and error.
2012
2063
  */
2013
- type ToolExecutionEndEvent<TOOLS extends ToolSet = ToolSet> = [
2014
- ToolSet
2015
- ] extends [TOOLS] ? WidenedToolExecutionEndEvent : StaticToolExecutionEndEvent<TOOLS> | DynamicToolExecutionEndEvent<TOOLS>;
2064
+ type ToolExecutionEndEvent<TOOLS extends ToolSet = ToolSet> = [ToolSet] extends [TOOLS] ? WidenedToolExecutionEndEvent : StaticToolExecutionEndEvent<TOOLS> | DynamicToolExecutionEndEvent<TOOLS>;
2016
2065
  /**
2017
2066
  * Callback that is set using the `onToolExecutionStart` option.
2018
2067
  *
@@ -2035,7 +2084,8 @@ type OnToolExecutionStartCallback<TOOLS extends ToolSet = ToolSet> = Callback<To
2035
2084
  * @param event - The event object containing tool call result information.
2036
2085
  */
2037
2086
  type OnToolExecutionEndCallback<TOOLS extends ToolSet = ToolSet> = Callback<ToolExecutionEndEvent<TOOLS>>;
2038
-
2087
+ //#endregion
2088
+ //#region src/generate-text/tool-input-refinement.d.ts
2039
2089
  /**
2040
2090
  * Mapping of tool names to functions that refine parsed tool inputs.
2041
2091
  *
@@ -2043,10 +2093,9 @@ type OnToolExecutionEndCallback<TOOLS extends ToolSet = ToolSet> = Callback<Tool
2043
2093
  * an input with the same type shape. Refined inputs are used for tool execution,
2044
2094
  * output parts, lifecycle callbacks, and telemetry.
2045
2095
  */
2046
- type ToolInputRefinement<TOOLS extends ToolSet> = {
2047
- [NAME in keyof TOOLS]?: (input: InferToolInput<TOOLS[NAME]>) => MaybePromiseLike<InferToolInput<TOOLS[NAME]>>;
2048
- };
2049
-
2096
+ type ToolInputRefinement<TOOLS extends ToolSet> = { [NAME in keyof TOOLS]?: (input: InferToolInput<TOOLS[NAME]>) => MaybePromiseLike<InferToolInput<TOOLS[NAME]>>; };
2097
+ //#endregion
2098
+ //#region src/generate-text/tools-context-parameter.d.ts
2050
2099
  /**
2051
2100
  * Checks whether a tool context map contains any contextual tool entries.
2052
2101
  */
@@ -2056,95 +2105,98 @@ type IsEmptyObject<OBJECT> = keyof OBJECT extends never ? true : false;
2056
2105
  * the tool set.
2057
2106
  */
2058
2107
  type ToolsContextSettings<TOOLS extends ToolSet> = IsEmptyObject<InferToolSetContext<TOOLS>> extends true ? {
2059
- toolsContext?: never;
2108
+ toolsContext?: never;
2060
2109
  } : HasRequiredKey<InferToolSetContext<TOOLS>> extends true ? {
2061
- toolsContext: InferToolSetContext<TOOLS>;
2110
+ toolsContext: InferToolSetContext<TOOLS>;
2062
2111
  } : {
2063
- toolsContext?: InferToolSetContext<TOOLS>;
2112
+ toolsContext?: InferToolSetContext<TOOLS>;
2064
2113
  };
2065
-
2114
+ //#endregion
2115
+ //#region src/generate-text/stream-text.d.ts
2066
2116
  type EnrichedStreamPart<TOOLS extends ToolSet, PARTIAL_OUTPUT> = {
2067
- part: TextStreamPart<TOOLS>;
2068
- partialOutput: PARTIAL_OUTPUT | undefined;
2117
+ part: TextStreamPart<TOOLS>;
2118
+ partialOutput: PARTIAL_OUTPUT | undefined;
2069
2119
  };
2070
-
2120
+ //#endregion
2121
+ //#region src/generate-text/output.d.ts
2071
2122
  interface Output<OUTPUT = any, PARTIAL = any, ELEMENT = any> {
2072
- /**
2073
- * The name of the output mode.
2074
- */
2075
- name: string;
2076
- /**
2077
- * The response format to use for the model.
2078
- */
2079
- responseFormat: PromiseLike<LanguageModelV4CallOptions['responseFormat']>;
2080
- /**
2081
- * Parses the complete output of the model.
2082
- */
2083
- parseCompleteOutput(options: {
2084
- text: string;
2085
- }, context: {
2086
- response: Omit<LanguageModelResponseMetadata, 'messages' | 'body'>;
2087
- usage: LanguageModelUsage;
2088
- finishReason: FinishReason;
2089
- }): Promise<OUTPUT>;
2090
- /**
2091
- * Parses the partial output of the model.
2092
- */
2093
- parsePartialOutput(options: {
2094
- text: string;
2095
- }): Promise<{
2096
- partial: PARTIAL;
2097
- } | undefined>;
2098
- /**
2099
- * Creates a stream transform that emits individual elements as they complete.
2100
- */
2101
- createElementStreamTransform(): TransformStream<EnrichedStreamPart<any, PARTIAL>, ELEMENT> | undefined;
2123
+ /**
2124
+ * The name of the output mode.
2125
+ */
2126
+ name: string;
2127
+ /**
2128
+ * The response format to use for the model.
2129
+ */
2130
+ responseFormat: PromiseLike<LanguageModelV4CallOptions['responseFormat']>;
2131
+ /**
2132
+ * Parses the complete output of the model.
2133
+ */
2134
+ parseCompleteOutput(options: {
2135
+ text: string;
2136
+ }, context: {
2137
+ response: Omit<LanguageModelResponseMetadata, 'messages' | 'body'>;
2138
+ usage: LanguageModelUsage;
2139
+ finishReason: FinishReason;
2140
+ }): Promise<OUTPUT>;
2141
+ /**
2142
+ * Parses the partial output of the model.
2143
+ */
2144
+ parsePartialOutput(options: {
2145
+ text: string;
2146
+ }): Promise<{
2147
+ partial: PARTIAL;
2148
+ } | undefined>;
2149
+ /**
2150
+ * Creates a stream transform that emits individual elements as they complete.
2151
+ */
2152
+ createElementStreamTransform(): TransformStream<EnrichedStreamPart<any, PARTIAL>, ELEMENT> | undefined;
2102
2153
  }
2103
-
2154
+ //#endregion
2155
+ //#region src/generate-text/generate-text-events.d.ts
2104
2156
  /**
2105
2157
  * Event passed to the `onStart` callback.
2106
2158
  *
2107
2159
  * Called when the generation operation begins, before any LLM calls.
2108
2160
  */
2109
2161
  type GenerateTextStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends Output = Output> = {
2110
- /** Unique identifier for this generation call, used to correlate events. */
2111
- readonly callId: string;
2112
- /** Identifies the operation type (e.g. 'ai.generateText' or 'ai.streamText'). */
2113
- readonly operationId: string;
2114
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
2115
- readonly provider: string;
2116
- /** The specific model identifier (e.g., 'gpt-4o'). */
2117
- readonly modelId: string;
2118
- /** The tools available for this generation. */
2119
- readonly tools: TOOLS | undefined;
2120
- /** The tool choice strategy for this generation. */
2121
- readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
2122
- /** Limits which tools are available for the model to call. */
2123
- readonly activeTools: ActiveTools<TOOLS>;
2124
- /** Controls the order in which tools are sent to the provider. */
2125
- readonly toolOrder: ToolOrder<TOOLS>;
2126
- /** Maximum number of retries for failed requests. */
2127
- readonly maxRetries: number;
2128
- /**
2129
- * Timeout configuration for the generation.
2130
- * Can be a number (milliseconds) or an object with totalMs, stepMs,
2131
- * firstChunkMs (streaming only), chunkMs, toolMs, and per-tool overrides via tools.
2132
- */
2133
- readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
2134
- /** Additional HTTP headers sent with the request. */
2135
- readonly headers: Record<string, string | undefined> | undefined;
2136
- /** Additional provider-specific options. */
2137
- readonly providerOptions: ProviderOptions | undefined;
2138
- /** The output specification for structured outputs, if configured. */
2139
- readonly output: OUTPUT | undefined;
2140
- /**
2141
- * Tool context.
2142
- */
2143
- readonly toolsContext: InferToolSetContext<TOOLS>;
2144
- /**
2145
- * User-defined runtime context.
2146
- */
2147
- readonly runtimeContext: RUNTIME_CONTEXT;
2162
+ /** Unique identifier for this generation call, used to correlate events. */
2163
+ readonly callId: string;
2164
+ /** Identifies the operation type (e.g. 'ai.generateText' or 'ai.streamText'). */
2165
+ readonly operationId: string;
2166
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
2167
+ readonly provider: string;
2168
+ /** The specific model identifier (e.g., 'gpt-4o'). */
2169
+ readonly modelId: string;
2170
+ /** The tools available for this generation. */
2171
+ readonly tools: TOOLS | undefined;
2172
+ /** The tool choice strategy for this generation. */
2173
+ readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
2174
+ /** Limits which tools are available for the model to call. */
2175
+ readonly activeTools: ActiveTools<TOOLS>;
2176
+ /** Controls the order in which tools are sent to the provider. */
2177
+ readonly toolOrder: ToolOrder<TOOLS>;
2178
+ /** Maximum number of retries for failed requests. */
2179
+ readonly maxRetries: number;
2180
+ /**
2181
+ * Timeout configuration for the generation.
2182
+ * Can be a number (milliseconds) or an object with totalMs, stepMs,
2183
+ * firstChunkMs (streaming only), chunkMs, toolMs, and per-tool overrides via tools.
2184
+ */
2185
+ readonly timeout: TimeoutConfiguration<TOOLS> | undefined;
2186
+ /** Additional HTTP headers sent with the request. */
2187
+ readonly headers: Record<string, string | undefined> | undefined;
2188
+ /** Additional provider-specific options. */
2189
+ readonly providerOptions: ProviderOptions | undefined;
2190
+ /** The output specification for structured outputs, if configured. */
2191
+ readonly output: OUTPUT | undefined;
2192
+ /**
2193
+ * Tool context.
2194
+ */
2195
+ readonly toolsContext: InferToolSetContext<TOOLS>;
2196
+ /**
2197
+ * User-defined runtime context.
2198
+ */
2199
+ readonly runtimeContext: RUNTIME_CONTEXT;
2148
2200
  } & LanguageModelCallOptions & StandardizedPrompt;
2149
2201
  /**
2150
2202
  * Event passed to the `onStepStart` callback.
@@ -2153,36 +2205,36 @@ type GenerateTextStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT ext
2153
2205
  * Each step represents a single LLM invocation.
2154
2206
  */
2155
2207
  type GenerateTextStepStartEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context = Context, OUTPUT extends Output = Output> = {
2156
- /** Unique identifier for this generation call, used to correlate events. */
2157
- readonly callId: string;
2158
- /** The provider identifier (e.g., 'openai', 'anthropic'). */
2159
- readonly provider: string;
2160
- /** The specific model identifier (e.g., 'gpt-4o'). */
2161
- readonly modelId: string;
2162
- /** Zero-based index of the current step. */
2163
- readonly stepNumber: number;
2164
- /** The tools available for this generation. */
2165
- readonly tools: TOOLS | undefined;
2166
- /** The tool choice configuration for this step. */
2167
- readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
2168
- /** Limits which tools are available for this step. */
2169
- readonly activeTools: ActiveTools<TOOLS>;
2170
- /** Controls the order in which tools are sent to the provider for this step. */
2171
- readonly toolOrder: ToolOrder<TOOLS>;
2172
- /** Array of results from previous steps (empty for first step). */
2173
- readonly steps: ReadonlyArray<StepResult<TOOLS, RUNTIME_CONTEXT>>;
2174
- /** Additional provider-specific options for this step. */
2175
- readonly providerOptions: ProviderOptions | undefined;
2176
- /** The output specification for structured outputs, if configured. */
2177
- readonly output: OUTPUT | undefined;
2178
- /**
2179
- * Runtime context. May be updated from `prepareStep` between steps.
2180
- */
2181
- readonly runtimeContext: RUNTIME_CONTEXT;
2182
- /**
2183
- * Tool context. May be updated from `prepareStep` between steps.
2184
- */
2185
- readonly toolsContext: InferToolSetContext<TOOLS>;
2208
+ /** Unique identifier for this generation call, used to correlate events. */
2209
+ readonly callId: string;
2210
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
2211
+ readonly provider: string;
2212
+ /** The specific model identifier (e.g., 'gpt-4o'). */
2213
+ readonly modelId: string;
2214
+ /** Zero-based index of the current step. */
2215
+ readonly stepNumber: number;
2216
+ /** The tools available for this generation. */
2217
+ readonly tools: TOOLS | undefined;
2218
+ /** The tool choice configuration for this step. */
2219
+ readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
2220
+ /** Limits which tools are available for this step. */
2221
+ readonly activeTools: ActiveTools<TOOLS>;
2222
+ /** Controls the order in which tools are sent to the provider for this step. */
2223
+ readonly toolOrder: ToolOrder<TOOLS>;
2224
+ /** Array of results from previous steps (empty for first step). */
2225
+ readonly steps: ReadonlyArray<StepResult<TOOLS, RUNTIME_CONTEXT>>;
2226
+ /** Additional provider-specific options for this step. */
2227
+ readonly providerOptions: ProviderOptions | undefined;
2228
+ /** The output specification for structured outputs, if configured. */
2229
+ readonly output: OUTPUT | undefined;
2230
+ /**
2231
+ * Runtime context. May be updated from `prepareStep` between steps.
2232
+ */
2233
+ readonly runtimeContext: RUNTIME_CONTEXT;
2234
+ /**
2235
+ * Tool context. May be updated from `prepareStep` between steps.
2236
+ */
2237
+ readonly toolsContext: InferToolSetContext<TOOLS>;
2186
2238
  } & StandardizedPrompt;
2187
2239
  /**
2188
2240
  * Event passed to the `onStepEnd` callback.
@@ -2198,94 +2250,94 @@ type GenerateTextStepEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT e
2198
2250
  * Includes the final step's result along with aggregated data from all steps.
2199
2251
  */
2200
2252
  type GenerateTextEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context = Context> = {
2201
- /** Unique identifier for this generation call, used to correlate events. */
2202
- readonly callId: string;
2203
- /** Zero-based index of the final step. */
2204
- readonly stepNumber: number;
2205
- /** Information about the model that produced the final step. */
2206
- readonly model: StepResult<TOOLS, RUNTIME_CONTEXT>['model'];
2207
- /**
2208
- * Tool context from the final step.
2209
- *
2210
- * @deprecated Use `finalStep.toolsContext` instead.
2211
- */
2212
- readonly toolsContext: InferToolSetContext<TOOLS>;
2213
- /**
2214
- * Runtime context from the final step.
2215
- *
2216
- * @deprecated Use `finalStep.runtimeContext` instead.
2217
- */
2218
- readonly runtimeContext: RUNTIME_CONTEXT;
2219
- /** The content that was generated in all steps. */
2220
- readonly content: StepResult<TOOLS, RUNTIME_CONTEXT>['content'];
2221
- /** The text that was generated in the final step. */
2222
- readonly text: StepResult<TOOLS, RUNTIME_CONTEXT>['text'];
2223
- /**
2224
- * The reasoning that was generated in the final step.
2225
- *
2226
- * @deprecated Use `finalStep.reasoning` instead.
2227
- */
2228
- readonly reasoning: StepResult<TOOLS, RUNTIME_CONTEXT>['reasoning'];
2229
- /**
2230
- * The reasoning text that was generated in the final step.
2231
- *
2232
- * @deprecated Use `finalStep.reasoningText` instead.
2233
- */
2234
- readonly reasoningText: StepResult<TOOLS, RUNTIME_CONTEXT>['reasoningText'];
2235
- /** Files that were generated in all steps. */
2236
- readonly files: StepResult<TOOLS, RUNTIME_CONTEXT>['files'];
2237
- /** Sources that were used as references in all steps. */
2238
- readonly sources: StepResult<TOOLS, RUNTIME_CONTEXT>['sources'];
2239
- /** Tool calls that were made in all steps. */
2240
- readonly toolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['toolCalls'];
2241
- /** Static tool calls that were made in all steps. */
2242
- readonly staticToolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['staticToolCalls'];
2243
- /** Dynamic tool calls that were made in all steps. */
2244
- readonly dynamicToolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['dynamicToolCalls'];
2245
- /** Tool results that were generated in all steps. */
2246
- readonly toolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['toolResults'];
2247
- /** Static tool results that were generated in all steps. */
2248
- readonly staticToolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['staticToolResults'];
2249
- /** Dynamic tool results that were generated in all steps. */
2250
- readonly dynamicToolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['dynamicToolResults'];
2251
- /** The unified reason why the generation finished. Taken from the final step. */
2252
- readonly finishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['finishReason'];
2253
- /** The raw reason why the generation finished. Taken from the final step. */
2254
- readonly rawFinishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['rawFinishReason'];
2255
- /** Aggregated token usage across all steps. */
2256
- readonly usage: LanguageModelUsage;
2257
- /**
2258
- * Aggregated token usage across all steps.
2259
- *
2260
- * @deprecated Use `usage` instead.
2261
- */
2262
- readonly totalUsage: LanguageModelUsage;
2263
- /** Warnings from the model provider in all steps. */
2264
- readonly warnings: StepResult<TOOLS, RUNTIME_CONTEXT>['warnings'];
2265
- /**
2266
- * Additional request information from the final step.
2267
- *
2268
- * @deprecated Use `finalStep.request` instead.
2269
- */
2270
- readonly request: StepResult<TOOLS, RUNTIME_CONTEXT>['request'];
2271
- /**
2272
- * Additional response information from the final step.
2273
- *
2274
- * @deprecated Use `finalStep.response` instead.
2275
- */
2276
- readonly response: StepResult<TOOLS, RUNTIME_CONTEXT>['response'];
2277
- /**
2278
- * Additional provider-specific metadata from the final step.
2279
- *
2280
- * @deprecated Use `finalStep.providerMetadata` instead.
2281
- */
2282
- readonly providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
2283
- /** The response messages that were generated during the call. */
2284
- readonly responseMessages: ResponseMessage[];
2285
- /** Array containing results from all steps in the generation. */
2286
- readonly steps: StepResult<TOOLS, RUNTIME_CONTEXT>[];
2287
- /** The final step. This is a shortcut for `steps.at(-1)`. */
2288
- readonly finalStep: StepResult<TOOLS, RUNTIME_CONTEXT>;
2253
+ /** Unique identifier for this generation call, used to correlate events. */
2254
+ readonly callId: string;
2255
+ /** Zero-based index of the final step. */
2256
+ readonly stepNumber: number;
2257
+ /** Information about the model that produced the final step. */
2258
+ readonly model: StepResult<TOOLS, RUNTIME_CONTEXT>['model'];
2259
+ /**
2260
+ * Tool context from the final step.
2261
+ *
2262
+ * @deprecated Use `finalStep.toolsContext` instead.
2263
+ */
2264
+ readonly toolsContext: InferToolSetContext<TOOLS>;
2265
+ /**
2266
+ * Runtime context from the final step.
2267
+ *
2268
+ * @deprecated Use `finalStep.runtimeContext` instead.
2269
+ */
2270
+ readonly runtimeContext: RUNTIME_CONTEXT;
2271
+ /** The content that was generated in all steps. */
2272
+ readonly content: StepResult<TOOLS, RUNTIME_CONTEXT>['content'];
2273
+ /** The text that was generated in the final step. */
2274
+ readonly text: StepResult<TOOLS, RUNTIME_CONTEXT>['text'];
2275
+ /**
2276
+ * The reasoning that was generated in the final step.
2277
+ *
2278
+ * @deprecated Use `finalStep.reasoning` instead.
2279
+ */
2280
+ readonly reasoning: StepResult<TOOLS, RUNTIME_CONTEXT>['reasoning'];
2281
+ /**
2282
+ * The reasoning text that was generated in the final step.
2283
+ *
2284
+ * @deprecated Use `finalStep.reasoningText` instead.
2285
+ */
2286
+ readonly reasoningText: StepResult<TOOLS, RUNTIME_CONTEXT>['reasoningText'];
2287
+ /** Files that were generated in all steps. */
2288
+ readonly files: StepResult<TOOLS, RUNTIME_CONTEXT>['files'];
2289
+ /** Sources that were used as references in all steps. */
2290
+ readonly sources: StepResult<TOOLS, RUNTIME_CONTEXT>['sources'];
2291
+ /** Tool calls that were made in all steps. */
2292
+ readonly toolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['toolCalls'];
2293
+ /** Static tool calls that were made in all steps. */
2294
+ readonly staticToolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['staticToolCalls'];
2295
+ /** Dynamic tool calls that were made in all steps. */
2296
+ readonly dynamicToolCalls: StepResult<TOOLS, RUNTIME_CONTEXT>['dynamicToolCalls'];
2297
+ /** Tool results that were generated in all steps. */
2298
+ readonly toolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['toolResults'];
2299
+ /** Static tool results that were generated in all steps. */
2300
+ readonly staticToolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['staticToolResults'];
2301
+ /** Dynamic tool results that were generated in all steps. */
2302
+ readonly dynamicToolResults: StepResult<TOOLS, RUNTIME_CONTEXT>['dynamicToolResults'];
2303
+ /** The unified reason why the generation finished. Taken from the final step. */
2304
+ readonly finishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['finishReason'];
2305
+ /** The raw reason why the generation finished. Taken from the final step. */
2306
+ readonly rawFinishReason: StepResult<TOOLS, RUNTIME_CONTEXT>['rawFinishReason'];
2307
+ /** Aggregated token usage across all steps. */
2308
+ readonly usage: LanguageModelUsage;
2309
+ /**
2310
+ * Aggregated token usage across all steps.
2311
+ *
2312
+ * @deprecated Use `usage` instead.
2313
+ */
2314
+ readonly totalUsage: LanguageModelUsage;
2315
+ /** Warnings from the model provider in all steps. */
2316
+ readonly warnings: StepResult<TOOLS, RUNTIME_CONTEXT>['warnings'];
2317
+ /**
2318
+ * Additional request information from the final step.
2319
+ *
2320
+ * @deprecated Use `finalStep.request` instead.
2321
+ */
2322
+ readonly request: StepResult<TOOLS, RUNTIME_CONTEXT>['request'];
2323
+ /**
2324
+ * Additional response information from the final step.
2325
+ *
2326
+ * @deprecated Use `finalStep.response` instead.
2327
+ */
2328
+ readonly response: StepResult<TOOLS, RUNTIME_CONTEXT>['response'];
2329
+ /**
2330
+ * Additional provider-specific metadata from the final step.
2331
+ *
2332
+ * @deprecated Use `finalStep.providerMetadata` instead.
2333
+ */
2334
+ readonly providerMetadata: StepResult<TOOLS, RUNTIME_CONTEXT>['providerMetadata'];
2335
+ /** The response messages that were generated during the call. */
2336
+ readonly responseMessages: ResponseMessage[];
2337
+ /** Array containing results from all steps in the generation. */
2338
+ readonly steps: StepResult<TOOLS, RUNTIME_CONTEXT>[];
2339
+ /** The final step. This is a shortcut for `steps.at(-1)`. */
2340
+ readonly finalStep: StepResult<TOOLS, RUNTIME_CONTEXT>;
2289
2341
  };
2290
2342
  /**
2291
2343
  * Event passed to an `onAbort` callback for text generation.
@@ -2294,12 +2346,12 @@ type GenerateTextEndEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT exten
2294
2346
  * completes.
2295
2347
  */
2296
2348
  type GenerateTextAbortEvent<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context = Context> = {
2297
- /** Unique identifier for this generation call, used to correlate events. */
2298
- readonly callId: string;
2299
- /** Details for all previously finished steps. */
2300
- readonly steps: StepResult<TOOLS, RUNTIME_CONTEXT>[];
2301
- /** The abort reason from the AbortSignal, when one is available. */
2302
- readonly reason?: unknown;
2349
+ /** Unique identifier for this generation call, used to correlate events. */
2350
+ readonly callId: string;
2351
+ /** Details for all previously finished steps. */
2352
+ readonly steps: StepResult<TOOLS, RUNTIME_CONTEXT>[];
2353
+ /** The abort reason from the AbortSignal, when one is available. */
2354
+ readonly reason?: unknown;
2303
2355
  };
2304
2356
  /**
2305
2357
  * Callback that is set using the `onStart` option.
@@ -2355,34 +2407,35 @@ type GenerateTextOnEndCallback<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT
2355
2407
  * @param event - The abort event, including finished steps and abort reason.
2356
2408
  */
2357
2409
  type GenerateTextOnAbortCallback<TOOLS extends ToolSet = ToolSet, RUNTIME_CONTEXT extends Context = Context> = Callback<GenerateTextAbortEvent<TOOLS, RUNTIME_CONTEXT>>;
2358
-
2410
+ //#endregion
2411
+ //#region src/rerank/rerank-events.d.ts
2359
2412
  /**
2360
2413
  * Event passed to the `onStart` callback for rerank operations.
2361
2414
  *
2362
2415
  * Called when the operation begins, before the reranking model is called.
2363
2416
  */
2364
2417
  type RerankStartEvent<RUNTIME_CONTEXT extends Context = Context> = {
2365
- /** User-defined runtime context. */
2366
- readonly runtimeContext: RUNTIME_CONTEXT;
2367
- /** Unique identifier for this rerank call, used to correlate events. */
2368
- readonly callId: string;
2369
- /** Identifies the operation type ('ai.rerank'). */
2370
- readonly operationId: string;
2371
- readonly provider: string;
2372
- /** The specific model identifier (e.g., 'gpt-4o'). */
2373
- readonly modelId: string;
2374
- /** The documents being reranked. */
2375
- readonly documents: Array<JSONObject | string>;
2376
- /** The query to rerank the documents against. */
2377
- readonly query: string;
2378
- /** Number of top documents to return. */
2379
- readonly topN: number | undefined;
2380
- /** Maximum number of retries for failed requests. */
2381
- readonly maxRetries: number;
2382
- /** Additional HTTP headers sent with the request. */
2383
- readonly headers: Record<string, string | undefined> | undefined;
2384
- /** Additional provider-specific options. */
2385
- readonly providerOptions: ProviderOptions | undefined;
2418
+ /** User-defined runtime context. */
2419
+ readonly runtimeContext: RUNTIME_CONTEXT;
2420
+ /** Unique identifier for this rerank call, used to correlate events. */
2421
+ readonly callId: string;
2422
+ /** Identifies the operation type ('ai.rerank'). */
2423
+ readonly operationId: string;
2424
+ readonly provider: string;
2425
+ /** The specific model identifier (e.g., 'gpt-4o'). */
2426
+ readonly modelId: string;
2427
+ /** The documents being reranked. */
2428
+ readonly documents: Array<JSONObject | string>;
2429
+ /** The query to rerank the documents against. */
2430
+ readonly query: string;
2431
+ /** Number of top documents to return. */
2432
+ readonly topN: number | undefined;
2433
+ /** Maximum number of retries for failed requests. */
2434
+ readonly maxRetries: number;
2435
+ /** Additional HTTP headers sent with the request. */
2436
+ readonly headers: Record<string, string | undefined> | undefined;
2437
+ /** Additional provider-specific options. */
2438
+ readonly providerOptions: ProviderOptions | undefined;
2386
2439
  };
2387
2440
  /**
2388
2441
  * Event passed to the `onEnd` callback for rerank operations.
@@ -2390,58 +2443,58 @@ type RerankStartEvent<RUNTIME_CONTEXT extends Context = Context> = {
2390
2443
  * Called when the operation completes, after the reranking model returns.
2391
2444
  */
2392
2445
  type RerankEndEvent<RUNTIME_CONTEXT extends Context = Context> = {
2393
- /** User-defined runtime context. */
2394
- readonly runtimeContext: RUNTIME_CONTEXT;
2395
- /** Unique identifier for this rerank call, used to correlate events. */
2396
- readonly callId: string;
2397
- /** Identifies the operation type ('ai.rerank'). */
2398
- readonly operationId: string;
2399
- readonly provider: string;
2400
- /** The specific model identifier (e.g., 'gpt-4o'). */
2401
- readonly modelId: string;
2402
- /** The documents that were reranked. */
2403
- readonly documents: Array<JSONObject | string>;
2404
- /** The query that documents were reranked against. */
2405
- readonly query: string;
2406
- /** The reranked results sorted by relevance score in descending order. */
2407
- readonly ranking: Array<{
2408
- originalIndex: number;
2409
- score: number;
2410
- document: JSONObject | string;
2411
- }>;
2412
- /** Warnings from the reranking model. */
2413
- readonly warnings: Array<Warning>;
2414
- /** Optional provider-specific metadata. */
2415
- readonly providerMetadata: ProviderMetadata | undefined;
2416
- /** Response data including headers and body. */
2417
- readonly response: {
2418
- id?: string;
2419
- timestamp: Date;
2420
- modelId: string;
2421
- headers?: Record<string, string>;
2422
- body?: unknown;
2423
- };
2446
+ /** User-defined runtime context. */
2447
+ readonly runtimeContext: RUNTIME_CONTEXT;
2448
+ /** Unique identifier for this rerank call, used to correlate events. */
2449
+ readonly callId: string;
2450
+ /** Identifies the operation type ('ai.rerank'). */
2451
+ readonly operationId: string;
2452
+ readonly provider: string;
2453
+ /** The specific model identifier (e.g., 'gpt-4o'). */
2454
+ readonly modelId: string;
2455
+ /** The documents that were reranked. */
2456
+ readonly documents: Array<JSONObject | string>;
2457
+ /** The query that documents were reranked against. */
2458
+ readonly query: string;
2459
+ /** The reranked results sorted by relevance score in descending order. */
2460
+ readonly ranking: Array<{
2461
+ originalIndex: number;
2462
+ score: number;
2463
+ document: JSONObject | string;
2464
+ }>;
2465
+ /** Warnings from the reranking model. */
2466
+ readonly warnings: Array<Warning>;
2467
+ /** Optional provider-specific metadata. */
2468
+ readonly providerMetadata: ProviderMetadata | undefined;
2469
+ /** Response data including headers and body. */
2470
+ readonly response: {
2471
+ id?: string;
2472
+ timestamp: Date;
2473
+ modelId: string;
2474
+ headers?: Record<string, string>;
2475
+ body?: unknown;
2476
+ };
2424
2477
  };
2425
2478
  /**
2426
2479
  * Event fired when an individual reranking model call (inner doRerank) begins.
2427
2480
  */
2428
2481
  type RerankingModelCallStartEvent = {
2429
- /** Unique identifier for this rerank call, used to correlate events. */
2430
- readonly callId: string;
2431
- /** Identifies the inner operation ('ai.rerank.doRerank'). */
2432
- readonly operationId: string;
2433
- /** The provider identifier. */
2434
- readonly provider: string;
2435
- /** The specific model identifier. */
2436
- readonly modelId: string;
2437
- /** The documents being reranked. */
2438
- readonly documents: Array<JSONObject | string>;
2439
- /** The type of documents ('text' or 'object'). */
2440
- readonly documentsType: string;
2441
- /** The query to rerank against. */
2442
- readonly query: string;
2443
- /** Number of top documents to return. */
2444
- readonly topN: number | undefined;
2482
+ /** Unique identifier for this rerank call, used to correlate events. */
2483
+ readonly callId: string;
2484
+ /** Identifies the inner operation ('ai.rerank.doRerank'). */
2485
+ readonly operationId: string;
2486
+ /** The provider identifier. */
2487
+ readonly provider: string;
2488
+ /** The specific model identifier. */
2489
+ readonly modelId: string;
2490
+ /** The documents being reranked. */
2491
+ readonly documents: Array<JSONObject | string>;
2492
+ /** The type of documents ('text' or 'object'). */
2493
+ readonly documentsType: string;
2494
+ /** The query to rerank against. */
2495
+ readonly query: string;
2496
+ /** Number of top documents to return. */
2497
+ readonly topN: number | undefined;
2445
2498
  };
2446
2499
  /**
2447
2500
  * Event fired when an individual reranking model call (doRerank) completes.
@@ -2449,330 +2502,497 @@ type RerankingModelCallStartEvent = {
2449
2502
  * Contains the ranking results from the model response.
2450
2503
  */
2451
2504
  type RerankingModelCallEndEvent = {
2452
- /** Unique identifier for this rerank call, used to correlate events. */
2453
- readonly callId: string;
2454
- /** Identifies the inner operation ('ai.rerank.doRerank'). */
2455
- readonly operationId: string;
2456
- /** The provider identifier. */
2457
- readonly provider: string;
2458
- /** The specific model identifier. */
2459
- readonly modelId: string;
2460
- /** The type of documents ('text' or 'object'). */
2461
- readonly documentsType: string;
2462
- /** The ranking results from the model. */
2463
- readonly ranking: Array<{
2464
- index: number;
2465
- relevanceScore: number;
2466
- }>;
2467
- };
2468
-
2469
- type TelemetryTracingEventType = 'generateText' | 'streamText' | 'step' | 'languageModelCall' | 'executeTool' | 'embed' | 'embedMany' | 'rerank' | 'experimental_evaluate';
2470
-
2505
+ /** Unique identifier for this rerank call, used to correlate events. */
2506
+ readonly callId: string;
2507
+ /** Identifies the inner operation ('ai.rerank.doRerank'). */
2508
+ readonly operationId: string;
2509
+ /** The provider identifier. */
2510
+ readonly provider: string;
2511
+ /** The specific model identifier. */
2512
+ readonly modelId: string;
2513
+ /** The type of documents ('text' or 'object'). */
2514
+ readonly documentsType: string;
2515
+ /** The ranking results from the model. */
2516
+ readonly ranking: Array<{
2517
+ index: number;
2518
+ relevanceScore: number;
2519
+ }>;
2520
+ };
2521
+ //#endregion
2522
+ //#region src/generate-speech/speech-events.d.ts
2523
+ /**
2524
+ * Event passed to telemetry integrations when speech generation begins.
2525
+ */
2526
+ type GenerateSpeechStartEvent = {
2527
+ /** Unique identifier for this speech generation call. */
2528
+ readonly callId: string;
2529
+ /** Identifies the operation type (`ai.generateSpeech`). */
2530
+ readonly operationId: 'ai.generateSpeech';
2531
+ /** The provider identifier. */
2532
+ readonly provider: string;
2533
+ /** The specific model identifier. */
2534
+ readonly modelId: string;
2535
+ /** The text to convert to speech. */
2536
+ readonly text: string;
2537
+ /** The requested voice. */
2538
+ readonly voice: string | undefined;
2539
+ /** The requested output format. */
2540
+ readonly outputFormat: string | undefined;
2541
+ /** Additional speech instructions. */
2542
+ readonly instructions: string | undefined;
2543
+ /** The requested speech speed. */
2544
+ readonly speed: number | undefined;
2545
+ /** The requested language. */
2546
+ readonly language: string | undefined;
2547
+ /** Maximum number of retries for failed requests. */
2548
+ readonly maxRetries: number;
2549
+ /** Additional HTTP headers sent with the request. */
2550
+ readonly headers: Record<string, string> | undefined;
2551
+ /** Additional provider-specific options. */
2552
+ readonly providerOptions: ProviderOptions;
2553
+ };
2554
+ /**
2555
+ * Event passed to telemetry integrations when speech generation completes.
2556
+ *
2557
+ * Raw audio is intentionally not included. Integrations receive only its size,
2558
+ * media type, and format.
2559
+ */
2560
+ type GenerateSpeechEndEvent = {
2561
+ /** Unique identifier for this speech generation call. */
2562
+ readonly callId: string;
2563
+ /** Identifies the operation type (`ai.generateSpeech`). */
2564
+ readonly operationId: 'ai.generateSpeech';
2565
+ /** The provider identifier. */
2566
+ readonly provider: string;
2567
+ /** The specific model identifier. */
2568
+ readonly modelId: string;
2569
+ /** The text that was converted to speech. */
2570
+ readonly text: string;
2571
+ /** Metadata about the generated audio. */
2572
+ readonly audio: {
2573
+ readonly byteLength: number;
2574
+ readonly mediaType: string;
2575
+ readonly format: string;
2576
+ };
2577
+ /** Usage reported by the provider, when available. */
2578
+ readonly usage: JSONObject | undefined;
2579
+ /** Warnings from the speech model. */
2580
+ readonly warnings: Array<Warning>;
2581
+ /** Optional provider-specific metadata. */
2582
+ readonly providerMetadata: ProviderMetadata | undefined;
2583
+ /** Response metadata from the provider. */
2584
+ readonly response: SpeechModelResponseMetadata;
2585
+ };
2586
+ //#endregion
2587
+ //#region src/transcribe/transcription-events.d.ts
2588
+ /**
2589
+ * Event passed to telemetry integrations when transcription begins.
2590
+ */
2591
+ type TranscriptionStartEventFor<OPERATION_ID extends string> = {
2592
+ /** Unique identifier for this transcription call. */
2593
+ readonly callId: string;
2594
+ /** Identifies the operation type (`ai.transcribe` or `ai.streamTranscribe`). */
2595
+ readonly operationId: OPERATION_ID;
2596
+ /** The provider identifier. */
2597
+ readonly provider: string;
2598
+ /** The specific model identifier. */
2599
+ readonly modelId: string;
2600
+ /**
2601
+ * Metadata about the input audio. The byte length is known immediately for
2602
+ * non-streaming transcription and is reported on the end event for streams.
2603
+ */
2604
+ readonly audio: {
2605
+ readonly byteLength: number | undefined;
2606
+ /**
2607
+ * The media type, when it is known before input preparation completes.
2608
+ * URL downloads and invalid inline inputs can begin without this metadata.
2609
+ */
2610
+ readonly mediaType: string | undefined;
2611
+ };
2612
+ /** The raw input format for streaming transcription. */
2613
+ readonly inputAudioFormat: SharedV4AudioFormat | undefined;
2614
+ /** Maximum number of retries for non-streaming transcription. */
2615
+ readonly maxRetries: number | undefined;
2616
+ /** Additional HTTP or WebSocket headers sent with the request. */
2617
+ readonly headers: Record<string, string> | undefined;
2618
+ /** Additional provider-specific options. */
2619
+ readonly providerOptions: ProviderOptions;
2620
+ };
2621
+ type TranscriptionStartEvent = TranscriptionStartEventFor<'ai.transcribe'>;
2622
+ type StreamTranscriptionStartEvent = TranscriptionStartEventFor<'ai.streamTranscribe'>;
2623
+ /**
2624
+ * Event passed to telemetry integrations when transcription completes.
2625
+ *
2626
+ * Raw audio is intentionally not included.
2627
+ */
2628
+ type TranscriptionEndEventFor<OPERATION_ID extends string> = {
2629
+ /** Unique identifier for this transcription call. */
2630
+ readonly callId: string;
2631
+ /** Identifies the operation type (`ai.transcribe` or `ai.streamTranscribe`). */
2632
+ readonly operationId: OPERATION_ID;
2633
+ /** The provider identifier. */
2634
+ readonly provider: string;
2635
+ /** The specific model identifier. */
2636
+ readonly modelId: string;
2637
+ /** Metadata about the input audio. */
2638
+ readonly audio: {
2639
+ readonly byteLength: number;
2640
+ readonly mediaType: string;
2641
+ };
2642
+ /** The complete transcript. */
2643
+ readonly text: string;
2644
+ /** Transcript segments with timing information. */
2645
+ readonly segments: Array<{
2646
+ readonly text: string;
2647
+ readonly startSecond: number;
2648
+ readonly endSecond: number;
2649
+ }>;
2650
+ /** The detected language. */
2651
+ readonly language: string | undefined;
2652
+ /** The duration of the input audio, when available. */
2653
+ readonly durationInSeconds: number | undefined;
2654
+ /** Usage reported by the provider, when available. */
2655
+ readonly usage: JSONObject | undefined;
2656
+ /** Warnings from the transcription model. */
2657
+ readonly warnings: Array<Warning>;
2658
+ /** Optional provider-specific metadata. */
2659
+ readonly providerMetadata: ProviderMetadata | undefined;
2660
+ /** Response metadata from the provider. */
2661
+ readonly response: TranscriptionModelResponseMetadata;
2662
+ };
2663
+ type TranscriptionEndEvent = TranscriptionEndEventFor<'ai.transcribe'>;
2664
+ type StreamTranscriptionEndEvent = TranscriptionEndEventFor<'ai.streamTranscribe'>;
2665
+ //#endregion
2666
+ //#region src/telemetry/tracing-channel.d.ts
2667
+ type TelemetryTracingEventType = 'generateText' | 'streamText' | 'step' | 'languageModelCall' | 'executeTool' | 'embed' | 'embedMany' | 'rerank' | 'generateSpeech' | 'transcribe' | 'streamTranscribe' | 'experimental_evaluate';
2668
+ //#endregion
2669
+ //#region src/telemetry/tracing-channel-publisher.d.ts
2471
2670
  type TracingChannelContext = {
2472
- run<T>(execute: () => T): T;
2671
+ run<T>(execute: () => T): T;
2473
2672
  };
2474
-
2673
+ //#endregion
2674
+ //#region src/telemetry/telemetry.d.ts
2475
2675
  type InferTelemetryEvent<EVENT> = EVENT & Omit<TelemetryOptions, 'integrations' | 'isEnabled' | 'includeRuntimeContext'>;
2476
- type OperationStartEvent = GenerateTextStartEvent | GenerateObjectStartEvent | EmbedStartEvent | RerankStartEvent;
2477
- type OperationEndEvent = GenerateTextEndEvent<ToolSet> | GenerateObjectEndEvent<unknown> | EmbedEndEvent | RerankEndEvent;
2676
+ type BivariantCallback<EVENT> = {
2677
+ bivarianceHack(event: EVENT): PromiseLike<void> | void;
2678
+ }['bivarianceHack'];
2679
+ type OperationStartEvent = GenerateTextStartEvent | GenerateObjectStartEvent | EmbedStartEvent | RerankStartEvent | GenerateSpeechStartEvent | TranscriptionStartEvent;
2680
+ type OperationEndEvent = GenerateTextEndEvent<ToolSet> | GenerateObjectEndEvent<unknown> | EmbedEndEvent | RerankEndEvent | GenerateSpeechEndEvent | TranscriptionEndEvent;
2478
2681
  interface TelemetryDispatcher {
2479
- /**
2480
- * Runs awaited work inside a diagnostics-channel tracing span.
2481
- */
2482
- runInTracingChannelSpan?: <T>(options: {
2483
- type: TelemetryTracingEventType;
2484
- event: unknown;
2485
- execute: () => PromiseLike<T>;
2486
- }) => Promise<T>;
2487
- /**
2488
- * Opens a tracing span context whose completion is observed separately.
2489
- * This is used by streamed operations that must preserve stream timing while
2490
- * still creating child spans with the correct parent.
2491
- */
2492
- startTracingChannelContext?: (options: {
2493
- type: TelemetryTracingEventType;
2494
- event: unknown;
2495
- completion: PromiseLike<unknown>;
2496
- }) => TracingChannelContext | undefined;
2497
- onStart?: Callback<OperationStartEvent>;
2498
- onStepStart?: Callback<GenerateTextStepStartEvent>;
2499
- onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
2500
- onLanguageModelCallEnd?: OnLanguageModelCallEndCallback;
2501
- onToolExecutionStart?: Callback<ToolExecutionStartEvent>;
2502
- onToolExecutionEnd?: Callback<ToolExecutionEndEvent>;
2503
- onStepEnd?: Callback<GenerateTextStepEndEvent>;
2504
- /** @deprecated Use `onStepEnd` instead. */
2505
- onStepFinish?: Callback<GenerateTextStepEndEvent>;
2506
- onObjectStepStart?: Callback<GenerateObjectStepStartEvent>;
2507
- onObjectStepEnd?: Callback<GenerateObjectStepEndEvent>;
2508
- onEmbedStart?: Callback<EmbeddingModelCallStartEvent>;
2509
- onEmbedEnd?: Callback<EmbeddingModelCallEndEvent>;
2510
- onRerankStart?: Callback<RerankingModelCallStartEvent>;
2511
- onRerankEnd?: Callback<RerankingModelCallEndEvent>;
2512
- experimental_onEvaluateStart?: Callback<EvaluateStartEvent>;
2513
- experimental_onEvaluationModelCallStart?: Callback<EvaluationModelCallStartEvent>;
2514
- experimental_onEvaluationModelCallEnd?: Callback<EvaluationModelCallEndEvent>;
2515
- experimental_onEvaluateEnd?: Callback<EvaluateEndEvent>;
2516
- onEnd?: Callback<OperationEndEvent>;
2517
- onAbort?: Callback<GenerateTextAbortEvent<ToolSet>>;
2518
- onError?: Callback<unknown>;
2519
- executeLanguageModelCall?: Telemetry['executeLanguageModelCall'];
2520
- executeTool?: Telemetry['executeTool'];
2682
+ /**
2683
+ * Runs awaited work inside a diagnostics-channel tracing span.
2684
+ */
2685
+ runInTracingChannelSpan?: <T>(options: {
2686
+ type: TelemetryTracingEventType;
2687
+ event: unknown;
2688
+ execute: () => PromiseLike<T>;
2689
+ }) => Promise<T>;
2690
+ /**
2691
+ * Opens a tracing span context whose completion is observed separately.
2692
+ * This is used by streamed operations that must preserve stream timing while
2693
+ * still creating child spans with the correct parent.
2694
+ */
2695
+ startTracingChannelContext?: (options: {
2696
+ type: TelemetryTracingEventType;
2697
+ event: unknown;
2698
+ completion: PromiseLike<unknown>;
2699
+ }) => TracingChannelContext | undefined;
2700
+ onStart?: Callback<OperationStartEvent>;
2701
+ onStepStart?: Callback<GenerateTextStepStartEvent>;
2702
+ onLanguageModelCallStart?: OnLanguageModelCallStartCallback;
2703
+ onLanguageModelCallEnd?: OnLanguageModelCallEndCallback;
2704
+ onToolExecutionStart?: Callback<ToolExecutionStartEvent>;
2705
+ onToolExecutionEnd?: Callback<ToolExecutionEndEvent>;
2706
+ onStepEnd?: Callback<GenerateTextStepEndEvent>;
2707
+ /** @deprecated Use `onStepEnd` instead. */
2708
+ onStepFinish?: Callback<GenerateTextStepEndEvent>;
2709
+ onObjectStepStart?: Callback<GenerateObjectStepStartEvent>;
2710
+ onObjectStepEnd?: Callback<GenerateObjectStepEndEvent>;
2711
+ onEmbedStart?: Callback<EmbeddingModelCallStartEvent>;
2712
+ onEmbedEnd?: Callback<EmbeddingModelCallEndEvent>;
2713
+ onRerankStart?: Callback<RerankingModelCallStartEvent>;
2714
+ onRerankEnd?: Callback<RerankingModelCallEndEvent>;
2715
+ experimental_onEvaluateStart?: Callback<EvaluateStartEvent>;
2716
+ experimental_onEvaluationModelCallStart?: Callback<EvaluationModelCallStartEvent>;
2717
+ experimental_onEvaluationModelCallEnd?: Callback<EvaluationModelCallEndEvent>;
2718
+ experimental_onEvaluateEnd?: Callback<EvaluateEndEvent>;
2719
+ experimental_onStreamTranscriptionStart?: Callback<StreamTranscriptionStartEvent>;
2720
+ experimental_onStreamTranscriptionEnd?: Callback<StreamTranscriptionEndEvent>;
2721
+ onEnd?: Callback<OperationEndEvent>;
2722
+ onAbort?: Callback<GenerateTextAbortEvent<ToolSet>>;
2723
+ onError?: Callback<unknown>;
2724
+ executeLanguageModelCall?: Telemetry['executeLanguageModelCall'];
2725
+ executeTool?: Telemetry['executeTool'];
2521
2726
  }
2522
2727
  /**
2523
2728
  * Implement this interface to create custom telemetry integrations.
2524
2729
  * Methods can be sync or return a PromiseLike.
2525
2730
  */
2526
2731
  interface Telemetry {
2527
- /**
2528
- * Called when an operation begins. Fired for text generation
2529
- * (generateText/streamText), object generation (generateObject/streamObject),
2530
- * embedding (embed/embedMany), and reranking operations.
2531
- *
2532
- * Use the `operationId` field to distinguish between operation types.
2533
- */
2534
- onStart?: Callback<InferTelemetryEvent<OperationStartEvent>>;
2535
- /**
2536
- * Called when an individual step (single LLM invocation) begins.
2537
- * A generation may consist of multiple steps (e.g. when tool calls trigger
2538
- * follow-up LLM calls). Use this to create per-step spans or record
2539
- * step-level inputs.
2540
- *
2541
- * The event includes the step number, accumulated previous step results,
2542
- * and the messages that will be sent to the model.
2543
- */
2544
- onStepStart?: Callback<InferTelemetryEvent<GenerateTextStepStartEvent>>;
2545
- /**
2546
- * Called immediately before the provider model call begins.
2547
- * Unlike `onStepStart`, this callback is scoped to model work only and
2548
- * excludes any later client-side tool execution.
2549
- */
2550
- onLanguageModelCallStart?: Callback<InferTelemetryEvent<LanguageModelCallStartEvent>>;
2551
- /**
2552
- * Called after the model response has been normalized and parsed, but before
2553
- * any client-side tool execution begins.
2554
- */
2555
- onLanguageModelCallEnd?: Callback<InferTelemetryEvent<LanguageModelCallEndEvent>>;
2556
- /**
2557
- * Called when a tool execution begins, before the tool's `execute` function
2558
- * is invoked. Use this to create tool-level spans or log tool invocations.
2559
- */
2560
- onToolExecutionStart?: Callback<InferTelemetryEvent<ToolExecutionStartEvent>>;
2561
- /**
2562
- * Called when a tool execution completes, either successfully or with an error.
2563
- * The event uses a discriminated union on the `success` field — check
2564
- * `event.success` to determine whether `output` or `error` is available.
2565
- *
2566
- * The event includes execution time (`toolExecutionMs`) for performance tracking.
2567
- */
2568
- onToolExecutionEnd?: Callback<InferTelemetryEvent<ToolExecutionEndEvent>>;
2569
- /**
2570
- * Called when an individual step (single LLM invocation) completes.
2571
- * The event is a `StepResult` containing the model's response, tool calls
2572
- * and results, usage statistics, finish reason, and optional request/response
2573
- * bodies.
2574
- */
2575
- onStepEnd?: Callback<InferTelemetryEvent<GenerateTextStepEndEvent>>;
2576
- /**
2577
- * Called when an individual step (single LLM invocation) completes.
2578
- *
2579
- * @deprecated Use `onStepEnd` instead.
2580
- */
2581
- onStepFinish?: Callback<InferTelemetryEvent<GenerateTextStepEndEvent>>;
2582
- /**
2583
- * Called when an object generation step (single LLM invocation) begins.
2584
- * For generateObject/streamObject there is always exactly one step.
2585
- *
2586
- * @deprecated
2587
- */
2588
- onObjectStepStart?: Callback<InferTelemetryEvent<GenerateObjectStepStartEvent>>;
2589
- /**
2590
- * Called when an object generation step (single LLM invocation) completes,
2591
- * with the raw result before JSON parsing and schema validation.
2592
- *
2593
- * @deprecated
2594
- */
2595
- onObjectStepEnd?: Callback<InferTelemetryEvent<GenerateObjectStepEndEvent>>;
2596
- /**
2597
- * Called when an individual embedding model call (doEmbed) begins.
2598
- * For `embed`, there is one call. For `embedMany`, there may be multiple
2599
- * calls when values are chunked.
2600
- */
2601
- onEmbedStart?: Callback<InferTelemetryEvent<EmbeddingModelCallStartEvent>>;
2602
- /**
2603
- * Called when an individual embedding model call (doEmbed) completes.
2604
- * Contains the embeddings, usage, and any warnings from the model response.
2605
- */
2606
- onEmbedEnd?: Callback<InferTelemetryEvent<EmbeddingModelCallEndEvent>>;
2607
- /**
2608
- * Called when an individual reranking model call (doRerank) begins.
2609
- * There is one call per `rerank` invocation.
2610
- */
2611
- onRerankStart?: Callback<InferTelemetryEvent<RerankingModelCallStartEvent>>;
2612
- /**
2613
- * Called when an individual reranking model call (doRerank) completes.
2614
- * Contains the ranking results from the model response.
2615
- */
2616
- onRerankEnd?: Callback<InferTelemetryEvent<RerankingModelCallEndEvent>>;
2617
- /** Called when an experimental evaluation operation begins. */
2618
- experimental_onEvaluateStart?: Callback<InferTelemetryEvent<EvaluateStartEvent>>;
2619
- /**
2620
- * Called immediately before an experimental evaluation model call begins.
2621
- * The logical model call includes any provider retries.
2622
- */
2623
- experimental_onEvaluationModelCallStart?: Callback<InferTelemetryEvent<EvaluationModelCallStartEvent>>;
2624
- /**
2625
- * Called after an experimental evaluation model response has been validated.
2626
- * The logical model call includes any provider retries.
2627
- */
2628
- experimental_onEvaluationModelCallEnd?: Callback<InferTelemetryEvent<EvaluationModelCallEndEvent>>;
2629
- /** Called when an experimental evaluation operation completes. */
2630
- experimental_onEvaluateEnd?: Callback<InferTelemetryEvent<EvaluateEndEvent>>;
2631
- /**
2632
- * Called when an operation completes. Fired for text generation
2633
- * (generateText/streamText), object generation (generateObject/streamObject),
2634
- * embedding (embed/embedMany), and reranking operations.
2635
- *
2636
- * Use the event shape or `operationId` to distinguish between operation types.
2637
- */
2638
- onEnd?: Callback<InferTelemetryEvent<OperationEndEvent>>;
2639
- /**
2640
- * Called when a streaming text generation operation is aborted before it
2641
- * completes.
2642
- */
2643
- onAbort?: Callback<InferTelemetryEvent<GenerateTextAbortEvent<ToolSet>>>;
2644
- /**
2645
- * Called when an unrecoverable error occurs during the generation lifecycle.
2646
- * The error value is untyped — it may be an `Error` instance, an `AISDKError`,
2647
- * or any thrown value.
2648
- *
2649
- * Use this to record error details on telemetry spans and set error status.
2650
- */
2651
- onError?: Callback<unknown>;
2652
- /**
2653
- * Optionally runs the language model call in a telemetry-integration-specific context. This enables
2654
- * auto-instrumented model provider requests to become children of the current
2655
- * model-call span.
2656
- *
2657
- * The options carry the model-call start-event content as context (the event
2658
- * fields are optional), alongside the always-present `callId` and the
2659
- * `execute` function that performs the model call.
2660
- */
2661
- executeLanguageModelCall?: <T>(options: Partial<InferTelemetryEvent<LanguageModelCallStartEvent>> & {
2662
- callId: string;
2663
- execute: () => PromiseLike<T>;
2664
- }) => PromiseLike<T>;
2665
- /**
2666
- * Optionally runs the tool execute function in a telemetry-integration-specific context. This enables
2667
- * nested traces — e.g. when a tool's `execute` function calls `generateText`,
2668
- * the inner call's spans become children of the tool span.
2669
- *
2670
- * The options carry the tool-execution start-event content as context (the
2671
- * event fields are optional), alongside the always-present `callId`,
2672
- * `toolCallId`, and the `execute` function to run.
2673
- */
2674
- executeTool?: <T>(options: Partial<InferTelemetryEvent<ToolExecutionStartEvent>> & {
2675
- callId: string;
2676
- toolCallId: string;
2677
- execute: () => PromiseLike<T>;
2678
- }) => PromiseLike<T>;
2732
+ /**
2733
+ * Called when an operation begins. Fired for text generation
2734
+ * (generateText/streamText), object generation (generateObject/streamObject),
2735
+ * embedding (embed/embedMany), reranking, speech generation, and
2736
+ * non-streaming transcription operations.
2737
+ *
2738
+ * Use the `operationId` field to distinguish between operation types.
2739
+ */
2740
+ onStart?: BivariantCallback<InferTelemetryEvent<OperationStartEvent>>;
2741
+ /**
2742
+ * Called when an individual step (single LLM invocation) begins.
2743
+ * A generation may consist of multiple steps (e.g. when tool calls trigger
2744
+ * follow-up LLM calls). Use this to create per-step spans or record
2745
+ * step-level inputs.
2746
+ *
2747
+ * The event includes the step number, accumulated previous step results,
2748
+ * and the messages that will be sent to the model.
2749
+ */
2750
+ onStepStart?: Callback<InferTelemetryEvent<GenerateTextStepStartEvent>>;
2751
+ /**
2752
+ * Called immediately before the provider model call begins.
2753
+ * Unlike `onStepStart`, this callback is scoped to model work only and
2754
+ * excludes any later client-side tool execution.
2755
+ */
2756
+ onLanguageModelCallStart?: Callback<InferTelemetryEvent<LanguageModelCallStartEvent>>;
2757
+ /**
2758
+ * Called after the model response has been normalized and parsed, but before
2759
+ * any client-side tool execution begins.
2760
+ */
2761
+ onLanguageModelCallEnd?: Callback<InferTelemetryEvent<LanguageModelCallEndEvent>>;
2762
+ /**
2763
+ * Called when a tool execution begins, before the tool's `execute` function
2764
+ * is invoked. Use this to create tool-level spans or log tool invocations.
2765
+ */
2766
+ onToolExecutionStart?: Callback<InferTelemetryEvent<ToolExecutionStartEvent>>;
2767
+ /**
2768
+ * Called when a tool execution completes, either successfully or with an error.
2769
+ * The event uses a discriminated union on the `success` field — check
2770
+ * `event.success` to determine whether `output` or `error` is available.
2771
+ *
2772
+ * The event includes execution time (`toolExecutionMs`) for performance tracking.
2773
+ */
2774
+ onToolExecutionEnd?: Callback<InferTelemetryEvent<ToolExecutionEndEvent>>;
2775
+ /**
2776
+ * Called when an individual step (single LLM invocation) completes.
2777
+ * The event is a `StepResult` containing the model's response, tool calls
2778
+ * and results, usage statistics, finish reason, and optional request/response
2779
+ * bodies.
2780
+ */
2781
+ onStepEnd?: Callback<InferTelemetryEvent<GenerateTextStepEndEvent>>;
2782
+ /**
2783
+ * Called when an individual step (single LLM invocation) completes.
2784
+ *
2785
+ * @deprecated Use `onStepEnd` instead.
2786
+ */
2787
+ onStepFinish?: Callback<InferTelemetryEvent<GenerateTextStepEndEvent>>;
2788
+ /**
2789
+ * Called when an object generation step (single LLM invocation) begins.
2790
+ * For generateObject/streamObject there is always exactly one step.
2791
+ *
2792
+ * @deprecated
2793
+ */
2794
+ onObjectStepStart?: Callback<InferTelemetryEvent<GenerateObjectStepStartEvent>>;
2795
+ /**
2796
+ * Called when an object generation step (single LLM invocation) completes,
2797
+ * with the raw result before JSON parsing and schema validation.
2798
+ *
2799
+ * @deprecated
2800
+ */
2801
+ onObjectStepEnd?: Callback<InferTelemetryEvent<GenerateObjectStepEndEvent>>;
2802
+ /**
2803
+ * Called when an individual embedding model call (doEmbed) begins.
2804
+ * For `embed`, there is one call. For `embedMany`, there may be multiple
2805
+ * calls when values are chunked.
2806
+ */
2807
+ onEmbedStart?: Callback<InferTelemetryEvent<EmbeddingModelCallStartEvent>>;
2808
+ /**
2809
+ * Called when an individual embedding model call (doEmbed) completes.
2810
+ * Contains the embeddings, usage, and any warnings from the model response.
2811
+ */
2812
+ onEmbedEnd?: Callback<InferTelemetryEvent<EmbeddingModelCallEndEvent>>;
2813
+ /**
2814
+ * Called when an individual reranking model call (doRerank) begins.
2815
+ * There is one call per `rerank` invocation.
2816
+ */
2817
+ onRerankStart?: Callback<InferTelemetryEvent<RerankingModelCallStartEvent>>;
2818
+ /**
2819
+ * Called when an individual reranking model call (doRerank) completes.
2820
+ * Contains the ranking results from the model response.
2821
+ */
2822
+ onRerankEnd?: Callback<InferTelemetryEvent<RerankingModelCallEndEvent>>;
2823
+ /** Called when an experimental evaluation operation begins. */
2824
+ experimental_onEvaluateStart?: Callback<InferTelemetryEvent<EvaluateStartEvent>>;
2825
+ /**
2826
+ * Called immediately before an experimental evaluation model call begins.
2827
+ * The logical model call includes any provider retries.
2828
+ */
2829
+ experimental_onEvaluationModelCallStart?: Callback<InferTelemetryEvent<EvaluationModelCallStartEvent>>;
2830
+ /**
2831
+ * Called after an experimental evaluation model response has been validated.
2832
+ * The logical model call includes any provider retries.
2833
+ */
2834
+ experimental_onEvaluationModelCallEnd?: Callback<InferTelemetryEvent<EvaluationModelCallEndEvent>>;
2835
+ /** Called when an experimental evaluation operation completes. */
2836
+ experimental_onEvaluateEnd?: Callback<InferTelemetryEvent<EvaluateEndEvent>>;
2837
+ /** Called when an experimental streaming transcription operation begins. */
2838
+ experimental_onStreamTranscriptionStart?: Callback<InferTelemetryEvent<StreamTranscriptionStartEvent>>;
2839
+ /** Called when an experimental streaming transcription operation completes. */
2840
+ experimental_onStreamTranscriptionEnd?: Callback<InferTelemetryEvent<StreamTranscriptionEndEvent>>;
2841
+ /**
2842
+ * Called when an operation completes. Fired for text generation
2843
+ * (generateText/streamText), object generation (generateObject/streamObject),
2844
+ * embedding (embed/embedMany), reranking, speech generation, and
2845
+ * non-streaming transcription operations.
2846
+ *
2847
+ * Use the event shape or `operationId` to distinguish between operation types.
2848
+ */
2849
+ onEnd?: BivariantCallback<InferTelemetryEvent<OperationEndEvent>>;
2850
+ /**
2851
+ * Called when a streaming text generation operation is aborted before it
2852
+ * completes.
2853
+ */
2854
+ onAbort?: Callback<InferTelemetryEvent<GenerateTextAbortEvent<ToolSet>>>;
2855
+ /**
2856
+ * Called when an unrecoverable error occurs during the generation lifecycle.
2857
+ * The error value is untyped — it may be an `Error` instance, an `AISDKError`,
2858
+ * or any thrown value.
2859
+ *
2860
+ * Use this to record error details on telemetry spans and set error status.
2861
+ */
2862
+ onError?: Callback<unknown>;
2863
+ /**
2864
+ * Optionally runs the language model call in a telemetry-integration-specific context. This enables
2865
+ * auto-instrumented model provider requests to become children of the current
2866
+ * model-call span.
2867
+ *
2868
+ * The options carry the model-call start-event content as context (the event
2869
+ * fields are optional), alongside the always-present `callId` and the
2870
+ * `execute` function that performs the model call.
2871
+ */
2872
+ executeLanguageModelCall?: <T>(options: Partial<InferTelemetryEvent<LanguageModelCallStartEvent>> & {
2873
+ callId: string;
2874
+ execute: () => PromiseLike<T>;
2875
+ }) => PromiseLike<T>;
2876
+ /**
2877
+ * Optionally runs the tool execute function in a telemetry-integration-specific context. This enables
2878
+ * nested traces — e.g. when a tool's `execute` function calls `generateText`,
2879
+ * the inner call's spans become children of the tool span.
2880
+ *
2881
+ * The options carry the tool-execution start-event content as context (the
2882
+ * event fields are optional), alongside the always-present `callId`,
2883
+ * `toolCallId`, and the `execute` function to run.
2884
+ */
2885
+ executeTool?: <T>(options: Partial<InferTelemetryEvent<ToolExecutionStartEvent>> & {
2886
+ callId: string;
2887
+ toolCallId: string;
2888
+ execute: () => PromiseLike<T>;
2889
+ }) => PromiseLike<T>;
2679
2890
  }
2680
-
2891
+ //#endregion
2892
+ //#region src/global.d.ts
2681
2893
  declare global {
2682
- /**
2683
- * The default provider to use for the AI SDK.
2684
- * String model ids are resolved to the default provider and model id.
2685
- *
2686
- * If not set, the default provider is the Vercel AI gateway provider.
2687
- * Experimental evaluation requires an explicitly configured evaluation-capable provider.
2688
- *
2689
- * @see https://ai-sdk.dev/docs/ai-sdk-core/provider-management#global-provider-configuration
2690
- */
2691
- var AI_SDK_DEFAULT_PROVIDER: ProviderV4 | ProviderV3 | ProviderV2 | undefined;
2692
- /**
2693
- * The warning logger to use for the AI SDK.
2694
- *
2695
- * If not set, the default logger is the console.warn function.
2696
- *
2697
- * If set to false, no warnings are logged.
2698
- */
2699
- var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
2700
- /**
2701
- * Globally registered telemetry integrations for the AI SDK.
2702
- *
2703
- * Integrations registered here receive lifecycle events (onStart, onStepStart,
2704
- * etc.) from every `generateText`, `streamText`, and similar call.
2705
- *
2706
- * Prefer using `registerTelemetry()` from `'ai'` instead of
2707
- * assigning this directly.
2708
- */
2709
- var AI_SDK_TELEMETRY_INTEGRATIONS: Telemetry[] | undefined;
2894
+ /**
2895
+ * The default provider to use for the AI SDK.
2896
+ * String model ids are resolved to the default provider and model id.
2897
+ *
2898
+ * If not set, the default provider is the Vercel AI gateway provider.
2899
+ * Experimental evaluation requires an explicitly configured evaluation-capable provider.
2900
+ *
2901
+ * @see https://ai-sdk.dev/docs/ai-sdk-core/provider-management#global-provider-configuration
2902
+ */
2903
+ var AI_SDK_DEFAULT_PROVIDER: ProviderV4 | ProviderV3 | ProviderV2 | undefined;
2904
+ /**
2905
+ * The warning logger to use for the AI SDK.
2906
+ *
2907
+ * If not set, the default logger is the console.warn function.
2908
+ *
2909
+ * If set to false, no warnings are logged.
2910
+ */
2911
+ var AI_SDK_LOG_WARNINGS: LogWarningsFunction | undefined | false;
2912
+ /**
2913
+ * Globally registered telemetry integrations for the AI SDK.
2914
+ *
2915
+ * Integrations registered here receive lifecycle events (onStart, onStepStart,
2916
+ * etc.) from every `generateText`, `streamText`, and similar call.
2917
+ *
2918
+ * Prefer using `registerTelemetry()` from `'ai'` instead of
2919
+ * assigning this directly.
2920
+ */
2921
+ var AI_SDK_TELEMETRY_INTEGRATIONS: Telemetry[] | undefined;
2710
2922
  }
2711
-
2712
- declare function convertToLanguageModelPrompt({ prompt, supportedUrls, download, abortSignal, provider, }: {
2713
- prompt: StandardizedPrompt;
2714
- supportedUrls: Record<string, RegExp[]>;
2715
- download: DownloadFunction | undefined;
2716
- abortSignal?: AbortSignal;
2717
- provider?: string;
2923
+ //#endregion
2924
+ //#region src/prompt/convert-to-language-model-prompt.d.ts
2925
+ export declare function convertToLanguageModelPrompt({ prompt, supportedUrls, download, abortSignal, provider }: {
2926
+ prompt: StandardizedPrompt;
2927
+ supportedUrls: Record<string, RegExp[]>;
2928
+ download: DownloadFunction | undefined;
2929
+ abortSignal?: AbortSignal;
2930
+ provider?: string;
2718
2931
  }): Promise<LanguageModelV4Prompt>;
2719
2932
  /**
2720
2933
  * Downloads files from URLs in the user messages.
2721
2934
  */
2722
- declare function downloadAssets(messages: ModelMessage[], download: DownloadFunction, supportedUrls: Record<string, RegExp[]>): Promise<Record<string, {
2935
+ export declare function downloadAssets(messages: ModelMessage[], download: DownloadFunction, supportedUrls: Record<string, RegExp[]>): Promise<Record<string, {
2936
+ mediaType: string | undefined;
2937
+ data: Uint8Array;
2938
+ }>>;
2939
+ export declare function mapToolResultOutput({ output, provider, warnings, downloadedAssets }: {
2940
+ output: ToolResultOutput;
2941
+ provider?: string;
2942
+ warnings?: Warning[];
2943
+ downloadedAssets: Record<string, {
2723
2944
  mediaType: string | undefined;
2724
2945
  data: Uint8Array;
2725
- }>>;
2726
- declare function mapToolResultOutput({ output, provider, warnings, downloadedAssets, }: {
2727
- output: ToolResultOutput;
2728
- provider?: string;
2729
- warnings?: Warning[];
2730
- downloadedAssets: Record<string, {
2731
- mediaType: string | undefined;
2732
- data: Uint8Array;
2733
- }>;
2946
+ }>;
2734
2947
  }): LanguageModelV4ToolResultOutput;
2735
-
2736
- declare function createToolModelOutput({ toolCallId, input, output, tool, errorMode, }: {
2737
- toolCallId: string;
2738
- input: unknown;
2739
- output: unknown;
2740
- tool: Tool | undefined;
2741
- errorMode: 'none' | 'text' | 'json';
2948
+ //#endregion
2949
+ //#region src/prompt/create-tool-model-output.d.ts
2950
+ export declare function createToolModelOutput({ toolCallId, input, output, tool, errorMode }: {
2951
+ toolCallId: string;
2952
+ input: unknown;
2953
+ output: unknown;
2954
+ tool: Tool | undefined;
2955
+ errorMode: 'none' | 'text' | 'json';
2742
2956
  }): Promise<ToolResultOutput>;
2743
-
2744
- declare function prepareToolChoice({ toolChoice, }: {
2745
- toolChoice: ToolChoice<any> | undefined;
2957
+ //#endregion
2958
+ //#region src/prompt/prepare-tool-choice.d.ts
2959
+ export declare function prepareToolChoice({ toolChoice }: {
2960
+ toolChoice: ToolChoice<any> | undefined;
2746
2961
  }): LanguageModelV4ToolChoice;
2747
-
2748
- declare function prepareTools<TOOLS extends ToolSet>({ tools, toolOrder, toolsContext, experimental_sandbox: sandbox, }: {
2749
- tools: TOOLS | undefined;
2750
- toolOrder?: ToolOrder<TOOLS>;
2751
- toolsContext?: InferToolSetContext<TOOLS>;
2752
- experimental_sandbox?: Experimental_SandboxSession;
2962
+ //#endregion
2963
+ //#region src/prompt/prepare-tools.d.ts
2964
+ export declare function prepareTools<TOOLS extends ToolSet>({ tools, toolOrder, toolsContext, experimental_sandbox: sandbox }: {
2965
+ tools: TOOLS | undefined;
2966
+ toolOrder?: ToolOrder<TOOLS>;
2967
+ toolsContext?: InferToolSetContext<TOOLS>;
2968
+ experimental_sandbox?: Experimental_SandboxSession;
2753
2969
  }): Promise<Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool> | undefined>;
2754
-
2970
+ //#endregion
2971
+ //#region src/prompt/prepare-language-model-call-options.d.ts
2755
2972
  /**
2756
2973
  * Validates model call options and returns a new object with normalized values.
2757
2974
  */
2758
- declare function prepareLanguageModelCallOptions({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, seed, stopSequences, reasoning, }: LanguageModelCallOptions): LanguageModelCallOptions;
2759
-
2975
+ export declare function prepareLanguageModelCallOptions({ maxOutputTokens, temperature, topP, topK, presencePenalty, frequencyPenalty, seed, stopSequences, reasoning }: LanguageModelCallOptions): LanguageModelCallOptions;
2976
+ //#endregion
2977
+ //#region src/util/prepare-retries.d.ts
2760
2978
  /**
2761
2979
  * Validate and prepare retries.
2762
2980
  */
2763
- declare function prepareRetries({ maxRetries, abortSignal, additionalRetryableError, parameter, defaultMaxRetries, }: {
2764
- maxRetries: number | undefined;
2765
- abortSignal: AbortSignal | undefined;
2766
- additionalRetryableError?: ShouldRetryFunction;
2767
- parameter?: string;
2768
- defaultMaxRetries?: number;
2981
+ export declare function prepareRetries({ maxRetries, abortSignal, additionalRetryableError, parameter, defaultMaxRetries }: {
2982
+ maxRetries: number | undefined;
2983
+ abortSignal: AbortSignal | undefined;
2984
+ additionalRetryableError?: ShouldRetryFunction;
2985
+ parameter?: string;
2986
+ defaultMaxRetries?: number;
2769
2987
  }): {
2770
- maxRetries: number;
2771
- retry: RetryFunction;
2988
+ maxRetries: number;
2989
+ retry: RetryFunction;
2772
2990
  };
2773
-
2774
- declare function resolveLanguageModel(model: LanguageModel): LanguageModelV4;
2775
-
2991
+ //#endregion
2992
+ //#region src/model/resolve-model.d.ts
2993
+ export declare function resolveLanguageModel(model: LanguageModel): LanguageModelV4;
2994
+ //#endregion
2995
+ //#region src/util/merge-abort-signals.d.ts
2776
2996
  /**
2777
2997
  * Merges multiple abort sources into a single `AbortSignal`.
2778
2998
  * The returned signal will abort when any input signal aborts or when any
@@ -2783,8 +3003,9 @@ declare function resolveLanguageModel(model: LanguageModel): LanguageModelV4;
2783
3003
  * @returns An `AbortSignal` that aborts when any valid source aborts,
2784
3004
  * or `undefined` if no valid sources are provided.
2785
3005
  */
2786
- declare function mergeAbortSignals(...signals: (AbortSignal | null | undefined | number)[]): AbortSignal | undefined;
2787
-
3006
+ export declare function mergeAbortSignals(...signals: (AbortSignal | null | undefined | number)[]): AbortSignal | undefined;
3007
+ //#endregion
3008
+ //#region src/util/merge-callbacks.d.ts
2788
3009
  /**
2789
3010
  * Creates an async callback that invokes the provided callbacks in parallel.
2790
3011
  * Undefined callbacks are skipped, and thrown or rejected callback errors are
@@ -2794,8 +3015,9 @@ declare function mergeAbortSignals(...signals: (AbortSignal | null | undefined |
2794
3015
  * @returns A callback that forwards each event to all callbacks and waits for
2795
3016
  * them to settle.
2796
3017
  */
2797
- declare function mergeCallbacks<EVENT>(...callbacks: Array<Callback<EVENT> | undefined>): Callback<EVENT>;
2798
-
3018
+ export declare function mergeCallbacks<EVENT>(...callbacks: Array<Callback<EVENT> | undefined>): Callback<EVENT>;
3019
+ //#endregion
3020
+ //#region src/telemetry/create-telemetry-dispatcher.d.ts
2799
3021
  /**
2800
3022
  * Creates a telemetry dispatcher that sends telemetry events
2801
3023
  * to the resolved set of integrations.
@@ -2809,45 +3031,48 @@ declare function mergeCallbacks<EVENT>(...callbacks: Array<Callback<EVENT> | und
2809
3031
  * @returns A telemetry dispatcher that fans out lifecycle events to the
2810
3032
  * resolved set of integrations.
2811
3033
  */
2812
- declare function createTelemetryDispatcher({ telemetry, }: {
2813
- telemetry?: TelemetryOptions;
3034
+ export declare function createTelemetryDispatcher({ telemetry }: {
3035
+ telemetry?: TelemetryOptions;
2814
3036
  }): TelemetryDispatcher;
2815
-
3037
+ //#endregion
3038
+ //#region src/generate-text/restricted-telemetry-dispatcher.d.ts
2816
3039
  /**
2817
3040
  * Telemetry dispatcher for text generation with callbacks typed to the
2818
3041
  * operation-specific tool set, runtime context, and output shape.
2819
3042
  */
2820
3043
  type RestrictedTelemetryDispatcher<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends Output> = Omit<TelemetryDispatcher, 'onStart' | 'onStepStart' | 'onStepEnd' | 'onStepFinish' | 'onEnd' | 'onAbort' | 'onToolExecutionStart' | 'onToolExecutionEnd'> & {
2821
- onStart: GenerateTextOnStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
2822
- onStepStart: GenerateTextOnStepStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
2823
- onStepEnd: GenerateTextOnStepEndCallback<TOOLS, RUNTIME_CONTEXT>;
2824
- /** @deprecated Use `onStepEnd` instead. */
2825
- onStepFinish: GenerateTextOnStepFinishCallback<TOOLS, RUNTIME_CONTEXT>;
2826
- onEnd: GenerateTextOnEndCallback<TOOLS, RUNTIME_CONTEXT>;
2827
- onAbort?: GenerateTextOnAbortCallback<TOOLS, RUNTIME_CONTEXT>;
2828
- onToolExecutionStart?: OnToolExecutionStartCallback<TOOLS>;
2829
- onToolExecutionEnd?: OnToolExecutionEndCallback<TOOLS>;
3044
+ onStart: GenerateTextOnStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
3045
+ onStepStart: GenerateTextOnStepStartCallback<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
3046
+ onStepEnd: GenerateTextOnStepEndCallback<TOOLS, RUNTIME_CONTEXT>;
3047
+ /** @deprecated Use `onStepEnd` instead. */
3048
+ onStepFinish: GenerateTextOnStepFinishCallback<TOOLS, RUNTIME_CONTEXT>;
3049
+ onEnd: GenerateTextOnEndCallback<TOOLS, RUNTIME_CONTEXT>;
3050
+ onAbort?: GenerateTextOnAbortCallback<TOOLS, RUNTIME_CONTEXT>;
3051
+ onToolExecutionStart?: OnToolExecutionStartCallback<TOOLS>;
3052
+ onToolExecutionEnd?: OnToolExecutionEndCallback<TOOLS>;
2830
3053
  };
2831
3054
  /**
2832
3055
  * Creates a telemetry dispatcher that only includes configured runtime context
2833
3056
  * properties in text-generation lifecycle events before dispatching them.
2834
3057
  */
2835
- declare function createRestrictedTelemetryDispatcher<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends Output>({ telemetry, includeRuntimeContext, includeToolsContext, }: {
2836
- telemetry?: TelemetryOptions<RUNTIME_CONTEXT, TOOLS>;
2837
- includeRuntimeContext: IncludedContext<RUNTIME_CONTEXT>;
2838
- includeToolsContext?: IncludedToolsContext<TOOLS>;
3058
+ export declare function createRestrictedTelemetryDispatcher<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context, OUTPUT extends Output>({ telemetry, includeRuntimeContext, includeToolsContext }: {
3059
+ telemetry?: TelemetryOptions<RUNTIME_CONTEXT, TOOLS>;
3060
+ includeRuntimeContext: IncludedContext<RUNTIME_CONTEXT>;
3061
+ includeToolsContext?: IncludedToolsContext<TOOLS>;
2839
3062
  }): RestrictedTelemetryDispatcher<TOOLS, RUNTIME_CONTEXT, OUTPUT>;
2840
-
2841
- declare function parseToolCall<TOOLS extends ToolSet>({ toolCall, tools, repairToolCall, refineToolInput, messages, instructions, abortSignal, }: {
2842
- toolCall: LanguageModelV4ToolCall;
2843
- tools: TOOLS | undefined;
2844
- repairToolCall: ToolCallRepairFunction<TOOLS> | undefined;
2845
- refineToolInput?: ToolInputRefinement<TOOLS> | undefined;
2846
- instructions: Instructions | undefined;
2847
- messages: ModelMessage[];
2848
- abortSignal?: AbortSignal;
3063
+ //#endregion
3064
+ //#region src/generate-text/parse-tool-call.d.ts
3065
+ export declare function parseToolCall<TOOLS extends ToolSet>({ toolCall, tools, repairToolCall, refineToolInput, messages, instructions, abortSignal }: {
3066
+ toolCall: LanguageModelV4ToolCall;
3067
+ tools: TOOLS | undefined;
3068
+ repairToolCall: ToolCallRepairFunction<TOOLS> | undefined;
3069
+ refineToolInput?: ToolInputRefinement<TOOLS> | undefined;
3070
+ instructions: Instructions | undefined;
3071
+ messages: ModelMessage[];
3072
+ abortSignal?: AbortSignal;
2849
3073
  }): Promise<TypedToolCall<TOOLS>>;
2850
-
3074
+ //#endregion
3075
+ //#region src/generate-text/validate-tool-context.d.ts
2851
3076
  /**
2852
3077
  * Validates a tool context value against the tool's optional context schema.
2853
3078
  *
@@ -2858,82 +3083,88 @@ declare function parseToolCall<TOOLS extends ToolSet>({ toolCall, tools, repairT
2858
3083
  * @throws {TypeValidationError} When the provided tool context does not match
2859
3084
  * the tool's declared `contextSchema`.
2860
3085
  */
2861
- declare function validateToolContext<CONTEXT>({ toolName, context, contextSchema, }: {
2862
- toolName: string;
2863
- context: unknown;
2864
- contextSchema: FlexibleSchema<CONTEXT> | undefined;
3086
+ export declare function validateToolContext<CONTEXT>({ toolName, context, contextSchema }: {
3087
+ toolName: string;
3088
+ context: unknown;
3089
+ contextSchema: FlexibleSchema<CONTEXT> | undefined;
2865
3090
  }): Promise<CONTEXT>;
2866
-
3091
+ //#endregion
3092
+ //#region src/tool-search/prepare-tool-search.d.ts
2867
3093
  /** Create discovery state for one generation, never for a shared tool instance. */
2868
- declare function createToolSearchState({ tools, toolCallers, }: {
2869
- tools: ToolSet | undefined;
2870
- toolCallers: ResolvedToolCallers | undefined;
3094
+ export declare function createToolSearchState({ tools, toolCallers }: {
3095
+ tools: ToolSet | undefined;
3096
+ toolCallers: ResolvedToolCallers | undefined;
2871
3097
  }): (activeTools: ToolSet | undefined, options?: {
2872
- toolsContext?: InferToolSetContext<ToolSet>;
2873
- experimental_sandbox?: Experimental_SandboxSession;
3098
+ toolsContext?: InferToolSetContext<ToolSet>;
3099
+ experimental_sandbox?: Experimental_SandboxSession;
2874
3100
  }) => ToolSet | undefined;
2875
-
3101
+ //#endregion
3102
+ //#region src/generate-text/collect-tool-approvals.d.ts
2876
3103
  type CollectedToolApprovals<TOOLS extends ToolSet> = {
2877
- approvalRequest: ToolApprovalRequest;
2878
- approvalResponse: ToolApprovalResponse;
2879
- toolCall: TypedToolCall<TOOLS>;
2880
- existingToolResult?: ToolResultPart;
3104
+ approvalRequest: ToolApprovalRequest;
3105
+ approvalResponse: ToolApprovalResponse;
3106
+ toolCall: TypedToolCall<TOOLS>;
3107
+ existingToolResult?: ToolResultPart;
2881
3108
  };
2882
3109
  /**
2883
3110
  * If the last message is a tool message, this function collects all tool approvals
2884
3111
  * from that message.
2885
3112
  */
2886
- declare function collectToolApprovals<TOOLS extends ToolSet>({ messages, }: {
2887
- messages: ModelMessage[];
3113
+ export declare function collectToolApprovals<TOOLS extends ToolSet>({ messages }: {
3114
+ messages: ModelMessage[];
2888
3115
  }): {
2889
- approvedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
2890
- deniedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
2891
- };
2892
-
2893
- declare function signToolApproval({ secret, approvalId, toolCallId, toolName, input, }: {
2894
- secret: string | Uint8Array;
2895
- approvalId: string;
2896
- toolCallId: string;
2897
- toolName: string;
2898
- input: unknown;
3116
+ approvedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
3117
+ deniedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
3118
+ };
3119
+ //#endregion
3120
+ //#region src/generate-text/tool-approval-signature.d.ts
3121
+ export declare function signToolApproval({ secret, approvalId, toolCallId, toolName, input }: {
3122
+ secret: string | Uint8Array;
3123
+ approvalId: string;
3124
+ toolCallId: string;
3125
+ toolName: string;
3126
+ input: unknown;
2899
3127
  }): Promise<string>;
2900
- declare function verifyToolApprovalSignature({ secret, signature, approvalId, toolCallId, toolName, input, }: {
2901
- secret: string | Uint8Array;
2902
- signature: string;
2903
- approvalId: string;
2904
- toolCallId: string;
2905
- toolName: string;
2906
- input: unknown;
3128
+ export declare function verifyToolApprovalSignature({ secret, signature, approvalId, toolCallId, toolName, input }: {
3129
+ secret: string | Uint8Array;
3130
+ signature: string;
3131
+ approvalId: string;
3132
+ toolCallId: string;
3133
+ toolName: string;
3134
+ input: unknown;
2907
3135
  }): Promise<boolean>;
2908
-
3136
+ //#endregion
3137
+ //#region src/generate-text/validate-tool-approvals.d.ts
2909
3138
  /**
2910
3139
  * Re-validates approved tool approvals reconstructed from client-supplied
2911
3140
  * message history before they are executed. Checks HMAC signature (when
2912
3141
  * configured), input schema, and approval policy.
2913
3142
  */
2914
- declare function validateApprovedToolApprovals<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context | unknown | never>({ approvedToolApprovals, tools, toolApproval, messages, toolsContext, runtimeContext, toolApprovalSecret, refineToolInput, }: {
2915
- approvedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
2916
- tools: TOOLS | undefined;
2917
- toolApproval: ToolApprovalConfiguration<TOOLS, RUNTIME_CONTEXT> | undefined;
2918
- messages: ModelMessage[];
2919
- toolsContext: InferToolSetContext<TOOLS>;
2920
- runtimeContext: RUNTIME_CONTEXT;
2921
- toolApprovalSecret?: string | Uint8Array;
2922
- refineToolInput?: ToolInputRefinement<TOOLS>;
3143
+ export declare function validateApprovedToolApprovals<TOOLS extends ToolSet, RUNTIME_CONTEXT extends Context | unknown | never>({ approvedToolApprovals, tools, toolApproval, messages, toolsContext, runtimeContext, toolApprovalSecret, refineToolInput }: {
3144
+ approvedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
3145
+ tools: TOOLS | undefined;
3146
+ toolApproval: ToolApprovalConfiguration<TOOLS, RUNTIME_CONTEXT> | undefined;
3147
+ messages: ModelMessage[];
3148
+ toolsContext: InferToolSetContext<TOOLS>;
3149
+ runtimeContext: RUNTIME_CONTEXT;
3150
+ toolApprovalSecret?: string | Uint8Array;
3151
+ refineToolInput?: ToolInputRefinement<TOOLS>;
2923
3152
  }): Promise<{
2924
- approvedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
2925
- deniedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
2926
- invalidToolApprovals: Array<CollectedToolApprovals<TOOLS> & {
2927
- error: InvalidToolInputError;
2928
- }>;
3153
+ approvedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
3154
+ deniedToolApprovals: Array<CollectedToolApprovals<TOOLS>>;
3155
+ invalidToolApprovals: Array<CollectedToolApprovals<TOOLS> & {
3156
+ error: InvalidToolInputError;
3157
+ }>;
2929
3158
  }>;
2930
-
3159
+ //#endregion
3160
+ //#region src/generate-text/to-response-messages.d.ts
2931
3161
  /**
2932
3162
  * Converts the result of a `generateText` or `streamText` call to a list of response messages.
2933
3163
  */
2934
- declare function toResponseMessages<TOOLS extends ToolSet>({ content: inputContent, tools, }: {
2935
- content: Array<ContentPart<TOOLS>>;
2936
- tools: TOOLS | undefined;
2937
- }): Promise<Array<AssistantModelMessage | ToolModelMessage>>;
2938
-
2939
- export { type CollectedToolApprovals, DefaultStepResult, type DownloadFunction, type ToolsContextSettings, addLanguageModelUsage, asLanguageModelUsage, collectToolApprovals, convertToLanguageModelPrompt, createAsyncIterableStream, createDefaultDownloadFunction, createNullLanguageModelUsage, createRestrictedTelemetryDispatcher, createTelemetryDispatcher, createToolModelOutput, createToolSearchState, downloadAssets, mapToolResultOutput, mergeAbortSignals, mergeCallbacks, parseToolCall, prepareLanguageModelCallOptions as prepareCallSettings, prepareLanguageModelCallOptions, prepareRetries, prepareToolChoice, prepareTools, resolveLanguageModel, signToolApproval, standardizePrompt, toResponseMessages, validateApprovedToolApprovals, validateToolContext, verifyToolApprovalSignature };
3164
+ export declare function toResponseMessages<TOOLS extends ToolSet>({ content: inputContent, tools }: {
3165
+ content: Array<ContentPart<TOOLS>>;
3166
+ tools: TOOLS | undefined;
3167
+ }): Promise<Array<AssistantModelMessage$1 | ToolModelMessage$1>>;
3168
+ //#endregion
3169
+ export { type CollectedToolApprovals, type DownloadFunction, type ToolsContextSettings, convertAsyncIteratorToReadableStream, prepareLanguageModelCallOptions as prepareCallSettings };
3170
+ //# sourceMappingURL=index.d.ts.map