@mastra/schema-compat 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mastra/schema-compat
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed Groq provider not receiving schema compatibility transformations, which caused HTTP 400 errors when AI models omitted optional parameters from workspace tool calls (e.g. list_files). Groq now correctly gets the same optional-to-nullable schema handling as OpenAI. ([#13303](https://github.com/mastra-ai/mastra/pull/13303))
8
+
9
+ ## 1.1.2-alpha.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Fixed Groq provider not receiving schema compatibility transformations, which caused HTTP 400 errors when AI models omitted optional parameters from workspace tool calls (e.g. list_files). Groq now correctly gets the same optional-to-nullable schema handling as OpenAI. ([#13303](https://github.com/mastra-ai/mastra/pull/13303))
14
+
3
15
  ## 1.1.1
4
16
 
5
17
  ### Patch Changes
@@ -2803,7 +2803,7 @@ declare interface GatewayLanguageModelEntry {
2803
2803
 
2804
2804
  declare type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
2805
2805
 
2806
- export declare type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'alibaba/qwen3.5-plus' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'minimax/minimax-m2.5' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | 'zai/glm-5' | (string & {});
2806
+ export declare type GatewayModelId = 'alibaba/qwen-3-14b' | 'alibaba/qwen-3-235b' | 'alibaba/qwen-3-30b' | 'alibaba/qwen-3-32b' | 'alibaba/qwen3-235b-a22b-thinking' | 'alibaba/qwen3-coder' | 'alibaba/qwen3-coder-30b-a3b' | 'alibaba/qwen3-coder-next' | 'alibaba/qwen3-coder-plus' | 'alibaba/qwen3-max' | 'alibaba/qwen3-max-preview' | 'alibaba/qwen3-max-thinking' | 'alibaba/qwen3-next-80b-a3b-instruct' | 'alibaba/qwen3-next-80b-a3b-thinking' | 'alibaba/qwen3-vl-instruct' | 'alibaba/qwen3-vl-thinking' | 'alibaba/qwen3.5-plus' | 'amazon/nova-2-lite' | 'amazon/nova-lite' | 'amazon/nova-micro' | 'amazon/nova-pro' | 'anthropic/claude-3-haiku' | 'anthropic/claude-3-opus' | 'anthropic/claude-3.5-haiku' | 'anthropic/claude-3.5-sonnet' | 'anthropic/claude-3.5-sonnet-20240620' | 'anthropic/claude-3.7-sonnet' | 'anthropic/claude-haiku-4.5' | 'anthropic/claude-opus-4' | 'anthropic/claude-opus-4.1' | 'anthropic/claude-opus-4.5' | 'anthropic/claude-opus-4.6' | 'anthropic/claude-sonnet-4' | 'anthropic/claude-sonnet-4.5' | 'anthropic/claude-sonnet-4.6' | 'arcee-ai/trinity-large-preview' | 'arcee-ai/trinity-mini' | 'bytedance/seed-1.6' | 'bytedance/seed-1.8' | 'cohere/command-a' | 'deepseek/deepseek-r1' | 'deepseek/deepseek-v3' | 'deepseek/deepseek-v3.1' | 'deepseek/deepseek-v3.1-terminus' | 'deepseek/deepseek-v3.2' | 'deepseek/deepseek-v3.2-thinking' | 'google/gemini-2.0-flash' | 'google/gemini-2.0-flash-lite' | 'google/gemini-2.5-flash' | 'google/gemini-2.5-flash-image' | 'google/gemini-2.5-flash-lite' | 'google/gemini-2.5-flash-lite-preview-09-2025' | 'google/gemini-2.5-flash-preview-09-2025' | 'google/gemini-2.5-pro' | 'google/gemini-3-flash' | 'google/gemini-3-pro-image' | 'google/gemini-3-pro-preview' | 'google/gemini-3.1-pro-preview' | 'inception/mercury-coder-small' | 'kwaipilot/kat-coder-pro-v1' | 'meituan/longcat-flash-chat' | 'meituan/longcat-flash-thinking' | 'meta/llama-3.1-70b' | 'meta/llama-3.1-8b' | 'meta/llama-3.2-11b' | 'meta/llama-3.2-1b' | 'meta/llama-3.2-3b' | 'meta/llama-3.2-90b' | 'meta/llama-3.3-70b' | 'meta/llama-4-maverick' | 'meta/llama-4-scout' | 'minimax/minimax-m2' | 'minimax/minimax-m2.1' | 'minimax/minimax-m2.1-lightning' | 'minimax/minimax-m2.5' | 'mistral/codestral' | 'mistral/devstral-2' | 'mistral/devstral-small' | 'mistral/devstral-small-2' | 'mistral/magistral-medium' | 'mistral/magistral-small' | 'mistral/ministral-14b' | 'mistral/ministral-3b' | 'mistral/ministral-8b' | 'mistral/mistral-large-3' | 'mistral/mistral-medium' | 'mistral/mistral-nemo' | 'mistral/mistral-small' | 'mistral/mixtral-8x22b-instruct' | 'mistral/pixtral-12b' | 'mistral/pixtral-large' | 'moonshotai/kimi-k2' | 'moonshotai/kimi-k2-0905' | 'moonshotai/kimi-k2-thinking' | 'moonshotai/kimi-k2-thinking-turbo' | 'moonshotai/kimi-k2-turbo' | 'moonshotai/kimi-k2.5' | 'morph/morph-v3-fast' | 'morph/morph-v3-large' | 'nvidia/nemotron-3-nano-30b-a3b' | 'nvidia/nemotron-nano-12b-v2-vl' | 'nvidia/nemotron-nano-9b-v2' | 'openai/codex-mini' | 'openai/gpt-3.5-turbo' | 'openai/gpt-3.5-turbo-instruct' | 'openai/gpt-4-turbo' | 'openai/gpt-4.1' | 'openai/gpt-4.1-mini' | 'openai/gpt-4.1-nano' | 'openai/gpt-4o' | 'openai/gpt-4o-mini' | 'openai/gpt-4o-mini-search-preview' | 'openai/gpt-5' | 'openai/gpt-5-chat' | 'openai/gpt-5-codex' | 'openai/gpt-5-mini' | 'openai/gpt-5-nano' | 'openai/gpt-5-pro' | 'openai/gpt-5.1-codex' | 'openai/gpt-5.1-codex-max' | 'openai/gpt-5.1-codex-mini' | 'openai/gpt-5.1-instant' | 'openai/gpt-5.1-thinking' | 'openai/gpt-5.2' | 'openai/gpt-5.2-chat' | 'openai/gpt-5.2-codex' | 'openai/gpt-5.2-pro' | 'openai/gpt-oss-120b' | 'openai/gpt-oss-20b' | 'openai/gpt-oss-safeguard-20b' | 'openai/o1' | 'openai/o3' | 'openai/o3-deep-research' | 'openai/o3-mini' | 'openai/o3-pro' | 'openai/o4-mini' | 'perplexity/sonar' | 'perplexity/sonar-pro' | 'perplexity/sonar-reasoning' | 'perplexity/sonar-reasoning-pro' | 'prime-intellect/intellect-3' | 'vercel/v0-1.0-md' | 'vercel/v0-1.5-md' | 'xai/grok-2-vision' | 'xai/grok-3' | 'xai/grok-3-fast' | 'xai/grok-3-mini' | 'xai/grok-3-mini-fast' | 'xai/grok-4' | 'xai/grok-4-fast-non-reasoning' | 'xai/grok-4-fast-reasoning' | 'xai/grok-4.1-fast-non-reasoning' | 'xai/grok-4.1-fast-reasoning' | 'xai/grok-code-fast-1' | 'xiaomi/mimo-v2-flash' | 'zai/glm-4.5' | 'zai/glm-4.5-air' | 'zai/glm-4.5v' | 'zai/glm-4.6' | 'zai/glm-4.6v' | 'zai/glm-4.6v-flash' | 'zai/glm-4.7' | 'zai/glm-4.7-flashx' | 'zai/glm-5' | (string & {});
2807
2807
 
2808
2808
  declare interface GatewayProvider extends ProviderV3 {
2809
2809
  (modelId: GatewayModelId): LanguageModelV3;
@@ -2904,7 +2904,7 @@ declare const gatewayTools: {
2904
2904
  perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
2905
2905
  };
2906
2906
 
2907
- declare type GatewayVideoModelId = 'google/veo-3.1-generate-001' | (string & {});
2907
+ declare type GatewayVideoModelId = 'alibaba/wan-v2.5-t2v-preview' | 'alibaba/wan-v2.6-i2v' | 'alibaba/wan-v2.6-i2v-flash' | 'alibaba/wan-v2.6-r2v' | 'alibaba/wan-v2.6-r2v-flash' | 'alibaba/wan-v2.6-t2v' | 'google/veo-3.0-fast-generate-001' | 'google/veo-3.0-generate-001' | 'google/veo-3.1-fast-generate-001' | 'google/veo-3.1-generate-001' | 'klingai/kling-v2.5-turbo-i2v' | 'klingai/kling-v2.5-turbo-t2v' | 'klingai/kling-v2.6-i2v' | 'klingai/kling-v2.6-t2v' | 'klingai/kling-v3.0-i2v' | 'klingai/kling-v3.0-t2v' | 'xai/grok-imagine-video' | (string & {});
2908
2908
 
2909
2909
  /**
2910
2910
  * A generated audio file.
@@ -3276,13 +3276,21 @@ export declare interface GenerateObjectResult<OBJECT> {
3276
3276
  * @param timeout - An optional timeout in milliseconds. The call will be aborted if it takes longer than the specified timeout.
3277
3277
  * @param headers - Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
3278
3278
  *
3279
+ * @param experimental_context - User-defined context object that flows through the entire generation lifecycle.
3280
+ * @param experimental_onStart - Callback invoked when generation begins, before any LLM calls.
3281
+ * @param experimental_onStepStart - Callback invoked when each step begins, before the provider is called.
3282
+ * Receives step number, messages (in ModelMessage format), tools, and context.
3283
+ * @param experimental_onToolCallStart - Callback invoked before each tool execution begins.
3284
+ * Receives tool name, call ID, input, and context.
3285
+ * @param experimental_onToolCallFinish - Callback invoked after each tool execution completes.
3286
+ * Uses a discriminated union: check `success` to determine if `output` or `error` is present.
3279
3287
  * @param onStepFinish - Callback that is called when each step (LLM call) is finished, including intermediate steps.
3280
3288
  * @param onFinish - Callback that is called when all steps are finished and the response is complete.
3281
3289
  *
3282
3290
  * @returns
3283
3291
  * A result object that contains the generated text, the results of the tool calls, and additional information.
3284
3292
  */
3285
- export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
3293
+ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string>>({ model: modelArg, tools, toolChoice, system, prompt, messages, maxRetries: maxRetriesArg, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, providerOptions, experimental_activeTools, activeTools, experimental_prepareStep, prepareStep, experimental_repairToolCall: repairToolCall, experimental_download: download, experimental_context, experimental_include: include, _internal: { generateId }, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, onStepFinish, onFinish, ...settings }: CallSettings & Prompt & {
3286
3294
  /**
3287
3295
  * The language model to use.
3288
3296
  */
@@ -3349,6 +3357,24 @@ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Outpu
3349
3357
  * A function that attempts to repair a tool call that failed to parse.
3350
3358
  */
3351
3359
  experimental_repairToolCall?: ToolCallRepairFunction<NoInfer<TOOLS>>;
3360
+ /**
3361
+ * Callback that is called when the generateText operation begins,
3362
+ * before any LLM calls are made.
3363
+ */
3364
+ experimental_onStart?: GenerateTextOnStartCallback<NoInfer<TOOLS>, OUTPUT>;
3365
+ /**
3366
+ * Callback that is called when a step (LLM call) begins,
3367
+ * before the provider is called.
3368
+ */
3369
+ experimental_onStepStart?: GenerateTextOnStepStartCallback<NoInfer<TOOLS>, OUTPUT>;
3370
+ /**
3371
+ * Callback that is called right before a tool's execute function runs.
3372
+ */
3373
+ experimental_onToolCallStart?: GenerateTextOnToolCallStartCallback<NoInfer<TOOLS>>;
3374
+ /**
3375
+ * Callback that is called right after a tool's execute function completes (or errors).
3376
+ */
3377
+ experimental_onToolCallFinish?: GenerateTextOnToolCallFinishCallback<NoInfer<TOOLS>>;
3352
3378
  /**
3353
3379
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
3354
3380
  */
@@ -3396,34 +3422,329 @@ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Outpu
3396
3422
  /**
3397
3423
  * Callback that is set using the `onFinish` option.
3398
3424
  *
3399
- * @param event - The event that is passed to the callback.
3425
+ * Called when the entire generation completes (all steps finished).
3426
+ * The event includes the final step's result properties along with
3427
+ * aggregated data from all steps.
3428
+ *
3429
+ * @param event - The final result along with aggregated step data.
3430
+ *
3431
+ * Inherited from StepResult (reflects the final step):
3432
+ * @param event.content - Array of content parts from the final step.
3433
+ * @param event.text - The generated text from the final step.
3434
+ * @param event.reasoning - Array of reasoning parts from the final step.
3435
+ * @param event.reasoningText - Combined reasoning text from the final step.
3436
+ * @param event.files - Array of generated files from the final step.
3437
+ * @param event.sources - Array of sources from the final step.
3438
+ * @param event.toolCalls - Array of tool calls from the final step.
3439
+ * @param event.toolResults - Array of tool results from the final step.
3440
+ * @param event.finishReason - Finish reason from the final step.
3441
+ * @param event.usage - Token usage from the final step only.
3442
+ * @param event.warnings - Warnings from the final step.
3443
+ * @param event.request - Request metadata from the final step.
3444
+ * @param event.response - Response metadata from the final step.
3445
+ * @param event.providerMetadata - Provider metadata from the final step.
3446
+ *
3447
+ * Additional properties:
3448
+ * @param event.steps - Array containing results from all steps in the generation.
3449
+ * @param event.totalUsage - Aggregated token usage across all steps.
3450
+ * @param event.experimental_context - The final state of the user-defined context object.
3451
+ * @param event.functionId - Identifier from telemetry settings for grouping related operations.
3452
+ * @param event.metadata - Additional metadata from telemetry settings.
3400
3453
  */
3401
3454
  export declare type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
3402
3455
  /**
3403
- * Details for all steps.
3456
+ * Array containing results from all steps in the generation.
3404
3457
  */
3405
3458
  readonly steps: StepResult<TOOLS>[];
3406
3459
  /**
3407
- * Total usage for all steps. This is the sum of the usage of all steps.
3460
+ * Aggregated token usage across all steps.
3461
+ * This is the sum of the usage from each individual step.
3408
3462
  */
3409
3463
  readonly totalUsage: LanguageModelUsage;
3410
3464
  /**
3411
- * Context that is passed into tool execution.
3465
+ * The final state of the user-defined context object.
3466
+ * This reflects any modifications made during the generation lifecycle
3467
+ * via `prepareStep` or tool execution.
3412
3468
  *
3413
3469
  * Experimental (can break in patch releases).
3414
3470
  *
3415
3471
  * @default undefined
3416
3472
  */
3417
3473
  experimental_context: unknown;
3474
+ /** Identifier from telemetry settings for grouping related operations. */
3475
+ readonly functionId: string | undefined;
3476
+ /** Additional metadata from telemetry settings. */
3477
+ readonly metadata: Record<string, unknown> | undefined;
3478
+ }) => PromiseLike<void> | void;
3479
+
3480
+ /**
3481
+ * Callback that is set using the `experimental_onStart` option.
3482
+ *
3483
+ * Called when the generateText operation begins, before any LLM calls.
3484
+ * Use this callback for logging, analytics, or initializing state at the
3485
+ * start of a generation.
3486
+ *
3487
+ * @param event - The event object containing generation configuration.
3488
+ */
3489
+ export declare type GenerateTextOnStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: {
3490
+ /** The model being used for generation. */
3491
+ readonly model: {
3492
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
3493
+ readonly provider: string;
3494
+ /** The specific model identifier (e.g., 'gpt-4o'). */
3495
+ readonly modelId: string;
3496
+ };
3497
+ /** The system message(s) provided to the model. */
3498
+ readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
3499
+ /** The prompt string or array of messages if using the prompt option. */
3500
+ readonly prompt: string | Array<ModelMessage> | undefined;
3501
+ /** The messages array if using the messages option. */
3502
+ readonly messages: Array<ModelMessage> | undefined;
3503
+ /** The tools available for this generation. */
3504
+ readonly tools: TOOLS | undefined;
3505
+ /** The tool choice strategy for this generation. */
3506
+ readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
3507
+ /** Limits which tools are available for the model to call. */
3508
+ readonly activeTools: Array<keyof TOOLS> | undefined;
3509
+ /** Maximum number of tokens to generate. */
3510
+ readonly maxOutputTokens: number | undefined;
3511
+ /** Sampling temperature for generation. */
3512
+ readonly temperature: number | undefined;
3513
+ /** Top-p (nucleus) sampling parameter. */
3514
+ readonly topP: number | undefined;
3515
+ /** Top-k sampling parameter. */
3516
+ readonly topK: number | undefined;
3517
+ /** Presence penalty for generation. */
3518
+ readonly presencePenalty: number | undefined;
3519
+ /** Frequency penalty for generation. */
3520
+ readonly frequencyPenalty: number | undefined;
3521
+ /** Sequences that will stop generation. */
3522
+ readonly stopSequences: string[] | undefined;
3523
+ /** Random seed for reproducible generation. */
3524
+ readonly seed: number | undefined;
3525
+ /** Maximum number of retries for failed requests. */
3526
+ readonly maxRetries: number;
3527
+ /**
3528
+ * Timeout configuration for the generation.
3529
+ * Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
3530
+ */
3531
+ readonly timeout: TimeoutConfiguration | undefined;
3532
+ /** Additional HTTP headers sent with the request. */
3533
+ readonly headers: Record<string, string | undefined> | undefined;
3534
+ /** Additional provider-specific options. */
3535
+ readonly providerOptions: ProviderOptions | undefined;
3536
+ /**
3537
+ * Condition(s) for stopping the generation.
3538
+ * When the condition is an array, any of the conditions can be met to stop.
3539
+ */
3540
+ readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
3541
+ /** The output specification for structured outputs, if configured. */
3542
+ readonly output: OUTPUT | undefined;
3543
+ /** Abort signal for cancelling the operation. */
3544
+ readonly abortSignal: AbortSignal | undefined;
3545
+ /**
3546
+ * Settings for controlling what data is included in step results.
3547
+ * `requestBody` and `responseBody` control whether these are retained.
3548
+ */
3549
+ readonly include: {
3550
+ requestBody?: boolean;
3551
+ responseBody?: boolean;
3552
+ } | undefined;
3553
+ /** Identifier from telemetry settings for grouping related operations. */
3554
+ readonly functionId: string | undefined;
3555
+ /** Additional metadata passed to the generation. */
3556
+ readonly metadata: Record<string, unknown> | undefined;
3557
+ /**
3558
+ * User-defined context object that flows through the entire generation lifecycle.
3559
+ * Can be accessed and modified in `prepareStep` and tool `execute` functions.
3560
+ */
3561
+ readonly experimental_context: unknown;
3418
3562
  }) => PromiseLike<void> | void;
3419
3563
 
3420
3564
  /**
3421
3565
  * Callback that is set using the `onStepFinish` option.
3422
3566
  *
3567
+ * Called when a step (LLM call) completes. The event includes all step result
3568
+ * properties (text, tool calls, usage, etc.) along with additional metadata.
3569
+ *
3423
3570
  * @param stepResult - The result of the step.
3424
3571
  */
3425
3572
  export declare type GenerateTextOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
3426
3573
 
3574
+ /**
3575
+ * Callback that is set using the `experimental_onStepStart` option.
3576
+ *
3577
+ * Called when a step (LLM call) begins, before the provider is called.
3578
+ * Each step represents a single LLM invocation. Multiple steps occur when
3579
+ * using tool calls (the model may be called multiple times in a loop).
3580
+ *
3581
+ * @param event - The event object containing step configuration.
3582
+ */
3583
+ export declare type GenerateTextOnStepStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: {
3584
+ /** Zero-based index of the current step. */
3585
+ readonly stepNumber: number;
3586
+ /** The model being used for this step. */
3587
+ readonly model: {
3588
+ /** The provider identifier. */
3589
+ readonly provider: string;
3590
+ /** The specific model identifier. */
3591
+ readonly modelId: string;
3592
+ };
3593
+ /**
3594
+ * The system message for this step.
3595
+ */
3596
+ readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
3597
+ /**
3598
+ * The messages that will be sent to the model for this step.
3599
+ * Uses the user-facing `ModelMessage` format.
3600
+ * May be overridden by prepareStep.
3601
+ */
3602
+ readonly messages: Array<ModelMessage>;
3603
+ /** The tools available for this generation. */
3604
+ readonly tools: TOOLS | undefined;
3605
+ /** The tool choice configuration for this step. */
3606
+ readonly toolChoice: LanguageModelV3ToolChoice | undefined;
3607
+ /** Limits which tools are available for this step. */
3608
+ readonly activeTools: Array<keyof TOOLS> | undefined;
3609
+ /** Array of results from previous steps (empty for first step). */
3610
+ readonly steps: ReadonlyArray<StepResult<TOOLS>>;
3611
+ /** Additional provider-specific options for this step. */
3612
+ readonly providerOptions: ProviderOptions | undefined;
3613
+ /**
3614
+ * Timeout configuration for the generation.
3615
+ * Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
3616
+ */
3617
+ readonly timeout: TimeoutConfiguration | undefined;
3618
+ /** Additional HTTP headers sent with the request. */
3619
+ readonly headers: Record<string, string | undefined> | undefined;
3620
+ /**
3621
+ * Condition(s) for stopping the generation.
3622
+ * When the condition is an array, any of the conditions can be met to stop.
3623
+ */
3624
+ readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
3625
+ /** The output specification for structured outputs, if configured. */
3626
+ readonly output: OUTPUT | undefined;
3627
+ /** Abort signal for cancelling the operation. */
3628
+ readonly abortSignal: AbortSignal | undefined;
3629
+ /**
3630
+ * Settings for controlling what data is included in step results.
3631
+ */
3632
+ readonly include: {
3633
+ requestBody?: boolean;
3634
+ responseBody?: boolean;
3635
+ } | undefined;
3636
+ /** Identifier from telemetry settings for grouping related operations. */
3637
+ readonly functionId: string | undefined;
3638
+ /** Additional metadata from telemetry settings. */
3639
+ readonly metadata: Record<string, unknown> | undefined;
3640
+ /**
3641
+ * User-defined context object. May be updated from `prepareStep` between steps.
3642
+ */
3643
+ readonly experimental_context: unknown;
3644
+ }) => PromiseLike<void> | void;
3645
+
3646
+ /**
3647
+ * Callback that is set using the `experimental_onToolCallFinish` option.
3648
+ *
3649
+ * Called when a tool execution completes, either successfully or with an error.
3650
+ * Use this for logging tool results, tracking execution time, or error handling.
3651
+ *
3652
+ * The event uses a discriminated union on the `success` field:
3653
+ * - When `success: true`: `output` contains the tool result, `error` is never present.
3654
+ * - When `success: false`: `error` contains the error, `output` is never present.
3655
+ *
3656
+ * @param event - The event object containing tool call result information.
3657
+ * @param event.stepNumber - Zero-based index of the current step where this tool call occurred.
3658
+ * @param event.model - Information about the model being used (provider and modelId).
3659
+ * @param event.toolCall - The full tool call object containing toolName, toolCallId, input, and metadata.
3660
+ * @param event.messages - The conversation messages available at tool execution time.
3661
+ * @param event.abortSignal - Signal for cancelling the operation.
3662
+ * @param event.durationMs - Execution time of the tool call in milliseconds.
3663
+ * @param event.functionId - Identifier from telemetry settings for grouping related operations.
3664
+ * @param event.metadata - Additional metadata from telemetry settings.
3665
+ * @param event.experimental_context - User-defined context object flowing through the generation.
3666
+ * @param event.success - Discriminator indicating whether the tool call succeeded.
3667
+ * @param event.output - The tool's return value (only present when `success: true`).
3668
+ * @param event.error - The error that occurred (only present when `success: false`).
3669
+ */
3670
+ export declare type GenerateTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (event: {
3671
+ /** Zero-based index of the current step where this tool call occurred. May be undefined in streaming contexts. */
3672
+ readonly stepNumber: number | undefined;
3673
+ /** Information about the model being used. May be undefined in streaming contexts. */
3674
+ readonly model: {
3675
+ /** The provider of the model. */
3676
+ readonly provider: string;
3677
+ /** The ID of the model. */
3678
+ readonly modelId: string;
3679
+ } | undefined;
3680
+ /** The full tool call object. */
3681
+ readonly toolCall: TypedToolCall<TOOLS>;
3682
+ /** The conversation messages available at tool execution time. */
3683
+ readonly messages: Array<ModelMessage>;
3684
+ /** Signal for cancelling the operation. */
3685
+ readonly abortSignal: AbortSignal | undefined;
3686
+ /** Execution time of the tool call in milliseconds. */
3687
+ readonly durationMs: number;
3688
+ /** Identifier from telemetry settings for grouping related operations. */
3689
+ readonly functionId: string | undefined;
3690
+ /** Additional metadata from telemetry settings. */
3691
+ readonly metadata: Record<string, unknown> | undefined;
3692
+ /** User-defined context object flowing through the generation. */
3693
+ readonly experimental_context: unknown;
3694
+ } & ({
3695
+ /** Indicates the tool call succeeded. */
3696
+ readonly success: true;
3697
+ /** The tool's return value. */
3698
+ readonly output: unknown;
3699
+ readonly error?: never;
3700
+ } | {
3701
+ /** Indicates the tool call failed. */
3702
+ readonly success: false;
3703
+ readonly output?: never;
3704
+ /** The error that occurred during tool execution. */
3705
+ readonly error: unknown;
3706
+ })) => PromiseLike<void> | void;
3707
+
3708
+ /**
3709
+ * Callback that is set using the `experimental_onToolCallStart` option.
3710
+ *
3711
+ * Called when a tool execution begins, before the tool's `execute` function is invoked.
3712
+ * Use this for logging tool invocations, tracking tool usage, or pre-execution validation.
3713
+ *
3714
+ * @param event - The event object containing tool call information.
3715
+ * @param event.stepNumber - Zero-based index of the current step where this tool call occurs.
3716
+ * @param event.model - Information about the model being used (provider and modelId).
3717
+ * @param event.toolCall - The full tool call object containing toolName, toolCallId, input, and metadata.
3718
+ * @param event.messages - The conversation messages available at tool execution time.
3719
+ * @param event.abortSignal - Signal for cancelling the operation.
3720
+ * @param event.functionId - Identifier from telemetry settings for grouping related operations.
3721
+ * @param event.metadata - Additional metadata from telemetry settings.
3722
+ * @param event.experimental_context - User-defined context object flowing through the generation.
3723
+ */
3724
+ export declare type GenerateTextOnToolCallStartCallback<TOOLS extends ToolSet = ToolSet> = (event: {
3725
+ /** Zero-based index of the current step where this tool call occurs. May be undefined in streaming contexts. */
3726
+ readonly stepNumber: number | undefined;
3727
+ /** Information about the model being used. May be undefined in streaming contexts. */
3728
+ readonly model: {
3729
+ /** The provider of the model. */
3730
+ readonly provider: string;
3731
+ /** The ID of the model. */
3732
+ readonly modelId: string;
3733
+ } | undefined;
3734
+ /** The full tool call object. */
3735
+ readonly toolCall: TypedToolCall<TOOLS>;
3736
+ /** The conversation messages available at tool execution time. */
3737
+ readonly messages: Array<ModelMessage>;
3738
+ /** Signal for cancelling the operation. */
3739
+ readonly abortSignal: AbortSignal | undefined;
3740
+ /** Identifier from telemetry settings for grouping related operations. */
3741
+ readonly functionId: string | undefined;
3742
+ /** Additional metadata from telemetry settings. */
3743
+ readonly metadata: Record<string, unknown> | undefined;
3744
+ /** User-defined context object flowing through the generation. */
3745
+ readonly experimental_context: unknown;
3746
+ }) => PromiseLike<void> | void;
3747
+
3427
3748
  /**
3428
3749
  * The result of a `generateText` call.
3429
3750
  * It contains the generated text, the tool calls that were made during the generation, and the results of the tool calls.
@@ -9492,6 +9813,33 @@ export declare function stepCountIs(stepCount: number): StopCondition<any>;
9492
9813
  * The result of a single step in the generation process.
9493
9814
  */
9494
9815
  export declare type StepResult<TOOLS extends ToolSet> = {
9816
+ /**
9817
+ * Zero-based index of this step.
9818
+ */
9819
+ readonly stepNumber: number;
9820
+ /**
9821
+ * Information about the model that produced this step.
9822
+ */
9823
+ readonly model: {
9824
+ /** The provider of the model. */
9825
+ readonly provider: string;
9826
+ /** The ID of the model. */
9827
+ readonly modelId: string;
9828
+ };
9829
+ /**
9830
+ * Identifier from telemetry settings for grouping related operations.
9831
+ */
9832
+ readonly functionId: string | undefined;
9833
+ /**
9834
+ * Additional metadata from telemetry settings.
9835
+ */
9836
+ readonly metadata: Record<string, unknown> | undefined;
9837
+ /**
9838
+ * User-defined context object flowing through the generation.
9839
+ *
9840
+ * Experimental (can break in patch releases).
9841
+ */
9842
+ readonly experimental_context: unknown;
9495
9843
  /**
9496
9844
  * The content that was generated in the last step.
9497
9845
  */
@@ -13035,5 +13383,5 @@ export declare function zodSchema<OBJECT>(zodSchema: z4.core.$ZodType<OBJECT, an
13035
13383
  }): Schema<OBJECT>;
13036
13384
 
13037
13385
  export { }
13038
- export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider, LazySchema as LazySchema, ZodSchema as ZodSchema, StandardSchema as StandardSchema, ValidationResult as ValidationResult, ParseResult as ParseResult, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, ToolOutputProperties as ToolOutputProperties, ToolResultOutput as ToolResultOutput, ToolNeedsApprovalFunction as ToolNeedsApprovalFunction, TypeValidationContext as TypeValidationContext, JSONSchema7Version as JSONSchema7Version, JSONSchema7Definition as JSONSchema7Definition, JSONSchema7TypeName as JSONSchema7TypeName, JSONSchema7Type as JSONSchema7Type, EmbeddingModelV2 as EmbeddingModelV2, EmbeddingModelV3Embedding as EmbeddingModelV3Embedding, EmbeddingModelV3Middleware as EmbeddingModelV3Middleware, ImageModelV2 as ImageModelV2, ImageModelV3ProviderMetadata as ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata as ImageModelV2ProviderMetadata, ImageModelV3Middleware as ImageModelV3Middleware, GlobalProviderModelId as GlobalProviderModelId, LanguageModelV2 as LanguageModelV2, SharedV3Warning as SharedV3Warning, LanguageModelV3Middleware as LanguageModelV3Middleware, SharedV3ProviderMetadata as SharedV3ProviderMetadata, SpeechModelV2 as SpeechModelV2, TranscriptionModelV2 as TranscriptionModelV2, ImageModelV3Usage as ImageModelV3Usage, BaseToolCall as BaseToolCall, Source as Source, DeepPartialInternal as DeepPartialInternal, AttributeValue as AttributeValue, Tracer as Tracer, LanguageModelV3ToolCall as LanguageModelV3ToolCall, ValueOf as ValueOf, asUITool as asUITool, _ai_sdk_provider_utils as _ai_sdk_provider_utils, _ai_sdk_provider as _ai_sdk_provider, DataUIMessageChunk as DataUIMessageChunk, InferElementOutput as InferElementOutput, ConsumeStreamOptions as ConsumeStreamOptions, StreamTextOnAbortCallback as StreamTextOnAbortCallback, ResponseMessage as ResponseMessage, Output_2 as Output_2, MaybePromiseLike as MaybePromiseLike, InferAgentTools as InferAgentTools, UIMessageStreamResponseInit as UIMessageStreamResponseInit, getOriginalFetch as getOriginalFetch, InferUIMessageToolCall as InferUIMessageToolCall, UIDataTypesToSchemas as UIDataTypesToSchemas, InferUIMessageData as InferUIMessageData, InferUIMessageMetadata as InferUIMessageMetadata, InferUIMessageTools as InferUIMessageTools, Resolvable as Resolvable, FetchFunction as FetchFunction, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, GenerateImagePrompt as GenerateImagePrompt, JSONValue_2 as JSONValue_2, Job as Job, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, VideoModelResponseMetadata as VideoModelResponseMetadata, VideoModelProviderMetadata as VideoModelProviderMetadata, VideoModel as VideoModel, EmbeddingModelV3CallOptions as EmbeddingModelV3CallOptions, LanguageModelV3CallOptions as LanguageModelV3CallOptions, JSONObject as JSONObject, LanguageModelV3 as LanguageModelV3, EmbeddingModelV3 as EmbeddingModelV3, ImageModelV3 as ImageModelV3, TranscriptionModelV3 as TranscriptionModelV3, SpeechModelV3 as SpeechModelV3, RerankingModelV3 as RerankingModelV3, VideoModelV3 as VideoModelV3, ProviderV2 as ProviderV2, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV3 as ProviderV3 };
13386
+ export { GatewayProviderSettings as GatewayProviderSettings, GatewayProvider as GatewayProvider, LazySchema as LazySchema, ZodSchema as ZodSchema, StandardSchema as StandardSchema, ValidationResult as ValidationResult, ParseResult as ParseResult, ProviderOptions as ProviderOptions, ReasoningPart as ReasoningPart, ToolOutputProperties as ToolOutputProperties, ToolResultOutput as ToolResultOutput, ToolNeedsApprovalFunction as ToolNeedsApprovalFunction, TypeValidationContext as TypeValidationContext, JSONSchema7Version as JSONSchema7Version, JSONSchema7Definition as JSONSchema7Definition, JSONSchema7TypeName as JSONSchema7TypeName, JSONSchema7Type as JSONSchema7Type, EmbeddingModelV2 as EmbeddingModelV2, EmbeddingModelV3Embedding as EmbeddingModelV3Embedding, EmbeddingModelV3Middleware as EmbeddingModelV3Middleware, ImageModelV2 as ImageModelV2, ImageModelV3ProviderMetadata as ImageModelV3ProviderMetadata, ImageModelV2ProviderMetadata as ImageModelV2ProviderMetadata, ImageModelV3Middleware as ImageModelV3Middleware, GlobalProviderModelId as GlobalProviderModelId, LanguageModelV2 as LanguageModelV2, SharedV3Warning as SharedV3Warning, LanguageModelV3Middleware as LanguageModelV3Middleware, SharedV3ProviderMetadata as SharedV3ProviderMetadata, SpeechModelV2 as SpeechModelV2, TranscriptionModelV2 as TranscriptionModelV2, ImageModelV3Usage as ImageModelV3Usage, BaseToolCall as BaseToolCall, Source as Source, DeepPartialInternal as DeepPartialInternal, AttributeValue as AttributeValue, Tracer as Tracer, LanguageModelV3ToolCall as LanguageModelV3ToolCall, LanguageModelV3ToolChoice as LanguageModelV3ToolChoice, ValueOf as ValueOf, asUITool as asUITool, _ai_sdk_provider_utils as _ai_sdk_provider_utils, _ai_sdk_provider as _ai_sdk_provider, DataUIMessageChunk as DataUIMessageChunk, InferElementOutput as InferElementOutput, ConsumeStreamOptions as ConsumeStreamOptions, StreamTextOnAbortCallback as StreamTextOnAbortCallback, ResponseMessage as ResponseMessage, Output_2 as Output_2, MaybePromiseLike as MaybePromiseLike, InferAgentTools as InferAgentTools, UIMessageStreamResponseInit as UIMessageStreamResponseInit, getOriginalFetch as getOriginalFetch, InferUIMessageToolCall as InferUIMessageToolCall, UIDataTypesToSchemas as UIDataTypesToSchemas, InferUIMessageData as InferUIMessageData, InferUIMessageMetadata as InferUIMessageMetadata, InferUIMessageTools as InferUIMessageTools, Resolvable as Resolvable, FetchFunction as FetchFunction, SingleRequestTextStreamPart as SingleRequestTextStreamPart, RetryErrorReason as RetryErrorReason, GenerateImagePrompt as GenerateImagePrompt, JSONValue_2 as JSONValue_2, Job as Job, StreamObjectOnErrorCallback as StreamObjectOnErrorCallback, VideoModelResponseMetadata as VideoModelResponseMetadata, VideoModelProviderMetadata as VideoModelProviderMetadata, VideoModel as VideoModel, EmbeddingModelV3CallOptions as EmbeddingModelV3CallOptions, LanguageModelV3CallOptions as LanguageModelV3CallOptions, JSONObject as JSONObject, LanguageModelV3 as LanguageModelV3, EmbeddingModelV3 as EmbeddingModelV3, ImageModelV3 as ImageModelV3, TranscriptionModelV3 as TranscriptionModelV3, SpeechModelV3 as SpeechModelV3, RerankingModelV3 as RerankingModelV3, VideoModelV3 as VideoModelV3, ProviderV2 as ProviderV2, ExtractModelId as ExtractModelId, ExtractLiteralUnion as ExtractLiteralUnion, ProviderV3 as ProviderV3 };
13039
13387
  export { schemaSymbol, symbol$1, symbol$1_2, symbol$2, symbol$2_2, symbol$3, symbol$3_2, symbol$4, symbol$4_2, symbol$5, symbol$5_2, symbol$6, symbol$6_2, symbol$7, symbol$7_2, symbol$8, symbol$8_2, symbol$9, symbol$9_2, symbol$a, symbol$a_2, symbol$b, symbol$b_2, symbol$c, symbol$c_2, symbol$d, symbol$d_2, symbol$e, symbol$f, symbol$g, symbol$h, symbol$i, symbol$j, symbol, symbol_2, symbol_3 };
package/dist/index.cjs CHANGED
@@ -5244,7 +5244,7 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer3 {
5244
5244
  return `jsonSchema7`;
5245
5245
  }
5246
5246
  shouldApply() {
5247
- if (!this.getModel().supportsStructuredOutputs && (this.getModel().provider.includes(`openai`) || this.getModel().modelId.includes(`openai`))) {
5247
+ if (!this.getModel().supportsStructuredOutputs && (this.getModel().provider.includes(`openai`) || this.getModel().modelId.includes(`openai`) || this.getModel().provider.includes(`groq`))) {
5248
5248
  return true;
5249
5249
  }
5250
5250
  return false;