@mastra/schema-compat 1.1.3 → 1.2.0

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 (81) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/LICENSE.md +15 -0
  3. package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +7562 -0
  4. package/dist/_types/@internal_ai-v6/dist/index.d.ts +449 -343
  5. package/dist/chunk-23HDOZLF.js +105 -0
  6. package/dist/chunk-23HDOZLF.js.map +1 -0
  7. package/dist/chunk-3MLZICLP.cjs +94 -0
  8. package/dist/chunk-3MLZICLP.cjs.map +1 -0
  9. package/dist/chunk-3QMIGINL.cjs +123 -0
  10. package/dist/chunk-3QMIGINL.cjs.map +1 -0
  11. package/dist/{chunk-4EY4LZB2.js → chunk-7ZCSAPV3.js} +76 -3
  12. package/dist/chunk-7ZCSAPV3.js.map +1 -0
  13. package/dist/chunk-FKB2Z36H.cjs +68 -0
  14. package/dist/chunk-FKB2Z36H.cjs.map +1 -0
  15. package/dist/chunk-FS3P4V5M.cjs +108 -0
  16. package/dist/chunk-FS3P4V5M.cjs.map +1 -0
  17. package/dist/chunk-I2YUBGXM.js +112 -0
  18. package/dist/chunk-I2YUBGXM.js.map +1 -0
  19. package/dist/chunk-IKQO7EW7.js +62 -0
  20. package/dist/chunk-IKQO7EW7.js.map +1 -0
  21. package/dist/chunk-K7I3YXWP.js +92 -0
  22. package/dist/chunk-K7I3YXWP.js.map +1 -0
  23. package/dist/{chunk-DGOXVQNP.js → chunk-QDRBTCDV.js} +158 -479
  24. package/dist/chunk-QDRBTCDV.js.map +1 -0
  25. package/dist/{chunk-DAVEUCUM.cjs → chunk-ROFMEFEF.cjs} +160 -488
  26. package/dist/chunk-ROFMEFEF.cjs.map +1 -0
  27. package/dist/{chunk-BOGGUXB5.cjs → chunk-UFJG5KPA.cjs} +77 -2
  28. package/dist/chunk-UFJG5KPA.cjs.map +1 -0
  29. package/dist/index.cjs +626 -337
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +6 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +580 -325
  34. package/dist/index.js.map +1 -1
  35. package/dist/json-schema/utils.d.ts +8 -0
  36. package/dist/json-schema/utils.d.ts.map +1 -1
  37. package/dist/null-to-undefined.d.ts +24 -0
  38. package/dist/null-to-undefined.d.ts.map +1 -0
  39. package/dist/provider-compats/google.d.ts +3 -0
  40. package/dist/provider-compats/google.d.ts.map +1 -1
  41. package/dist/provider-compats/openai-reasoning.d.ts +5 -5
  42. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -1
  43. package/dist/provider-compats/openai.d.ts +8 -0
  44. package/dist/provider-compats/openai.d.ts.map +1 -1
  45. package/dist/schema-compatibility-v3.d.ts +2 -2
  46. package/dist/schema-compatibility-v3.d.ts.map +1 -1
  47. package/dist/schema-compatibility.d.ts +2 -1
  48. package/dist/schema-compatibility.d.ts.map +1 -1
  49. package/dist/schema.cjs +16 -4
  50. package/dist/schema.d.ts +1 -1
  51. package/dist/schema.d.ts.map +1 -1
  52. package/dist/schema.js +1 -1
  53. package/dist/schema.types.d.ts +4 -2
  54. package/dist/schema.types.d.ts.map +1 -1
  55. package/dist/standard-schema/adapters/ai-sdk.cjs +16 -0
  56. package/dist/standard-schema/adapters/ai-sdk.cjs.map +1 -0
  57. package/dist/standard-schema/adapters/ai-sdk.js +3 -0
  58. package/dist/standard-schema/adapters/ai-sdk.js.map +1 -0
  59. package/dist/standard-schema/adapters/json-schema.cjs +16 -0
  60. package/dist/standard-schema/adapters/json-schema.cjs.map +1 -0
  61. package/dist/standard-schema/adapters/json-schema.d.ts.map +1 -1
  62. package/dist/standard-schema/adapters/json-schema.js +3 -0
  63. package/dist/standard-schema/adapters/json-schema.js.map +1 -0
  64. package/dist/standard-schema/adapters/zod-v3.cjs +12 -0
  65. package/dist/standard-schema/adapters/zod-v3.cjs.map +1 -0
  66. package/dist/standard-schema/adapters/zod-v3.js +3 -0
  67. package/dist/standard-schema/adapters/zod-v3.js.map +1 -0
  68. package/dist/standard-schema/standard-schema.d.ts.map +1 -1
  69. package/dist/standard-schema-compat.d.ts +74 -0
  70. package/dist/standard-schema-compat.d.ts.map +1 -0
  71. package/dist/utils.d.ts +3 -2
  72. package/dist/utils.d.ts.map +1 -1
  73. package/dist/zod-to-json.cjs +10 -2
  74. package/dist/zod-to-json.d.ts +13 -0
  75. package/dist/zod-to-json.d.ts.map +1 -1
  76. package/dist/zod-to-json.js +1 -1
  77. package/package.json +41 -10
  78. package/dist/chunk-4EY4LZB2.js.map +0 -1
  79. package/dist/chunk-BOGGUXB5.cjs.map +0 -1
  80. package/dist/chunk-DAVEUCUM.cjs.map +0 -1
  81. package/dist/chunk-DGOXVQNP.js.map +0 -1
@@ -229,10 +229,30 @@ CALL_OPTIONS
229
229
  * Timeout in milliseconds. Can be specified as a number or as an object with `totalMs`.
230
230
  */
231
231
  timeout?: TimeoutConfiguration;
