ai 7.0.0-beta.26 → 7.0.0-beta.27

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,15 @@
1
1
  # ai
2
2
 
3
+ ## 7.0.0-beta.27
4
+
5
+ ### Patch Changes
6
+
7
+ - 3887c70: feat(provider): add new top-level reasoning parameter to spec and support it in `generateText` and `streamText`
8
+ - Updated dependencies [3887c70]
9
+ - @ai-sdk/provider-utils@5.0.0-beta.6
10
+ - @ai-sdk/provider@4.0.0-beta.4
11
+ - @ai-sdk/gateway@4.0.0-beta.17
12
+
3
13
  ## 7.0.0-beta.26
4
14
 
5
15
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { Tool, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, AssistantModelMessage, ToolModelMessage, ReasoningPart, ReasoningFilePart, ProviderOptions, UserModelMessage, IdGenerator, ToolCall, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
5
5
  export { AssistantContent, AssistantModelMessage, DataContent, DownloadError, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolExecutionOptions, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
6
6
  import * as _ai_sdk_provider from '@ai-sdk/provider';
7
- import { EmbeddingModelV4, EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV4Embedding, EmbeddingModelV4Middleware, ImageModelV4, ImageModelV3, ImageModelV2, ImageModelV4ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV4Middleware, JSONValue as JSONValue$1, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, LanguageModelV4Middleware, RerankingModelV4, RerankingModelV3, SharedV4ProviderMetadata, SpeechModelV4, SpeechModelV3, SpeechModelV2, TranscriptionModelV4, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV4Usage, AISDKError, LanguageModelV4ToolCall, JSONSchema7, LanguageModelV4ToolChoice, LanguageModelV4CallOptions, JSONParseError, TypeValidationError, Experimental_VideoModelV4, Experimental_VideoModelV3, EmbeddingModelV4CallOptions, ProviderV4, ProviderV3, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
7
+ import { EmbeddingModelV4, EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV4Embedding, EmbeddingModelV4Middleware, ImageModelV4, ImageModelV3, ImageModelV2, ImageModelV4ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV4Middleware, JSONValue as JSONValue$1, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, LanguageModelV4Middleware, RerankingModelV4, RerankingModelV3, SharedV4ProviderMetadata, SpeechModelV4, SpeechModelV3, SpeechModelV2, TranscriptionModelV4, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV4Usage, LanguageModelV4CallOptions, AISDKError, LanguageModelV4ToolCall, JSONSchema7, LanguageModelV4ToolChoice, LanguageModelV4ResponseMetadata, JSONParseError, TypeValidationError, Experimental_VideoModelV4, Experimental_VideoModelV3, EmbeddingModelV4CallOptions, ProviderV4, ProviderV3, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
8
8
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
9
9
  import { Tracer } from '@opentelemetry/api';
10
10
  import { ServerResponse } from 'node:http';
@@ -696,6 +696,14 @@ type CallSettings<TOOLS extends ToolSet> = {
696
696
  * by the model, calls will generate deterministic results.
697
697
  */
698
698
  seed?: number;
699
+ /**
700
+ * Reasoning effort level for the model. Controls how much reasoning
701
+ * the model performs before generating a response.
702
+ *
703
+ * Use `'provider-default'` to use the provider's default reasoning level.
704
+ * Use `'none'` to disable reasoning (if supported by the provider).
705
+ */
706
+ reasoning?: LanguageModelV4CallOptions['reasoning'];
699
707
  /**
700
708
  * Maximum number of retries. Set to 0 to disable retries.
701
709
  *
@@ -2414,37 +2422,44 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
2414
2422
  */
2415
2423
  toTextStreamResponse(init?: ResponseInit): Response;
2416
2424
  }
2417
- type TextStreamPart<TOOLS extends ToolSet> = {
2418
- type: 'text-start';
2425
+ type TextStreamTextDeltaPart = {
2426
+ type: 'text-delta';
2419
2427
  id: string;
2420
2428
  providerMetadata?: ProviderMetadata;
2421
- } | {
2422
- type: 'text-end';
2429
+ text: string;
2430
+ };
2431
+ type TextStreamTextStartPart = {
2432
+ type: 'text-start';
2423
2433
  id: string;
2424
2434
  providerMetadata?: ProviderMetadata;
2425
- } | {
2426
- type: 'text-delta';
2435
+ };
2436
+ type TextStreamTextEndPart = {
2437
+ type: 'text-end';
2427
2438
  id: string;
2428
2439
  providerMetadata?: ProviderMetadata;
2429
- text: string;
2430
- } | {
2440
+ };
2441
+ type TextStreamReasoningStartPart = {
2431
2442
  type: 'reasoning-start';
2432
2443
  id: string;
2433
2444
  providerMetadata?: ProviderMetadata;
2434
- } | {
2445
+ };
2446
+ type TextStreamReasoningEndPart = {
2435
2447
  type: 'reasoning-end';
2436
2448
  id: string;
2437
2449
  providerMetadata?: ProviderMetadata;
2438
- } | {
2450
+ };
2451
+ type TextStreamReasoningDeltaPart = {
2439
2452
  type: 'reasoning-delta';
2440
2453
  providerMetadata?: ProviderMetadata;
2441
2454
  id: string;
2442
2455
  text: string;
2443
- } | {
2456
+ };
2457
+ type TextStreamCustomPart = {
2444
2458
  type: 'custom';
2445
2459
  kind: string;
2446
2460
  providerMetadata?: ProviderMetadata;
2447
- } | {
2461
+ };
2462
+ type TextStreamToolInputStartPart = {
2448
2463
  type: 'tool-input-start';
2449
2464
  id: string;
2450
2465
  toolName: string;
@@ -2452,61 +2467,79 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2452
2467
  providerExecuted?: boolean;
2453
2468
  dynamic?: boolean;
2454
2469
  title?: string;
2455
- } | {
2470
+ };
2471
+ type TextStreamToolInputEndPart = {
2456
2472
  type: 'tool-input-end';
2457
2473
  id: string;
2458
2474
  providerMetadata?: ProviderMetadata;
2459
- } | {
2475
+ };
2476
+ type TextStreamToolInputDeltaPart = {
2460
2477
  type: 'tool-input-delta';
2461
2478
  id: string;
2462
2479
  delta: string;
2463
2480
  providerMetadata?: ProviderMetadata;
2464
- } | ({
2481
+ };
2482
+ type TextStreamSourcePart = {
2465
2483
  type: 'source';
2466
- } & Source) | {
2484
+ } & Source;
2485
+ type TextStreamFilePart = {
2467
2486
  type: 'file';
2468
2487
  file: GeneratedFile;
2469
2488
  providerMetadata?: ProviderMetadata;
2470
- } | {
2489
+ };
2490
+ type TextStreamReasoningFilePart = {
2471
2491
  type: 'reasoning-file';
2472
2492
  file: GeneratedFile;
2473
2493
  providerMetadata?: ProviderMetadata;
2474
- } | ({
2494
+ };
2495
+ type TextStreamToolCallPart<TOOLS extends ToolSet> = {
2475
2496
  type: 'tool-call';
2476
- } & TypedToolCall<TOOLS>) | ({
2497
+ } & TypedToolCall<TOOLS>;
2498
+ type TextStreamToolResultPart<TOOLS extends ToolSet> = {
2477
2499
  type: 'tool-result';
2478
- } & TypedToolResult<TOOLS>) | ({
2500
+ } & TypedToolResult<TOOLS>;
2501
+ type TextStreamToolErrorPart<TOOLS extends ToolSet> = {
2479
2502
  type: 'tool-error';
2480
- } & TypedToolError<TOOLS>) | ({
2503
+ } & TypedToolError<TOOLS>;
2504
+ type TextStreamToolOutputDeniedPart<TOOLS extends ToolSet> = {
2481
2505
  type: 'tool-output-denied';
2482
- } & StaticToolOutputDenied<TOOLS>) | ToolApprovalRequestOutput<TOOLS> | {
2506
+ } & StaticToolOutputDenied<TOOLS>;
2507
+ type TextStreamToolApprovalRequestPart<TOOLS extends ToolSet> = ToolApprovalRequestOutput<TOOLS>;
2508
+ type TextStreamStartStepPart = {
2483
2509
  type: 'start-step';
2484
2510
  request: LanguageModelRequestMetadata;
2485
2511
  warnings: CallWarning[];
2486
- } | {
2512
+ };
2513
+ type TextStreamFinishStepPart = {
2487
2514
  type: 'finish-step';
2488
2515
  response: LanguageModelResponseMetadata;
2489
2516
  usage: LanguageModelUsage;
2490
2517
  finishReason: FinishReason;
2491
2518
  rawFinishReason: string | undefined;
2492
2519
  providerMetadata: ProviderMetadata | undefined;
2493
- } | {
2520
+ };
2521
+ type TextStreamStartPart = {
2494
2522
  type: 'start';
2495
- } | {
2523
+ };
2524
+ type TextStreamFinishPart = {
2496
2525
  type: 'finish';
2497
2526
  finishReason: FinishReason;
2498
2527
  rawFinishReason: string | undefined;
2499
2528
  totalUsage: LanguageModelUsage;
2500
- } | {
2529
+ };
2530
+ type TextStreamAbortPart = {
2501
2531
  type: 'abort';
2502
2532
  reason?: string;
2503
- } | {
2533
+ };
2534
+ type TextStreamErrorPart = {
2504
2535
  type: 'error';
2505
2536
  error: unknown;
2506
- } | {
2537
+ };
2538
+ type TextStreamRawPart = {
2507
2539
  type: 'raw';
2508
2540
  rawValue: unknown;
2509
2541
  };
2542
+ type TextStreamPart<TOOLS extends ToolSet> = TextStreamTextStartPart | TextStreamTextEndPart | TextStreamTextDeltaPart | TextStreamReasoningStartPart | TextStreamReasoningEndPart | TextStreamReasoningDeltaPart | TextStreamCustomPart | TextStreamToolInputStartPart | TextStreamToolInputEndPart | TextStreamToolInputDeltaPart | TextStreamSourcePart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | TextStreamToolOutputDeniedPart<TOOLS> | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamStartStepPart | TextStreamFinishStepPart | TextStreamStartPart | TextStreamFinishPart | TextStreamAbortPart | TextStreamErrorPart | TextStreamRawPart;
2510
2543
 
2511
2544
  /**
2512
2545
  * Common model information used across callback events.
@@ -4897,96 +4930,27 @@ declare class InvalidArgumentError extends AISDKError {
4897
4930
  static isInstance(error: unknown): error is InvalidArgumentError;
4898
4931
  }
4899
4932
 
4900
- type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
4901
- type: 'text-start';
4902
- providerMetadata?: ProviderMetadata;
4903
- id: string;
4904
- } | {
4905
- type: 'text-delta';
4906
- id: string;
4907
- providerMetadata?: ProviderMetadata;
4908
- text: string;
4909
- } | {
4910
- type: 'text-end';
4911
- providerMetadata?: ProviderMetadata;
4912
- id: string;
4913
- } | {
4914
- type: 'reasoning-start';
4915
- providerMetadata?: ProviderMetadata;
4916
- id: string;
4917
- } | {
4918
- type: 'reasoning-delta';
4919
- id: string;
4920
- providerMetadata?: ProviderMetadata;
4921
- text: string;
4922
- } | {
4923
- type: 'reasoning-end';
4924
- id: string;
4925
- providerMetadata?: ProviderMetadata;
4926
- } | {
4927
- type: 'custom';
4928
- kind: string;
4929
- providerMetadata?: ProviderMetadata;
4930
- } | {
4931
- type: 'tool-input-start';
4932
- id: string;
4933
- toolName: string;
4934
- providerMetadata?: ProviderMetadata;
4935
- dynamic?: boolean;
4936
- title?: string;
4937
- } | {
4938
- type: 'tool-input-delta';
4939
- id: string;
4940
- delta: string;
4941
- providerMetadata?: ProviderMetadata;
4942
- } | {
4943
- type: 'tool-input-end';
4944
- id: string;
4945
- providerMetadata?: ProviderMetadata;
4946
- } | ToolApprovalRequestOutput<TOOLS> | ({
4947
- type: 'source';
4948
- } & Source) | {
4949
- type: 'file';
4950
- file: GeneratedFile;
4951
- providerMetadata?: ProviderMetadata;
4952
- } | {
4953
- type: 'reasoning-file';
4954
- file: GeneratedFile;
4955
- providerMetadata?: ProviderMetadata;
4956
- } | ({
4957
- type: 'tool-call';
4958
- } & TypedToolCall<TOOLS>) | ({
4959
- type: 'tool-result';
4960
- } & TypedToolResult<TOOLS>) | ({
4961
- type: 'tool-error';
4962
- } & TypedToolError<TOOLS>) | {
4963
- type: 'stream-start';
4964
- warnings: SharedV4Warning[];
4965
- } | {
4966
- type: 'response-metadata';
4967
- id?: string;
4968
- timestamp?: Date;
4969
- modelId?: string;
4970
- } | {
4933
+ type UglyTransformedStreamTextPart<TOOLS extends ToolSet> = Exclude<TextStreamPart<TOOLS>, {
4934
+ type: 'finish' | 'stream-start' | 'tool-output-denied' | 'start-step' | 'finish-step' | 'start' | 'abort';
4935
+ }> | TextStreamTextDeltaPart | TextStreamReasoningDeltaPart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | {
4971
4936
  type: 'finish';
4972
4937
  finishReason: FinishReason;
4973
4938
  rawFinishReason: string | undefined;
4974
4939
  usage: LanguageModelUsage;
4975
4940
  providerMetadata?: ProviderMetadata;
4976
4941
  } | {
4977
- type: 'error';
4978
- error: unknown;
4979
- } | {
4980
- type: 'raw';
4981
- rawValue: unknown;
4982
- };
4942
+ type: 'stream-start';
4943
+ warnings: Array<SharedV4Warning>;
4944
+ } | ({
4945
+ type: 'response-metadata';
4946
+ } & LanguageModelV4ResponseMetadata);
4983
4947
 
4984
4948
  declare const symbol$g: unique symbol;
4985
4949
  declare class InvalidStreamPartError extends AISDKError {
4986
4950
  private readonly [symbol$g];
4987
- readonly chunk: SingleRequestTextStreamPart<any>;
4951
+ readonly chunk: UglyTransformedStreamTextPart<any>;
4988
4952
  constructor({ chunk, message, }: {
4989
- chunk: SingleRequestTextStreamPart<any>;
4953
+ chunk: UglyTransformedStreamTextPart<any>;
4990
4954
  message: string;
4991
4955
  });
4992
4956
  static isInstance(error: unknown): error is InvalidStreamPartError;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { Tool, InferToolInput, InferToolOutput, FlexibleSchema, InferSchema, SystemModelMessage, ModelMessage, AssistantModelMessage, ToolModelMessage, ReasoningPart, ReasoningFilePart, ProviderOptions, UserModelMessage, IdGenerator, ToolCall, MaybePromiseLike, TextPart, FilePart, Resolvable, FetchFunction, DataContent } from '@ai-sdk/provider-utils';
5
5
  export { AssistantContent, AssistantModelMessage, DataContent, DownloadError, FilePart, FlexibleSchema, IdGenerator, ImagePart, InferSchema, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolApprovalRequest, ToolApprovalResponse, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolExecutionOptions, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, parseJsonEventStream, tool, zodSchema } from '@ai-sdk/provider-utils';
6
6
  import * as _ai_sdk_provider from '@ai-sdk/provider';
7
- import { EmbeddingModelV4, EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV4Embedding, EmbeddingModelV4Middleware, ImageModelV4, ImageModelV3, ImageModelV2, ImageModelV4ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV4Middleware, JSONValue as JSONValue$1, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, LanguageModelV4Middleware, RerankingModelV4, RerankingModelV3, SharedV4ProviderMetadata, SpeechModelV4, SpeechModelV3, SpeechModelV2, TranscriptionModelV4, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV4Usage, AISDKError, LanguageModelV4ToolCall, JSONSchema7, LanguageModelV4ToolChoice, LanguageModelV4CallOptions, JSONParseError, TypeValidationError, Experimental_VideoModelV4, Experimental_VideoModelV3, EmbeddingModelV4CallOptions, ProviderV4, ProviderV3, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
7
+ import { EmbeddingModelV4, EmbeddingModelV3, EmbeddingModelV2, EmbeddingModelV4Embedding, EmbeddingModelV4Middleware, ImageModelV4, ImageModelV3, ImageModelV2, ImageModelV4ProviderMetadata, ImageModelV2ProviderMetadata, ImageModelV4Middleware, JSONValue as JSONValue$1, LanguageModelV4, LanguageModelV3, LanguageModelV2, SharedV4Warning, LanguageModelV4Source, LanguageModelV4Middleware, RerankingModelV4, RerankingModelV3, SharedV4ProviderMetadata, SpeechModelV4, SpeechModelV3, SpeechModelV2, TranscriptionModelV4, TranscriptionModelV3, TranscriptionModelV2, JSONObject, ImageModelV4Usage, LanguageModelV4CallOptions, AISDKError, LanguageModelV4ToolCall, JSONSchema7, LanguageModelV4ToolChoice, LanguageModelV4ResponseMetadata, JSONParseError, TypeValidationError, Experimental_VideoModelV4, Experimental_VideoModelV3, EmbeddingModelV4CallOptions, ProviderV4, ProviderV3, ProviderV2, NoSuchModelError } from '@ai-sdk/provider';
8
8
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, LoadSettingError, NoContentGeneratedError, NoSuchModelError, TooManyEmbeddingValuesForCallError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
9
9
  import { Tracer } from '@opentelemetry/api';
10
10
  import { ServerResponse } from 'node:http';
@@ -696,6 +696,14 @@ type CallSettings<TOOLS extends ToolSet> = {
696
696
  * by the model, calls will generate deterministic results.
697
697
  */
698
698
  seed?: number;
699
+ /**
700
+ * Reasoning effort level for the model. Controls how much reasoning
701
+ * the model performs before generating a response.
702
+ *
703
+ * Use `'provider-default'` to use the provider's default reasoning level.
704
+ * Use `'none'` to disable reasoning (if supported by the provider).
705
+ */
706
+ reasoning?: LanguageModelV4CallOptions['reasoning'];
699
707
  /**
700
708
  * Maximum number of retries. Set to 0 to disable retries.
701
709
  *
@@ -2414,37 +2422,44 @@ interface StreamTextResult<TOOLS extends ToolSet, OUTPUT extends Output> {
2414
2422
  */
2415
2423
  toTextStreamResponse(init?: ResponseInit): Response;
2416
2424
  }
2417
- type TextStreamPart<TOOLS extends ToolSet> = {
2418
- type: 'text-start';
2425
+ type TextStreamTextDeltaPart = {
2426
+ type: 'text-delta';
2419
2427
  id: string;
2420
2428
  providerMetadata?: ProviderMetadata;
2421
- } | {
2422
- type: 'text-end';
2429
+ text: string;
2430
+ };
2431
+ type TextStreamTextStartPart = {
2432
+ type: 'text-start';
2423
2433
  id: string;
2424
2434
  providerMetadata?: ProviderMetadata;
2425
- } | {
2426
- type: 'text-delta';
2435
+ };
2436
+ type TextStreamTextEndPart = {
2437
+ type: 'text-end';
2427
2438
  id: string;
2428
2439
  providerMetadata?: ProviderMetadata;
2429
- text: string;
2430
- } | {
2440
+ };
2441
+ type TextStreamReasoningStartPart = {
2431
2442
  type: 'reasoning-start';
2432
2443
  id: string;
2433
2444
  providerMetadata?: ProviderMetadata;
2434
- } | {
2445
+ };
2446
+ type TextStreamReasoningEndPart = {
2435
2447
  type: 'reasoning-end';
2436
2448
  id: string;
2437
2449
  providerMetadata?: ProviderMetadata;
2438
- } | {
2450
+ };
2451
+ type TextStreamReasoningDeltaPart = {
2439
2452
  type: 'reasoning-delta';
2440
2453
  providerMetadata?: ProviderMetadata;
2441
2454
  id: string;
2442
2455
  text: string;
2443
- } | {
2456
+ };
2457
+ type TextStreamCustomPart = {
2444
2458
  type: 'custom';
2445
2459
  kind: string;
2446
2460
  providerMetadata?: ProviderMetadata;
2447
- } | {
2461
+ };
2462
+ type TextStreamToolInputStartPart = {
2448
2463
  type: 'tool-input-start';
2449
2464
  id: string;
2450
2465
  toolName: string;
@@ -2452,61 +2467,79 @@ type TextStreamPart<TOOLS extends ToolSet> = {
2452
2467
  providerExecuted?: boolean;
2453
2468
  dynamic?: boolean;
2454
2469
  title?: string;
2455
- } | {
2470
+ };
2471
+ type TextStreamToolInputEndPart = {
2456
2472
  type: 'tool-input-end';
2457
2473
  id: string;
2458
2474
  providerMetadata?: ProviderMetadata;
2459
- } | {
2475
+ };
2476
+ type TextStreamToolInputDeltaPart = {
2460
2477
  type: 'tool-input-delta';
2461
2478
  id: string;
2462
2479
  delta: string;
2463
2480
  providerMetadata?: ProviderMetadata;
2464
- } | ({
2481
+ };
2482
+ type TextStreamSourcePart = {
2465
2483
  type: 'source';
2466
- } & Source) | {
2484
+ } & Source;
2485
+ type TextStreamFilePart = {
2467
2486
  type: 'file';
2468
2487
  file: GeneratedFile;
2469
2488
  providerMetadata?: ProviderMetadata;
2470
- } | {
2489
+ };
2490
+ type TextStreamReasoningFilePart = {
2471
2491
  type: 'reasoning-file';
2472
2492
  file: GeneratedFile;
2473
2493
  providerMetadata?: ProviderMetadata;
2474
- } | ({
2494
+ };
2495
+ type TextStreamToolCallPart<TOOLS extends ToolSet> = {
2475
2496
  type: 'tool-call';
2476
- } & TypedToolCall<TOOLS>) | ({
2497
+ } & TypedToolCall<TOOLS>;
2498
+ type TextStreamToolResultPart<TOOLS extends ToolSet> = {
2477
2499
  type: 'tool-result';
2478
- } & TypedToolResult<TOOLS>) | ({
2500
+ } & TypedToolResult<TOOLS>;
2501
+ type TextStreamToolErrorPart<TOOLS extends ToolSet> = {
2479
2502
  type: 'tool-error';
2480
- } & TypedToolError<TOOLS>) | ({
2503
+ } & TypedToolError<TOOLS>;
2504
+ type TextStreamToolOutputDeniedPart<TOOLS extends ToolSet> = {
2481
2505
  type: 'tool-output-denied';
2482
- } & StaticToolOutputDenied<TOOLS>) | ToolApprovalRequestOutput<TOOLS> | {
2506
+ } & StaticToolOutputDenied<TOOLS>;
2507
+ type TextStreamToolApprovalRequestPart<TOOLS extends ToolSet> = ToolApprovalRequestOutput<TOOLS>;
2508
+ type TextStreamStartStepPart = {
2483
2509
  type: 'start-step';
2484
2510
  request: LanguageModelRequestMetadata;
2485
2511
  warnings: CallWarning[];
2486
- } | {
2512
+ };
2513
+ type TextStreamFinishStepPart = {
2487
2514
  type: 'finish-step';
2488
2515
  response: LanguageModelResponseMetadata;
2489
2516
  usage: LanguageModelUsage;
2490
2517
  finishReason: FinishReason;
2491
2518
  rawFinishReason: string | undefined;
2492
2519
  providerMetadata: ProviderMetadata | undefined;
2493
- } | {
2520
+ };
2521
+ type TextStreamStartPart = {
2494
2522
  type: 'start';
2495
- } | {
2523
+ };
2524
+ type TextStreamFinishPart = {
2496
2525
  type: 'finish';
2497
2526
  finishReason: FinishReason;
2498
2527
  rawFinishReason: string | undefined;
2499
2528
  totalUsage: LanguageModelUsage;
2500
- } | {
2529
+ };
2530
+ type TextStreamAbortPart = {
2501
2531
  type: 'abort';
2502
2532
  reason?: string;
2503
- } | {
2533
+ };
2534
+ type TextStreamErrorPart = {
2504
2535
  type: 'error';
2505
2536
  error: unknown;
2506
- } | {
2537
+ };
2538
+ type TextStreamRawPart = {
2507
2539
  type: 'raw';
2508
2540
  rawValue: unknown;
2509
2541
  };
2542
+ type TextStreamPart<TOOLS extends ToolSet> = TextStreamTextStartPart | TextStreamTextEndPart | TextStreamTextDeltaPart | TextStreamReasoningStartPart | TextStreamReasoningEndPart | TextStreamReasoningDeltaPart | TextStreamCustomPart | TextStreamToolInputStartPart | TextStreamToolInputEndPart | TextStreamToolInputDeltaPart | TextStreamSourcePart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | TextStreamToolOutputDeniedPart<TOOLS> | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamStartStepPart | TextStreamFinishStepPart | TextStreamStartPart | TextStreamFinishPart | TextStreamAbortPart | TextStreamErrorPart | TextStreamRawPart;
2510
2543
 
2511
2544
  /**
2512
2545
  * Common model information used across callback events.
@@ -4897,96 +4930,27 @@ declare class InvalidArgumentError extends AISDKError {
4897
4930
  static isInstance(error: unknown): error is InvalidArgumentError;
4898
4931
  }
4899
4932
 
4900
- type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
4901
- type: 'text-start';
4902
- providerMetadata?: ProviderMetadata;
4903
- id: string;
4904
- } | {
4905
- type: 'text-delta';
4906
- id: string;
4907
- providerMetadata?: ProviderMetadata;
4908
- text: string;
4909
- } | {
4910
- type: 'text-end';
4911
- providerMetadata?: ProviderMetadata;
4912
- id: string;
4913
- } | {
4914
- type: 'reasoning-start';
4915
- providerMetadata?: ProviderMetadata;
4916
- id: string;
4917
- } | {
4918
- type: 'reasoning-delta';
4919
- id: string;
4920
- providerMetadata?: ProviderMetadata;
4921
- text: string;
4922
- } | {
4923
- type: 'reasoning-end';
4924
- id: string;
4925
- providerMetadata?: ProviderMetadata;
4926
- } | {
4927
- type: 'custom';
4928
- kind: string;
4929
- providerMetadata?: ProviderMetadata;
4930
- } | {
4931
- type: 'tool-input-start';
4932
- id: string;
4933
- toolName: string;
4934
- providerMetadata?: ProviderMetadata;
4935
- dynamic?: boolean;
4936
- title?: string;
4937
- } | {
4938
- type: 'tool-input-delta';
4939
- id: string;
4940
- delta: string;
4941
- providerMetadata?: ProviderMetadata;
4942
- } | {
4943
- type: 'tool-input-end';
4944
- id: string;
4945
- providerMetadata?: ProviderMetadata;
4946
- } | ToolApprovalRequestOutput<TOOLS> | ({
4947
- type: 'source';
4948
- } & Source) | {
4949
- type: 'file';
4950
- file: GeneratedFile;
4951
- providerMetadata?: ProviderMetadata;
4952
- } | {
4953
- type: 'reasoning-file';
4954
- file: GeneratedFile;
4955
- providerMetadata?: ProviderMetadata;
4956
- } | ({
4957
- type: 'tool-call';
4958
- } & TypedToolCall<TOOLS>) | ({
4959
- type: 'tool-result';
4960
- } & TypedToolResult<TOOLS>) | ({
4961
- type: 'tool-error';
4962
- } & TypedToolError<TOOLS>) | {
4963
- type: 'stream-start';
4964
- warnings: SharedV4Warning[];
4965
- } | {
4966
- type: 'response-metadata';
4967
- id?: string;
4968
- timestamp?: Date;
4969
- modelId?: string;
4970
- } | {
4933
+ type UglyTransformedStreamTextPart<TOOLS extends ToolSet> = Exclude<TextStreamPart<TOOLS>, {
4934
+ type: 'finish' | 'stream-start' | 'tool-output-denied' | 'start-step' | 'finish-step' | 'start' | 'abort';
4935
+ }> | TextStreamTextDeltaPart | TextStreamReasoningDeltaPart | TextStreamFilePart | TextStreamReasoningFilePart | TextStreamToolApprovalRequestPart<TOOLS> | TextStreamToolCallPart<TOOLS> | TextStreamToolResultPart<TOOLS> | TextStreamToolErrorPart<TOOLS> | {
4971
4936
  type: 'finish';
4972
4937
  finishReason: FinishReason;
4973
4938
  rawFinishReason: string | undefined;
4974
4939
  usage: LanguageModelUsage;
4975
4940
  providerMetadata?: ProviderMetadata;
4976
4941
  } | {
4977
- type: 'error';
4978
- error: unknown;
4979
- } | {
4980
- type: 'raw';
4981
- rawValue: unknown;
4982
- };
4942
+ type: 'stream-start';
4943
+ warnings: Array<SharedV4Warning>;
4944
+ } | ({
4945
+ type: 'response-metadata';
4946
+ } & LanguageModelV4ResponseMetadata);
4983
4947
 
4984
4948
  declare const symbol$g: unique symbol;
4985
4949
  declare class InvalidStreamPartError extends AISDKError {
4986
4950
  private readonly [symbol$g];
4987
- readonly chunk: SingleRequestTextStreamPart<any>;
4951
+ readonly chunk: UglyTransformedStreamTextPart<any>;
4988
4952
  constructor({ chunk, message, }: {
4989
- chunk: SingleRequestTextStreamPart<any>;
4953
+ chunk: UglyTransformedStreamTextPart<any>;
4990
4954
  message: string;
4991
4955
  });
4992
4956
  static isInstance(error: unknown): error is InvalidStreamPartError;