232
+ /**
233
+ * Callback that is called when the agent operation begins, before any LLM calls.
234
+ */
235
+ experimental_onStart?: ToolLoopAgentOnStartCallback<TOOLS>;
236
+ /**
237
+ * Callback that is called when a step (LLM call) begins, before the provider is called.
238
+ */
239
+ experimental_onStepStart?: ToolLoopAgentOnStepStartCallback<TOOLS>;
240
+ /**
241
+ * Callback that is called before each tool execution begins.
242
+ */
243
+ experimental_onToolCallStart?: ToolLoopAgentOnToolCallStartCallback<TOOLS>;
244
+ /**
245
+ * Callback that is called after each tool execution completes.
246
+ */
247
+ experimental_onToolCallFinish?: ToolLoopAgentOnToolCallFinishCallback<TOOLS>;
232
248
  /**
233
249
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
234
250
  */
235
251
  onStepFinish?: ToolLoopAgentOnStepFinishCallback<TOOLS>;
252
+ /**
253
+ * Callback that is called when all steps are finished and the response is complete.
254
+ */
255
+ onFinish?: ToolLoopAgentOnFinishCallback<TOOLS>;
236
256
  };
237
257
 
238
258
  /**
@@ -473,7 +493,9 @@ declare namespace _ai_sdk_provider_utils {
473
493
  resolve,
474
494
  safeParseJSON,
475
495
  safeValidateTypes,
496
+ stripFileExtension,
476
497
  tool,
498
+ validateDownloadUrl,
477
499
  validateTypes,
478
500
  withUserAgentSuffix,
479
501
  withoutTrailingSlash,
@@ -595,6 +617,23 @@ declare type BaseToolCall = {
595
617
  providerMetadata?: ProviderMetadata;
596
618
  };
597
619
 
620
+ /**
621
+ * Wraps a telemetry integration with bound methods.
622
+ * Use this when creating class-based integrations to ensure methods
623
+ * work correctly when passed as callbacks.
624
+ */
625
+ export declare function bindTelemetryIntegration(integration: TelemetryIntegration): TelemetryIntegration;
626
+
627
+ /**
628
+ * Common model information used across callback events.
629
+ */
630
+ declare interface CallbackModelInfo {
631
+ /** The provider identifier (e.g., 'openai', 'anthropic'). */
632
+ readonly provider: string;
633
+ /** The specific model identifier (e.g., 'gpt-4o'). */
634
+ readonly modelId: string;
635
+ }
636
+
598
637
  export declare function callCompletionApi({ api, prompt, credentials, headers, body, streamProtocol, setCompletion, setLoading, setError, setAbortController, onFinish, onError, fetch, }: {
599
638
  api: string;
600
639
  prompt: string;
@@ -1229,7 +1268,7 @@ export declare function createTextStreamResponse({ status, statusText, headers,
1229
1268
  * @param tools - Tools that were passed to the language model.
1230
1269
  * @param providerToolNames - Maps the provider tool ids to the provider tool names.
1231
1270
  */
1232
- declare function createToolNameMapping({ tools, providerToolNames, }: {
1271
+ declare function createToolNameMapping({ tools, providerToolNames, resolveProviderToolName, }: {
1233
1272
  /**
1234
1273
  * Tools that were passed to the language model.
1235
1274
  */
@@ -1238,6 +1277,11 @@ declare function createToolNameMapping({ tools, providerToolNames, }: {
1238
1277
  * Maps the provider tool ids to the provider tool names.
1239
1278
  */
1240
1279
  providerToolNames: Record<`${string}.${string}`, string>;
1280
+ /**
1281
+ * Optional resolver for provider tool names that cannot be represented as
1282
+ * static id -> name mappings (e.g. dynamic provider names).
1283
+ */
1284
+ resolveProviderToolName?: (tool: LanguageModelV3ProviderTool) => string | undefined;
1241
1285
  }): ToolNameMapping;
1242
1286
 
1243
1287
  export declare type CreateUIMessage<UI_MESSAGE extends UIMessage> = Omit<UI_MESSAGE, 'id' | 'role'> & {
@@ -2746,13 +2790,13 @@ declare interface GatewayCreditsResponse {
2746
2790
  totalUsed: string;
2747
2791
  }
2748
2792
 
2749
- declare type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | 'voyage/voyage-3-large' | 'voyage/voyage-3.5' | 'voyage/voyage-3.5-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
2793
+ declare type GatewayEmbeddingModelId = 'alibaba/qwen3-embedding-0.6b' | 'alibaba/qwen3-embedding-4b' | 'alibaba/qwen3-embedding-8b' | 'amazon/titan-embed-text-v2' | 'cohere/embed-v4.0' | 'google/gemini-embedding-001' | 'google/text-embedding-005' | 'google/text-multilingual-embedding-002' | 'mistral/codestral-embed' | 'mistral/mistral-embed' | 'openai/text-embedding-3-large' | 'openai/text-embedding-3-small' | 'openai/text-embedding-ada-002' | 'voyage/voyage-3-large' | 'voyage/voyage-3.5' | 'voyage/voyage-3.5-lite' | 'voyage/voyage-4' | 'voyage/voyage-4-large' | 'voyage/voyage-4-lite' | 'voyage/voyage-code-2' | 'voyage/voyage-code-3' | 'voyage/voyage-finance-2' | 'voyage/voyage-law-2' | (string & {});
2750
2794
 
2751
2795
  declare interface GatewayFetchMetadataResponse {
2752
2796
  models: GatewayLanguageModelEntry[];
2753
2797
  }
2754
2798
 
2755
- declare type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'xai/grok-imagine-image' | 'xai/grok-imagine-image-pro' | (string & {});
2799
+ declare type GatewayImageModelId = 'bfl/flux-kontext-max' | 'bfl/flux-kontext-pro' | 'bfl/flux-pro-1.0-fill' | 'bfl/flux-pro-1.1' | 'bfl/flux-pro-1.1-ultra' | 'google/imagen-4.0-fast-generate-001' | 'google/imagen-4.0-generate-001' | 'google/imagen-4.0-ultra-generate-001' | 'openai/gpt-image-1' | 'openai/gpt-image-1-mini' | 'openai/gpt-image-1.5' | 'recraft/recraft-v2' | 'recraft/recraft-v3' | 'recraft/recraft-v4' | 'recraft/recraft-v4-pro' | 'xai/grok-imagine-image' | 'xai/grok-imagine-image-pro' | (string & {});
2756
2800
 
2757
2801
  declare interface GatewayLanguageModelEntry {
2758
2802
  /**
@@ -2803,7 +2847,7 @@ declare interface GatewayLanguageModelEntry {
2803
2847
 
2804
2848
  declare type GatewayLanguageModelSpecification = Pick<LanguageModelV3, 'specificationVersion' | 'provider' | 'modelId'>;
2805
2849
 
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 & {});
2850
+ 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-flash' | '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-flash-image-preview' | 'google/gemini-3.1-flash-lite-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-5.3-chat' | 'openai/gpt-5.3-codex' | '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
2851
 
2808
2852
  declare interface GatewayProvider extends ProviderV3 {
2809
2853
  (modelId: GatewayModelId): LanguageModelV3;
@@ -2904,7 +2948,7 @@ declare const gatewayTools: {
2904
2948
  perplexitySearch: (config?: PerplexitySearchConfig) => ReturnType<typeof perplexitySearchToolFactory>;
2905
2949
  };
2906
2950
 
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 & {});
2951
+ 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' | 'bytedance/seedance-v1.0-lite-i2v' | 'bytedance/seedance-v1.0-lite-t2v' | 'bytedance/seedance-v1.0-pro' | 'bytedance/seedance-v1.0-pro-fast' | 'bytedance/seedance-v1.5-pro' | '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-motion-control' | 'klingai/kling-v2.6-t2v' | 'klingai/kling-v3.0-i2v' | 'klingai/kling-v3.0-t2v' | 'xai/grok-imagine-video' | (string & {});
2908
2952
 
2909
2953
  /**
2910
2954
  * A generated audio file.
@@ -3419,6 +3463,14 @@ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Outpu
3419
3463
  };
3420
3464
  }): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
3421
3465
 
3466
+ /**
3467
+ * Include settings for generateText (requestBody and responseBody).
3468
+ */
3469
+ declare type GenerateTextIncludeSettings = {
3470
+ requestBody?: boolean;
3471
+ responseBody?: boolean;
3472
+ };
3473
+
3422
3474
  /**
3423
3475
  * Callback that is set using the `onFinish` option.
3424
3476
  *
@@ -3427,55 +3479,8 @@ export declare function generateText<TOOLS extends ToolSet, OUTPUT extends Outpu
3427
3479
  * aggregated data from all steps.
3428
3480
  *
3429
3481
  * @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.
3453
- */
3454
- export declare type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
3455
- /**
3456
- * Array containing results from all steps in the generation.
3457
- */
3458
- readonly steps: StepResult<TOOLS>[];
3459
- /**
3460
- * Aggregated token usage across all steps.
3461
- * This is the sum of the usage from each individual step.
3462
- */
3463
- readonly totalUsage: LanguageModelUsage;
3464
- /**
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.
3468
- *
3469
- * Experimental (can break in patch releases).
3470
- *
3471
- * @default undefined
3472
- */
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;
3482
+ */
3483
+ export declare type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
3479
3484
 
3480
3485
  /**
3481
3486
  * Callback that is set using the `experimental_onStart` option.
@@ -3486,80 +3491,7 @@ export declare type GenerateTextOnFinishCallback<TOOLS extends ToolSet> = (event
3486
3491
  *
3487
3492
  * @param event - The event object containing generation configuration.
3488
3493
  */
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;
3562
- }) => PromiseLike<void> | void;
3494
+ export declare type GenerateTextOnStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStartEvent<TOOLS, OUTPUT, GenerateTextIncludeSettings>) => PromiseLike<void> | void;
3563
3495
 
3564
3496
  /**
3565
3497
  * Callback that is set using the `onStepFinish` option.
@@ -3569,7 +3501,7 @@ export declare type GenerateTextOnStartCallback<TOOLS extends ToolSet = ToolSet,
3569
3501
  *
3570
3502
  * @param stepResult - The result of the step.
3571
3503
  */
3572
- export declare type GenerateTextOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
3504
+ export declare type GenerateTextOnStepFinishCallback<TOOLS extends ToolSet> = (event: OnStepFinishEvent<TOOLS>) => Promise<void> | void;
3573
3505
 
3574
3506
  /**
3575
3507
  * Callback that is set using the `experimental_onStepStart` option.
@@ -3580,68 +3512,7 @@ export declare type GenerateTextOnStepFinishCallback<TOOLS extends ToolSet> = (s
3580
3512
  *
3581
3513
  * @param event - The event object containing step configuration.
3582
3514
  */
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;
3515
+ export declare type GenerateTextOnStepStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStepStartEvent<TOOLS, OUTPUT, GenerateTextIncludeSettings>) => PromiseLike<void> | void;
3645
3516
 
3646
3517
  /**
3647
3518
  * Callback that is set using the `experimental_onToolCallFinish` option.
@@ -3654,56 +3525,8 @@ export declare type GenerateTextOnStepStartCallback<TOOLS extends ToolSet = Tool
3654
3525
  * - When `success: false`: `error` contains the error, `output` is never present.
3655
3526
  *
3656
3527
  * @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;
3528
+ */
3529
+ export declare type GenerateTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallFinishEvent<TOOLS>) => PromiseLike<void> | void;
3707
3530
 
3708
3531
  /**
3709
3532
  * Callback that is set using the `experimental_onToolCallStart` option.
@@ -3712,38 +3535,8 @@ export declare type GenerateTextOnToolCallFinishCallback<TOOLS extends ToolSet =
3712
3535
  * Use this for logging tool invocations, tracking tool usage, or pre-execution validation.
3713
3536
  *
3714
3537
  * @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;
3538
+ */
3539
+ export declare type GenerateTextOnToolCallStartCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallStartEvent<TOOLS>) => PromiseLike<void> | void;
3747
3540
 
3748
3541
  /**
3749
3542
  * The result of a `generateText` call.
@@ -7096,6 +6889,11 @@ declare interface Link {
7096
6889
  droppedAttributesCount?: number;
7097
6890
  }
7098
6891
 
6892
+ /**
6893
+ * A callback function that can be used to notify listeners.
6894
+ */
6895
+ declare type Listener<EVENT> = (event: EVENT) => PromiseLike<void> | void;
6896
+
7099
6897
  declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description, }: {
7100
6898
  apiKey: string | undefined;
7101
6899
  environmentVariableName: string;
@@ -7415,22 +7213,256 @@ export declare type ObjectStreamPart<PARTIAL> = {
7415
7213
  providerMetadata?: ProviderMetadata;
7416
7214
  };
7417
7215
 
7418
- export declare namespace Output {
7419
- export {
7420
- output_Output as Output,
7421
- output_array as array,
7422
- output_choice as choice,
7423
- output_json as json,
7424
- output_object as object,
7425
- output_text as text,
7426
- };
7427
- }
7428
-
7429
- declare interface Output_2<OUTPUT = any, PARTIAL = any, ELEMENT = any> {
7216
+ /**
7217
+ * Event passed to the `onFinish` callback.
7218
+ *
7219
+ * Called when the entire generation completes (all steps finished).
7220
+ * Includes the final step's result along with aggregated data from all steps.
7221
+ */
7222
+ export declare type OnFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS> & {
7223
+ /** Array containing results from all steps in the generation. */
7224
+ readonly steps: StepResult<TOOLS>[];
7225
+ /** Aggregated token usage across all steps. */
7226
+ readonly totalUsage: LanguageModelUsage;
7430
7227
  /**
7431
- * The name of the output mode.
7228
+ * The final state of the user-defined context object.
7229
+ *
7230
+ * Experimental (can break in patch releases).
7231
+ *
7232
+ * @default undefined
7432
7233
  */
7433
- name: string;
7234
+ experimental_context: unknown;
7235
+ /** Identifier from telemetry settings for grouping related operations. */
7236
+ readonly functionId: string | undefined;
7237
+ /** Additional metadata from telemetry settings. */
7238
+ readonly metadata: Record<string, unknown> | undefined;
7239
+ };
7240
+
7241
+ /**
7242
+ * Event passed to the `onStart` callback.
7243
+ *
7244
+ * Called when the generation operation begins, before any LLM calls.
7245
+ */
7246
+ export declare interface OnStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2, INCLUDE = {
7247
+ requestBody?: boolean;
7248
+ responseBody?: boolean;
7249
+ }> {
7250
+ /** The model being used for generation. */
7251
+ readonly model: CallbackModelInfo;
7252
+ /** The system message(s) provided to the model. */
7253
+ readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
7254
+ /** The prompt string or array of messages if using the prompt option. */
7255
+ readonly prompt: string | Array<ModelMessage> | undefined;
7256
+ /** The messages array if using the messages option. */
7257
+ readonly messages: Array<ModelMessage> | undefined;
7258
+ /** The tools available for this generation. */
7259
+ readonly tools: TOOLS | undefined;
7260
+ /** The tool choice strategy for this generation. */
7261
+ readonly toolChoice: ToolChoice<NoInfer<TOOLS>> | undefined;
7262
+ /** Limits which tools are available for the model to call. */
7263
+ readonly activeTools: Array<keyof TOOLS> | undefined;
7264
+ /** Maximum number of tokens to generate. */
7265
+ readonly maxOutputTokens: number | undefined;
7266
+ /** Sampling temperature for generation. */
7267
+ readonly temperature: number | undefined;
7268
+ /** Top-p (nucleus) sampling parameter. */
7269
+ readonly topP: number | undefined;
7270
+ /** Top-k sampling parameter. */
7271
+ readonly topK: number | undefined;
7272
+ /** Presence penalty for generation. */
7273
+ readonly presencePenalty: number | undefined;
7274
+ /** Frequency penalty for generation. */
7275
+ readonly frequencyPenalty: number | undefined;
7276
+ /** Sequences that will stop generation. */
7277
+ readonly stopSequences: string[] | undefined;
7278
+ /** Random seed for reproducible generation. */
7279
+ readonly seed: number | undefined;
7280
+ /** Maximum number of retries for failed requests. */
7281
+ readonly maxRetries: number;
7282
+ /**
7283
+ * Timeout configuration for the generation.
7284
+ * Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
7285
+ */
7286
+ readonly timeout: TimeoutConfiguration | undefined;
7287
+ /** Additional HTTP headers sent with the request. */
7288
+ readonly headers: Record<string, string | undefined> | undefined;
7289
+ /** Additional provider-specific options. */
7290
+ readonly providerOptions: ProviderOptions | undefined;
7291
+ /**
7292
+ * Condition(s) for stopping the generation.
7293
+ * When the condition is an array, any of the conditions can be met to stop.
7294
+ */
7295
+ readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
7296
+ /** The output specification for structured outputs, if configured. */
7297
+ readonly output: OUTPUT | undefined;
7298
+ /** Abort signal for cancelling the operation. */
7299
+ readonly abortSignal: AbortSignal | undefined;
7300
+ /**
7301
+ * Settings for controlling what data is included in step results.
7302
+ */
7303
+ readonly include: INCLUDE | undefined;
7304
+ /** Identifier from telemetry settings for grouping related operations. */
7305
+ readonly functionId: string | undefined;
7306
+ /** Additional metadata passed to the generation. */
7307
+ readonly metadata: Record<string, unknown> | undefined;
7308
+ /**
7309
+ * User-defined context object that flows through the entire generation lifecycle.
7310
+ * Can be accessed and modified in `prepareStep` and tool `execute` functions.
7311
+ */
7312
+ readonly experimental_context: unknown;
7313
+ }
7314
+
7315
+ /**
7316
+ * Event passed to the `onStepFinish` callback.
7317
+ *
7318
+ * Called when a step (LLM call) completes.
7319
+ * This is simply the StepResult for that step.
7320
+ */
7321
+ export declare type OnStepFinishEvent<TOOLS extends ToolSet = ToolSet> = StepResult<TOOLS>;
7322
+
7323
+ /**
7324
+ * Event passed to the `onStepStart` callback.
7325
+ *
7326
+ * Called when a step (LLM call) begins, before the provider is called.
7327
+ * Each step represents a single LLM invocation.
7328
+ */
7329
+ export declare interface OnStepStartEvent<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2, INCLUDE = {
7330
+ requestBody?: boolean;
7331
+ responseBody?: boolean;
7332
+ }> {
7333
+ /** Zero-based index of the current step. */
7334
+ readonly stepNumber: number;
7335
+ /** The model being used for this step. */
7336
+ readonly model: CallbackModelInfo;
7337
+ /**
7338
+ * The system message for this step.
7339
+ */
7340
+ readonly system: string | SystemModelMessage | Array<SystemModelMessage> | undefined;
7341
+ /**
7342
+ * The messages that will be sent to the model for this step.
7343
+ * Uses the user-facing `ModelMessage` format.
7344
+ * May be overridden by prepareStep.
7345
+ */
7346
+ readonly messages: Array<ModelMessage>;
7347
+ /** The tools available for this generation. */
7348
+ readonly tools: TOOLS | undefined;
7349
+ /** The tool choice configuration for this step. */
7350
+ readonly toolChoice: LanguageModelV3ToolChoice | undefined;
7351
+ /** Limits which tools are available for this step. */
7352
+ readonly activeTools: Array<keyof TOOLS> | undefined;
7353
+ /** Array of results from previous steps (empty for first step). */
7354
+ readonly steps: ReadonlyArray<StepResult<TOOLS>>;
7355
+ /** Additional provider-specific options for this step. */
7356
+ readonly providerOptions: ProviderOptions | undefined;
7357
+ /**
7358
+ * Timeout configuration for the generation.
7359
+ * Can be a number (milliseconds) or an object with totalMs, stepMs, chunkMs.
7360
+ */
7361
+ readonly timeout: TimeoutConfiguration | undefined;
7362
+ /** Additional HTTP headers sent with the request. */
7363
+ readonly headers: Record<string, string | undefined> | undefined;
7364
+ /**
7365
+ * Condition(s) for stopping the generation.
7366
+ * When the condition is an array, any of the conditions can be met to stop.
7367
+ */
7368
+ readonly stopWhen: StopCondition<TOOLS> | Array<StopCondition<TOOLS>> | undefined;
7369
+ /** The output specification for structured outputs, if configured. */
7370
+ readonly output: OUTPUT | undefined;
7371
+ /** Abort signal for cancelling the operation. */
7372
+ readonly abortSignal: AbortSignal | undefined;
7373
+ /**
7374
+ * Settings for controlling what data is included in step results.
7375
+ */
7376
+ readonly include: INCLUDE | undefined;
7377
+ /** Identifier from telemetry settings for grouping related operations. */
7378
+ readonly functionId: string | undefined;
7379
+ /** Additional metadata from telemetry settings. */
7380
+ readonly metadata: Record<string, unknown> | undefined;
7381
+ /**
7382
+ * User-defined context object. May be updated from `prepareStep` between steps.
7383
+ */
7384
+ readonly experimental_context: unknown;
7385
+ }
7386
+
7387
+ /**
7388
+ * Event passed to the `onToolCallFinish` callback.
7389
+ *
7390
+ * Called when a tool execution completes, either successfully or with an error.
7391
+ * Uses a discriminated union on the `success` field.
7392
+ */
7393
+ export declare type OnToolCallFinishEvent<TOOLS extends ToolSet = ToolSet> = {
7394
+ /** Zero-based index of the current step where this tool call occurred. */
7395
+ readonly stepNumber: number | undefined;
7396
+ /** The model being used for this step. */
7397
+ readonly model: CallbackModelInfo | undefined;
7398
+ /** The full tool call object. */
7399
+ readonly toolCall: TypedToolCall<TOOLS>;
7400
+ /** The conversation messages available at tool execution time. */
7401
+ readonly messages: Array<ModelMessage>;
7402
+ /** Signal for cancelling the operation. */
7403
+ readonly abortSignal: AbortSignal | undefined;
7404
+ /** Execution time of the tool call in milliseconds. */
7405
+ readonly durationMs: number;
7406
+ /** Identifier from telemetry settings for grouping related operations. */
7407
+ readonly functionId: string | undefined;
7408
+ /** Additional metadata from telemetry settings. */
7409
+ readonly metadata: Record<string, unknown> | undefined;
7410
+ /** User-defined context object flowing through the generation. */
7411
+ readonly experimental_context: unknown;
7412
+ } & ({
7413
+ /** Indicates the tool call succeeded. */
7414
+ readonly success: true;
7415
+ /** The tool's return value. */
7416
+ readonly output: unknown;
7417
+ readonly error?: never;
7418
+ } | {
7419
+ /** Indicates the tool call failed. */
7420
+ readonly success: false;
7421
+ readonly output?: never;
7422
+ /** The error that occurred during tool execution. */
7423
+ readonly error: unknown;
7424
+ });
7425
+
7426
+ /**
7427
+ * Event passed to the `onToolCallStart` callback.
7428
+ *
7429
+ * Called when a tool execution begins, before the tool's `execute` function is invoked.
7430
+ */
7431
+ export declare interface OnToolCallStartEvent<TOOLS extends ToolSet = ToolSet> {
7432
+ /** Zero-based index of the current step where this tool call occurs. */
7433
+ readonly stepNumber: number | undefined;
7434
+ /** The model being used for this step. */
7435
+ readonly model: CallbackModelInfo | undefined;
7436
+ /** The full tool call object. */
7437
+ readonly toolCall: TypedToolCall<TOOLS>;
7438
+ /** The conversation messages available at tool execution time. */
7439
+ readonly messages: Array<ModelMessage>;
7440
+ /** Signal for cancelling the operation. */
7441
+ readonly abortSignal: AbortSignal | undefined;
7442
+ /** Identifier from telemetry settings for grouping related operations. */
7443
+ readonly functionId: string | undefined;
7444
+ /** Additional metadata from telemetry settings. */
7445
+ readonly metadata: Record<string, unknown> | undefined;
7446
+ /** User-defined context object flowing through the generation. */
7447
+ readonly experimental_context: unknown;
7448
+ }
7449
+
7450
+ export declare namespace Output {
7451
+ export {
7452
+ output_Output as Output,
7453
+ output_array as array,
7454
+ output_choice as choice,
7455
+ output_json as json,
7456
+ output_object as object,
7457
+ output_text as text,
7458
+ };
7459
+ }
7460
+
7461
+ declare interface Output_2<OUTPUT = any, PARTIAL = any, ELEMENT = any> {
7462
+ /**
7463
+ * The name of the output mode.
7464
+ */
7465
+ name: string;
7434
7466
  /**
7435
7467
  * The response format to use for the model.
7436
7468
  */
@@ -8403,6 +8435,11 @@ export declare type ReasoningUIPart = {
8403
8435
  providerMetadata?: ProviderMetadata;
8404
8436
  };
8405
8437
 
8438
+ /**
8439
+ * Registers a telemetry integration globally.
8440
+ */
8441
+ export declare function registerTelemetryIntegration(integration: TelemetryIntegration): void;
8442
+
8406
8443
  /**
8407
8444
  * Removes entries from a record where the value is null or undefined.
8408
8445
  * @param record - The input object whose entries may be null or undefined.
@@ -9008,6 +9045,7 @@ declare type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
9008
9045
  } & Source) | {
9009
9046
  type: 'file';
9010
9047
  file: GeneratedFile;
9048
+ providerMetadata?: ProviderMetadata;
9011
9049
  } | ({
9012
9050
  type: 'tool-call';
9013
9051
  } & TypedToolCall<TOOLS>) | ({
@@ -9015,9 +9053,6 @@ declare type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
9015
9053
  } & TypedToolResult<TOOLS>) | ({
9016
9054
  type: 'tool-error';
9017
9055
  } & TypedToolError<TOOLS>) | {
9018
- type: 'file';
9019
- file: GeneratedFile;
9020
- } | {
9021
9056
  type: 'stream-start';
9022
9057
  warnings: SharedV3Warning[];
9023
9058
  } | {
@@ -10270,7 +10305,7 @@ declare interface StreamOptions {
10270
10305
  * @returns
10271
10306
  * A result object for accessing different stream types and additional information.
10272
10307
  */
10273
- export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
10308
+ export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_2 = Output_2<string, string, never>>({ model, tools, toolChoice, system, prompt, messages, maxRetries, abortSignal, timeout, headers, stopWhen, experimental_output, output, experimental_telemetry: telemetry, prepareStep, providerOptions, experimental_activeTools, activeTools, experimental_repairToolCall: repairToolCall, experimental_transform: transform, experimental_download: download, includeRawChunks, onChunk, onError, onFinish, onAbort, onStepFinish, experimental_onStart: onStart, experimental_onStepStart: onStepStart, experimental_onToolCallStart: onToolCallStart, experimental_onToolCallFinish: onToolCallFinish, experimental_context, experimental_include: include, _internal: { now, generateId }, ...settings }: CallSettings & Prompt & {
10274
10309
  /**
10275
10310
  * The language model to use.
10276
10311
  */
@@ -10377,6 +10412,24 @@ export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_
10377
10412
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
10378
10413
  */
10379
10414
  onStepFinish?: StreamTextOnStepFinishCallback<TOOLS>;
10415
+ /**
10416
+ * Callback that is called when the streamText operation begins,
10417
+ * before any LLM calls are made.
10418
+ */
10419
+ experimental_onStart?: StreamTextOnStartCallback<NoInfer<TOOLS>, OUTPUT>;
10420
+ /**
10421
+ * Callback that is called when a step (LLM call) begins,
10422
+ * before the provider is called.
10423
+ */
10424
+ experimental_onStepStart?: StreamTextOnStepStartCallback<NoInfer<TOOLS>, OUTPUT>;
10425
+ /**
10426
+ * Callback that is called right before a tool's execute function runs.
10427
+ */
10428
+ experimental_onToolCallStart?: StreamTextOnToolCallStartCallback<NoInfer<TOOLS>>;
10429
+ /**
10430
+ * Callback that is called right after a tool's execute function completes (or errors).
10431
+ */
10432
+ experimental_onToolCallFinish?: StreamTextOnToolCallFinishCallback<NoInfer<TOOLS>>;
10380
10433
  /**
10381
10434
  * Context that is passed into tool execution.
10382
10435
  *
@@ -10409,6 +10462,13 @@ export declare function streamText<TOOLS extends ToolSet, OUTPUT extends Output_
10409
10462
  };
10410
10463
  }): StreamTextResult<TOOLS, OUTPUT>;
10411
10464
 
10465
+ /**
10466
+ * Include settings for streamText (requestBody only).
10467
+ */
10468
+ declare type StreamTextIncludeSettings = {
10469
+ requestBody?: boolean;
10470
+ };
10471
+
10412
10472
  /**
10413
10473
  * Callback that is set using the `onAbort` option.
10414
10474
  *
@@ -10446,31 +10506,40 @@ export declare type StreamTextOnErrorCallback = (event: {
10446
10506
  *
10447
10507
  * @param event - The event that is passed to the callback.
10448
10508
  */
10449
- export declare type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: StepResult<TOOLS> & {
10450
- /**
10451
- * Details for all steps.
10452
- */
10453
- readonly steps: StepResult<TOOLS>[];
10454
- /**
10455
- * Total usage for all steps. This is the sum of the usage of all steps.
10456
- */
10457
- readonly totalUsage: LanguageModelUsage;
10458
- /**
10459
- * Context that is passed into tool execution.
10460
- *
10461
- * Experimental (can break in patch releases).
10462
- *
10463
- * @default undefined
10464
- */
10465
- experimental_context: unknown;
10466
- }) => PromiseLike<void> | void;
10509
+ export declare type StreamTextOnFinishCallback<TOOLS extends ToolSet> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
10510
+
10511
+ /**
10512
+ * Callback that is set using the `experimental_onStart` option.
10513
+ *
10514
+ * Called when the streamText operation begins, before any LLM calls.
10515
+ * Use this callback for logging, analytics, or initializing state at the
10516
+ * start of a generation.
10517
+ *
10518
+ * @param event - The event object containing generation configuration.
10519
+ */
10520
+ export declare type StreamTextOnStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStartEvent<TOOLS, OUTPUT, StreamTextIncludeSettings>) => PromiseLike<void> | void;
10467
10521
 
10468
10522
  /**
10469
10523
  * Callback that is set using the `onStepFinish` option.
10470
10524
  *
10471
10525
  * @param stepResult - The result of the step.
10472
10526
  */
10473
- export declare type StreamTextOnStepFinishCallback<TOOLS extends ToolSet> = (stepResult: StepResult<TOOLS>) => PromiseLike<void> | void;
10527
+ export declare type StreamTextOnStepFinishCallback<TOOLS extends ToolSet> = (event: OnStepFinishEvent<TOOLS>) => PromiseLike<void> | void;
10528
+
10529
+ /**
10530
+ * Callback that is set using the `experimental_onStepStart` option.
10531
+ *
10532
+ * Called when a step (LLM call) begins, before the provider is called.
10533
+ * Each step represents a single LLM invocation. Multiple steps occur when
10534
+ * using tool calls (the model may be called multiple times in a loop).
10535
+ *
10536
+ * @param event - The event object containing step configuration.
10537
+ */
10538
+ export declare type StreamTextOnStepStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStepStartEvent<TOOLS, OUTPUT, StreamTextIncludeSettings>) => PromiseLike<void> | void;
10539
+
10540
+ export declare type StreamTextOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallFinishEvent<TOOLS>) => PromiseLike<void> | void;
10541
+
10542
+ export declare type StreamTextOnToolCallStartCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallStartEvent<TOOLS>) => PromiseLike<void> | void;
10474
10543
 
10475
10544
  /**
10476
10545
  * A result object for accessing different stream types and additional information.
@@ -10701,6 +10770,16 @@ export declare type StreamTextTransform<TOOLS extends ToolSet> = (options: {
10701
10770
  stopStream: () => void;
10702
10771
  }) => TransformStream<TextStreamPart<TOOLS>, TextStreamPart<TOOLS>>;
10703
10772
 
10773
+ /**
10774
+ * Strips file extension segments from a filename.
10775
+ *
10776
+ * Examples:
10777
+ * - "report.pdf" -> "report"
10778
+ * - "archive.tar.gz" -> "archive"
10779
+ * - "filename" -> "filename"
10780
+ */
10781
+ declare function stripFileExtension(filename: string): string;
10782
+
10704
10783
  declare const symbol$1: unique symbol;
10705
10784
 
10706
10785
  declare const symbol$1_2: unique symbol;
@@ -10791,6 +10870,19 @@ export declare type SystemModelMessage = {
10791
10870
 
10792
10871
  export declare const systemModelMessageSchema: z.ZodType<SystemModelMessage>;
10793
10872
 
10873
+ /**
10874
+ * Implement this interface to create custom telemetry integrations.
10875
+ * Methods can be sync or return a PromiseLike.
10876
+ */
10877
+ export declare interface TelemetryIntegration {
10878
+ onStart?: Listener<OnStartEvent<ToolSet, Output_2>>;
10879
+ onStepStart?: Listener<OnStepStartEvent<ToolSet, Output_2>>;
10880
+ onToolCallStart?: Listener<OnToolCallStartEvent<ToolSet>>;
10881
+ onToolCallFinish?: Listener<OnToolCallFinishEvent<ToolSet>>;
10882
+ onStepFinish?: Listener<OnStepFinishEvent<ToolSet>>;
10883
+ onFinish?: Listener<OnFinishEvent<ToolSet>>;
10884
+ }
10885
+
10794
10886
  /**
10795
10887
  * Telemetry configuration.
10796
10888
  */
@@ -10825,6 +10917,13 @@ export declare type TelemetrySettings = {
10825
10917
  * A custom tracer to use for the telemetry data.
10826
10918
  */
10827
10919
  tracer?: Tracer;
10920
+ /**
10921
+ * Per-call telemetry integrations that receive lifecycle events during generation.
10922
+ *
10923
+ * These integrations run after any globally registered integrations
10924
+ * (see `registerTelemetryIntegration`).
10925
+ */
10926
+ integrations?: TelemetryIntegration | TelemetryIntegration[];
10828
10927
  };
10829
10928
 
10830
10929
  /**
@@ -10897,6 +10996,7 @@ export declare type TextStreamPart<TOOLS extends ToolSet> = {
10897
10996
  } & Source) | {
10898
10997
  type: 'file';
10899
10998
  file: GeneratedFile;
10999
+ providerMetadata?: ProviderMetadata;
10900
11000
  } | ({
10901
11001
  type: 'tool-call';
10902
11002
  } & TypedToolCall<TOOLS>) | ({
@@ -11353,49 +11453,30 @@ declare class ToolLoopAgent<CALL_OPTIONS = never, TOOLS extends ToolSet = {}, OU
11353
11453
  */
11354
11454
  get tools(): TOOLS;
11355
11455
  private prepareCall;
11356
- private mergeOnStepFinishCallbacks;
11456
+ private mergeCallbacks;
11357
11457
  /**
11358
11458
  * Generates an output from the agent (non-streaming).
11359
11459
  */
11360
- generate({ abortSignal, timeout, onStepFinish, ...options }: AgentCallParameters<CALL_OPTIONS, TOOLS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
11460
+ generate({ abortSignal, timeout, experimental_onStart, experimental_onStepStart, experimental_onToolCallStart, experimental_onToolCallFinish, onStepFinish, onFinish, ...options }: AgentCallParameters<CALL_OPTIONS, TOOLS>): Promise<GenerateTextResult<TOOLS, OUTPUT>>;
11361
11461
  /**
11362
11462
  * Streams an output from the agent (streaming).
11363
11463
  */
11364
- stream({ abortSignal, timeout, experimental_transform, onStepFinish, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
11464
+ stream({ abortSignal, timeout, experimental_transform, experimental_onStart, experimental_onStepStart, experimental_onToolCallStart, experimental_onToolCallFinish, onStepFinish, onFinish, ...options }: AgentStreamParameters<CALL_OPTIONS, TOOLS>): Promise<StreamTextResult<TOOLS, OUTPUT>>;
11365
11465
  }
11366
11466
  export { ToolLoopAgent as Experimental_Agent }
11367
11467
  export { ToolLoopAgent }
11368
11468
 
11369
- /**
11370
- * Callback that is set using the `onFinish` option.
11371
- *
11372
- * @param event - The event that is passed to the callback.
11373
- */
11374
- export declare type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: StepResult<TOOLS> & {
11375
- /**
11376
- * Details for all steps.
11377
- */
11378
- readonly steps: StepResult<TOOLS>[];
11379
- /**
11380
- * Total usage for all steps. This is the sum of the usage of all steps.
11381
- */
11382
- readonly totalUsage: LanguageModelUsage;
11383
- /**
11384
- * Context that is passed into tool execution.
11385
- *
11386
- * Experimental (can break in patch releases).
11387
- *
11388
- * @default undefined
11389
- */
11390
- experimental_context: unknown;
11391
- }) => PromiseLike<void> | void;
11469
+ export declare type ToolLoopAgentOnFinishCallback<TOOLS extends ToolSet = {}> = (event: OnFinishEvent<TOOLS>) => PromiseLike<void> | void;
11392
11470
 
11393
- /**
11394
- * Callback that is set using the `onStepFinish` option.
11395
- *
11396
- * @param stepResult - The result of the step.
11397
- */
11398
- export declare type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: StepResult<TOOLS>) => Promise<void> | void;
11471
+ export declare type ToolLoopAgentOnStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStartEvent<TOOLS, OUTPUT>) => PromiseLike<void> | void;
11472
+
11473
+ export declare type ToolLoopAgentOnStepFinishCallback<TOOLS extends ToolSet = {}> = (stepResult: OnStepFinishEvent<TOOLS>) => Promise<void> | void;
11474
+
11475
+ export declare type ToolLoopAgentOnStepStartCallback<TOOLS extends ToolSet = ToolSet, OUTPUT extends Output_2 = Output_2> = (event: OnStepStartEvent<TOOLS, OUTPUT>) => PromiseLike<void> | void;
11476
+
11477
+ export declare type ToolLoopAgentOnToolCallFinishCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallFinishEvent<TOOLS>) => PromiseLike<void> | void;
11478
+
11479
+ export declare type ToolLoopAgentOnToolCallStartCallback<TOOLS extends ToolSet = ToolSet> = (event: OnToolCallStartEvent<TOOLS>) => PromiseLike<void> | void;
11399
11480
 
11400
11481
  /**
11401
11482
  * Configuration options for an agent.
@@ -11451,6 +11532,22 @@ declare type ToolLoopAgentSettings<CALL_OPTIONS = never, TOOLS extends ToolSet =
11451
11532
  * A function that attempts to repair a tool call that failed to parse.
11452
11533
  */
11453
11534
  experimental_repairToolCall?: ToolCallRepairFunction<NoInfer<TOOLS>>;
11535
+ /**
11536
+ * Callback that is called when the agent operation begins, before any LLM calls.
11537
+ */
11538
+ experimental_onStart?: ToolLoopAgentOnStartCallback<NoInfer<TOOLS>, OUTPUT>;
11539
+ /**
11540
+ * Callback that is called when a step (LLM call) begins, before the provider is called.
11541
+ */
11542
+ experimental_onStepStart?: ToolLoopAgentOnStepStartCallback<NoInfer<TOOLS>, OUTPUT>;
11543
+ /**
11544
+ * Callback that is called before each tool execution begins.
11545
+ */
11546
+ experimental_onToolCallStart?: ToolLoopAgentOnToolCallStartCallback<NoInfer<TOOLS>>;
11547
+ /**
11548
+ * Callback that is called after each tool execution completes.
11549
+ */
11550
+ experimental_onToolCallFinish?: ToolLoopAgentOnToolCallFinishCallback<NoInfer<TOOLS>>;
11454
11551
  /**
11455
11552
  * Callback that is called when each step (LLM call) is finished, including intermediate steps.
11456
11553
  */
@@ -12944,6 +13041,15 @@ export declare type UserModelMessage = {
12944
13041
 
12945
13042
  export declare const userModelMessageSchema: z.ZodType<UserModelMessage>;
12946
13043
 
13044
+ /**
13045
+ * Validates that a URL is safe to download from, blocking private/internal addresses
13046
+ * to prevent SSRF attacks.
13047
+ *
13048
+ * @param url - The URL string to validate.
13049
+ * @throws DownloadError if the URL is unsafe.
13050
+ */
13051
+ declare function validateDownloadUrl(url: string): void;
13052
+
12947
13053
  /**
12948
13054
  * Validates the types of an unknown object using a schema and
12949
13055
  * return a strongly-typed object.
@@ -13383,5 +13489,5 @@ export declare function zodSchema<OBJECT>(zodSchema: z4.core.$ZodType<OBJECT, an
13383
13489
  }): Schema<OBJECT>;
13384
13490
 
13385
13491
  export { }
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 };
13492
+ 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, CallbackModelInfo as CallbackModelInfo, LanguageModelV3ToolChoice as LanguageModelV3ToolChoice, Listener as Listener, AttributeValue as AttributeValue, Tracer as Tracer, LanguageModelV3ToolCall as LanguageModelV3ToolCall, GenerateTextIncludeSettings as GenerateTextIncludeSettings, 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, StreamTextIncludeSettings as StreamTextIncludeSettings, StreamTextOnAbortCallback as StreamTextOnAbortCallback, ResponseMessage as ResponseMessage, MaybePromiseLike as MaybePromiseLike, Output_2 as Output_2, 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 };
13387
13493
  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 };