ai 5.0.0-beta.30 → 5.0.0-beta.31

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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, Schema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, InferSchema, FlexibleSchema, DataContent, Validator, StandardSchemaV1, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
2
- export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, tool } from '@ai-sdk/provider-utils';
2
+ export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, tool, zodSchema } from '@ai-sdk/provider-utils';
3
3
  import { AttributeValue, Tracer } from '@opentelemetry/api';
4
4
  import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV2Usage, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
5
5
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
@@ -420,7 +420,7 @@ type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType>
420
420
 
421
421
  type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
422
422
 
423
- type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
423
+ type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
424
424
  [NAME in keyof TOOLS]: {
425
425
  type: 'tool-call';
426
426
  toolCallId: string;
@@ -430,7 +430,8 @@ type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
430
430
  dynamic?: false | undefined;
431
431
  providerMetadata?: ProviderMetadata;
432
432
  };
433
- }> | {
433
+ }>;
434
+ type DynamicToolCall = {
434
435
  type: 'tool-call';
435
436
  toolCallId: string;
436
437
  toolName: string;
@@ -439,49 +440,51 @@ type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
439
440
  dynamic: true;
440
441
  providerMetadata?: ProviderMetadata;
441
442
  };
442
- type ToolCallArray<TOOLS extends ToolSet> = Array<ToolCallUnion<TOOLS>>;
443
+ type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
443
444
 
444
- type ToToolResultObject<TOOLS extends ToolSet> = ValueOf<{
445
+ type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
445
446
  [NAME in keyof TOOLS]: {
446
- type: 'tool-result';
447
+ type: 'tool-error';
447
448
  toolCallId: string;
448
449
  toolName: NAME & string;
449
450
  input: InferToolInput<TOOLS[NAME]>;
450
- output: InferToolOutput<TOOLS[NAME]>;
451
+ error: unknown;
451
452
  providerExecuted?: boolean;
452
453
  dynamic?: false | undefined;
453
454
  };
454
- }> | {
455
- type: 'tool-result';
455
+ }>;
456
+ type DynamicToolError = {
457
+ type: 'tool-error';
456
458
  toolCallId: string;
457
459
  toolName: string;
458
460
  input: unknown;
459
- output: unknown;
461
+ error: unknown;
460
462
  providerExecuted?: boolean;
461
463
  dynamic: true;
462
464
  };
463
- type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<TOOLS>;
464
- type ToolResultArray<TOOLS extends ToolSet> = Array<ToolResultUnion<TOOLS>>;
465
- type ToToolErrorObject<TOOLS extends ToolSet> = ValueOf<{
465
+ type TypedToolError<TOOLS extends ToolSet> = StaticToolError<TOOLS> | DynamicToolError;
466
+
467
+ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
466
468
  [NAME in keyof TOOLS]: {
467
- type: 'tool-error';
469
+ type: 'tool-result';
468
470
  toolCallId: string;
469
471
  toolName: NAME & string;
470
472
  input: InferToolInput<TOOLS[NAME]>;
471
- error: unknown;
473
+ output: InferToolOutput<TOOLS[NAME]>;
472
474
  providerExecuted?: boolean;
473
475
  dynamic?: false | undefined;
474
476
  };
475
- }> | {
476
- type: 'tool-error';
477
+ }>;
478
+ type DynamicToolResult = {
479
+ type: 'tool-result';
477
480
  toolCallId: string;
478
481
  toolName: string;
479
482
  input: unknown;
480
- error: unknown;
483
+ output: unknown;
481
484
  providerExecuted?: boolean;
482
485
  dynamic: true;
483
486
  };
484
- type ToolErrorUnion<TOOLS extends ToolSet> = ToToolErrorObject<TOOLS>;
487
+ type TypedToolResult<TOOLS extends ToolSet> = StaticToolResult<TOOLS> | DynamicToolResult;
485
488
 
486
489
  type ContentPart<TOOLS extends ToolSet> = {
487
490
  type: 'text';
@@ -499,15 +502,15 @@ type ContentPart<TOOLS extends ToolSet> = {
499
502
  providerMetadata?: ProviderMetadata;
500
503
  } | ({
501
504
  type: 'tool-call';
502
- } & ToolCallUnion<TOOLS> & {
505
+ } & TypedToolCall<TOOLS> & {
503
506
  providerMetadata?: ProviderMetadata;
504
507
  }) | ({
505
508
  type: 'tool-result';
506
- } & ToolResultUnion<TOOLS> & {
509
+ } & TypedToolResult<TOOLS> & {
507
510
  providerMetadata?: ProviderMetadata;
508
511
  }) | ({
509
512
  type: 'tool-error';
510
- } & ToolErrorUnion<TOOLS> & {
513
+ } & TypedToolError<TOOLS> & {
511
514
  providerMetadata?: ProviderMetadata;
512
515
  });
513
516
 
@@ -548,11 +551,27 @@ type StepResult<TOOLS extends ToolSet> = {
548
551
  /**
549
552
  The tool calls that were made during the generation.
550
553
  */
551
- readonly toolCalls: ToolCallArray<TOOLS>;
554
+ readonly toolCalls: Array<TypedToolCall<TOOLS>>;
555
+ /**
556
+ The static tool calls that were made in the last step.
557
+ */
558
+ readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
559
+ /**
560
+ The dynamic tool calls that were made in the last step.
561
+ */
562
+ readonly dynamicToolCalls: Array<DynamicToolCall>;
552
563
  /**
553
564
  The results of the tool calls.
554
565
  */
555
- readonly toolResults: ToolResultArray<TOOLS>;
566
+ readonly toolResults: Array<TypedToolResult<TOOLS>>;
567
+ /**
568
+ The static tool results that were made in the last step.
569
+ */
570
+ readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
571
+ /**
572
+ The dynamic tool results that were made in the last step.
573
+ */
574
+ readonly dynamicToolResults: Array<DynamicToolResult>;
556
575
  /**
557
576
  The reason why the generation finished.
558
577
  */
@@ -626,11 +645,27 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
626
645
  /**
627
646
  The tool calls that were made in the last step.
628
647
  */
629
- readonly toolCalls: ToolCallArray<TOOLS>;
648
+ readonly toolCalls: Array<TypedToolCall<TOOLS>>;
649
+ /**
650
+ The static tool calls that were made in the last step.
651
+ */
652
+ readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
653
+ /**
654
+ The dynamic tool calls that were made in the last step.
655
+ */
656
+ readonly dynamicToolCalls: Array<DynamicToolCall>;
630
657
  /**
631
658
  The results of the tool calls from the last step.
632
659
  */
633
- readonly toolResults: ToolResultArray<TOOLS>;
660
+ readonly toolResults: Array<TypedToolResult<TOOLS>>;
661
+ /**
662
+ The static tool results that were made in the last step.
663
+ */
664
+ readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
665
+ /**
666
+ The dynamic tool results that were made in the last step.
667
+ */
668
+ readonly dynamicToolResults: Array<DynamicToolResult>;
634
669
  /**
635
670
  The reason why the generation finished.
636
671
  */
@@ -1442,8 +1477,12 @@ type InferUIMessageTools<T extends UIMessage> = T extends UIMessage<unknown, UID
1442
1477
  type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
1443
1478
  [NAME in keyof InferUIMessageTools<UI_MESSAGE>]: ToolCall<NAME & string, InferUIMessageTools<UI_MESSAGE>[NAME] extends {
1444
1479
  input: infer INPUT;
1445
- } ? INPUT : never>;
1446
- }>;
1480
+ } ? INPUT : never> & {
1481
+ dynamic?: false;
1482
+ };
1483
+ }> | (ToolCall<string, unknown> & {
1484
+ dynamic: true;
1485
+ });
1447
1486
 
1448
1487
  type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
1449
1488
  [NAME in keyof DATA_TYPES & string]: {
@@ -1685,13 +1724,37 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
1685
1724
 
1686
1725
  Resolved when the response is finished.
1687
1726
  */
1688
- readonly toolCalls: Promise<ToolCallUnion<TOOLS>[]>;
1727
+ readonly toolCalls: Promise<TypedToolCall<TOOLS>[]>;
1728
+ /**
1729
+ The static tool calls that have been executed in the last step.
1730
+
1731
+ Resolved when the response is finished.
1732
+ */
1733
+ readonly staticToolCalls: Promise<StaticToolCall<TOOLS>[]>;
1734
+ /**
1735
+ The dynamic tool calls that have been executed in the last step.
1736
+
1737
+ Resolved when the response is finished.
1738
+ */
1739
+ readonly dynamicToolCalls: Promise<DynamicToolCall[]>;
1740
+ /**
1741
+ The static tool results that have been generated in the last step.
1742
+
1743
+ Resolved when the response is finished.
1744
+ */
1745
+ readonly staticToolResults: Promise<StaticToolResult<TOOLS>[]>;
1746
+ /**
1747
+ The dynamic tool results that have been generated in the last step.
1748
+
1749
+ Resolved when the response is finished.
1750
+ */
1751
+ readonly dynamicToolResults: Promise<DynamicToolResult[]>;
1689
1752
  /**
1690
1753
  The tool results that have been generated in the last step.
1691
1754
 
1692
1755
  Resolved when the all tool executions are finished.
1693
1756
  */
1694
- readonly toolResults: Promise<ToolResultUnion<TOOLS>[]>;
1757
+ readonly toolResults: Promise<TypedToolResult<TOOLS>[]>;
1695
1758
  /**
1696
1759
  The reason why the generation finished. Taken from the last step.
1697
1760
 
@@ -1872,11 +1935,11 @@ type TextStreamPart<TOOLS extends ToolSet> = {
1872
1935
  file: GeneratedFile;
1873
1936
  } | ({
1874
1937
  type: 'tool-call';
1875
- } & ToolCallUnion<TOOLS>) | ({
1938
+ } & TypedToolCall<TOOLS>) | ({
1876
1939
  type: 'tool-result';
1877
- } & ToolResultUnion<TOOLS>) | ({
1940
+ } & TypedToolResult<TOOLS>) | ({
1878
1941
  type: 'tool-error';
1879
- } & ToolErrorUnion<TOOLS>) | {
1942
+ } & TypedToolError<TOOLS>) | {
1880
1943
  type: 'start-step';
1881
1944
  request: LanguageModelRequestMetadata;
1882
1945
  warnings: CallWarning[];
@@ -2214,11 +2277,11 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
2214
2277
  file: GeneratedFile;
2215
2278
  } | ({
2216
2279
  type: 'tool-call';
2217
- } & ToolCallUnion<TOOLS>) | ({
2280
+ } & TypedToolCall<TOOLS>) | ({
2218
2281
  type: 'tool-result';
2219
- } & ToolResultUnion<TOOLS>) | ({
2282
+ } & TypedToolResult<TOOLS>) | ({
2220
2283
  type: 'tool-error';
2221
- } & ToolErrorUnion<TOOLS>) | {
2284
+ } & TypedToolError<TOOLS>) | {
2222
2285
  type: 'file';
2223
2286
  file: GeneratedFile;
2224
2287
  } | {
@@ -4140,4 +4203,4 @@ declare global {
4140
4203
  var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
4141
4204
  }
4142
4205
 
4143
- export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolErrorUnion, ToolResultUnion, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
4206
+ export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ModelMessage, Tool, InferToolInput, InferToolOutput, AssistantModelMessage, ToolModelMessage, ReasoningPart, Schema, SystemModelMessage, UserModelMessage, ProviderOptions, IdGenerator, ToolCall, InferSchema, FlexibleSchema, DataContent, Validator, StandardSchemaV1, Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
2
- export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, tool } from '@ai-sdk/provider-utils';
2
+ export { AssistantContent, AssistantModelMessage, DataContent, FilePart, IdGenerator, ImagePart, InferToolInput, InferToolOutput, ModelMessage, Schema, SystemModelMessage, TextPart, Tool, ToolCallOptions, ToolCallPart, ToolContent, ToolExecuteFunction, ToolModelMessage, ToolResultPart, UserContent, UserModelMessage, asSchema, createIdGenerator, dynamicTool, generateId, jsonSchema, tool, zodSchema } from '@ai-sdk/provider-utils';
3
3
  import { AttributeValue, Tracer } from '@opentelemetry/api';
4
4
  import { EmbeddingModelV2, EmbeddingModelV2Embedding, ImageModelV2, ImageModelV2CallWarning, ImageModelV2ProviderMetadata, JSONValue as JSONValue$1, LanguageModelV2, LanguageModelV2FinishReason, LanguageModelV2CallWarning, LanguageModelV2Source, SharedV2ProviderMetadata, SpeechModelV2, SpeechModelV2CallWarning, TranscriptionModelV2, TranscriptionModelV2CallWarning, LanguageModelV2Usage, LanguageModelV2CallOptions, AISDKError, LanguageModelV2ToolCall, JSONSchema7, JSONParseError, TypeValidationError, LanguageModelV2Middleware, ProviderV2, NoSuchModelError, JSONObject } from '@ai-sdk/provider';
5
5
  export { AISDKError, APICallError, EmptyResponseBodyError, InvalidPromptError, InvalidResponseDataError, JSONParseError, JSONSchema7, LoadAPIKeyError, NoContentGeneratedError, NoSuchModelError, TypeValidationError, UnsupportedFunctionalityError } from '@ai-sdk/provider';
@@ -420,7 +420,7 @@ type ValueOf<ObjectType, ValueType extends keyof ObjectType = keyof ObjectType>
420
420
 
421
421
  type ToolSet = Record<string, (Tool<never, never> | Tool<any, any> | Tool<any, never> | Tool<never, any>) & Pick<Tool<any, any>, 'execute' | 'onInputAvailable' | 'onInputStart' | 'onInputDelta'>>;
422
422
 
423
- type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
423
+ type StaticToolCall<TOOLS extends ToolSet> = ValueOf<{
424
424
  [NAME in keyof TOOLS]: {
425
425
  type: 'tool-call';
426
426
  toolCallId: string;
@@ -430,7 +430,8 @@ type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
430
430
  dynamic?: false | undefined;
431
431
  providerMetadata?: ProviderMetadata;
432
432
  };
433
- }> | {
433
+ }>;
434
+ type DynamicToolCall = {
434
435
  type: 'tool-call';
435
436
  toolCallId: string;
436
437
  toolName: string;
@@ -439,49 +440,51 @@ type ToolCallUnion<TOOLS extends ToolSet> = ValueOf<{
439
440
  dynamic: true;
440
441
  providerMetadata?: ProviderMetadata;
441
442
  };
442
- type ToolCallArray<TOOLS extends ToolSet> = Array<ToolCallUnion<TOOLS>>;
443
+ type TypedToolCall<TOOLS extends ToolSet> = StaticToolCall<TOOLS> | DynamicToolCall;
443
444
 
444
- type ToToolResultObject<TOOLS extends ToolSet> = ValueOf<{
445
+ type StaticToolError<TOOLS extends ToolSet> = ValueOf<{
445
446
  [NAME in keyof TOOLS]: {
446
- type: 'tool-result';
447
+ type: 'tool-error';
447
448
  toolCallId: string;
448
449
  toolName: NAME & string;
449
450
  input: InferToolInput<TOOLS[NAME]>;
450
- output: InferToolOutput<TOOLS[NAME]>;
451
+ error: unknown;
451
452
  providerExecuted?: boolean;
452
453
  dynamic?: false | undefined;
453
454
  };
454
- }> | {
455
- type: 'tool-result';
455
+ }>;
456
+ type DynamicToolError = {
457
+ type: 'tool-error';
456
458
  toolCallId: string;
457
459
  toolName: string;
458
460
  input: unknown;
459
- output: unknown;
461
+ error: unknown;
460
462
  providerExecuted?: boolean;
461
463
  dynamic: true;
462
464
  };
463
- type ToolResultUnion<TOOLS extends ToolSet> = ToToolResultObject<TOOLS>;
464
- type ToolResultArray<TOOLS extends ToolSet> = Array<ToolResultUnion<TOOLS>>;
465
- type ToToolErrorObject<TOOLS extends ToolSet> = ValueOf<{
465
+ type TypedToolError<TOOLS extends ToolSet> = StaticToolError<TOOLS> | DynamicToolError;
466
+
467
+ type StaticToolResult<TOOLS extends ToolSet> = ValueOf<{
466
468
  [NAME in keyof TOOLS]: {
467
- type: 'tool-error';
469
+ type: 'tool-result';
468
470
  toolCallId: string;
469
471
  toolName: NAME & string;
470
472
  input: InferToolInput<TOOLS[NAME]>;
471
- error: unknown;
473
+ output: InferToolOutput<TOOLS[NAME]>;
472
474
  providerExecuted?: boolean;
473
475
  dynamic?: false | undefined;
474
476
  };
475
- }> | {
476
- type: 'tool-error';
477
+ }>;
478
+ type DynamicToolResult = {
479
+ type: 'tool-result';
477
480
  toolCallId: string;
478
481
  toolName: string;
479
482
  input: unknown;
480
- error: unknown;
483
+ output: unknown;
481
484
  providerExecuted?: boolean;
482
485
  dynamic: true;
483
486
  };
484
- type ToolErrorUnion<TOOLS extends ToolSet> = ToToolErrorObject<TOOLS>;
487
+ type TypedToolResult<TOOLS extends ToolSet> = StaticToolResult<TOOLS> | DynamicToolResult;
485
488
 
486
489
  type ContentPart<TOOLS extends ToolSet> = {
487
490
  type: 'text';
@@ -499,15 +502,15 @@ type ContentPart<TOOLS extends ToolSet> = {
499
502
  providerMetadata?: ProviderMetadata;
500
503
  } | ({
501
504
  type: 'tool-call';
502
- } & ToolCallUnion<TOOLS> & {
505
+ } & TypedToolCall<TOOLS> & {
503
506
  providerMetadata?: ProviderMetadata;
504
507
  }) | ({
505
508
  type: 'tool-result';
506
- } & ToolResultUnion<TOOLS> & {
509
+ } & TypedToolResult<TOOLS> & {
507
510
  providerMetadata?: ProviderMetadata;
508
511
  }) | ({
509
512
  type: 'tool-error';
510
- } & ToolErrorUnion<TOOLS> & {
513
+ } & TypedToolError<TOOLS> & {
511
514
  providerMetadata?: ProviderMetadata;
512
515
  });
513
516
 
@@ -548,11 +551,27 @@ type StepResult<TOOLS extends ToolSet> = {
548
551
  /**
549
552
  The tool calls that were made during the generation.
550
553
  */
551
- readonly toolCalls: ToolCallArray<TOOLS>;
554
+ readonly toolCalls: Array<TypedToolCall<TOOLS>>;
555
+ /**
556
+ The static tool calls that were made in the last step.
557
+ */
558
+ readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
559
+ /**
560
+ The dynamic tool calls that were made in the last step.
561
+ */
562
+ readonly dynamicToolCalls: Array<DynamicToolCall>;
552
563
  /**
553
564
  The results of the tool calls.
554
565
  */
555
- readonly toolResults: ToolResultArray<TOOLS>;
566
+ readonly toolResults: Array<TypedToolResult<TOOLS>>;
567
+ /**
568
+ The static tool results that were made in the last step.
569
+ */
570
+ readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
571
+ /**
572
+ The dynamic tool results that were made in the last step.
573
+ */
574
+ readonly dynamicToolResults: Array<DynamicToolResult>;
556
575
  /**
557
576
  The reason why the generation finished.
558
577
  */
@@ -626,11 +645,27 @@ interface GenerateTextResult<TOOLS extends ToolSet, OUTPUT> {
626
645
  /**
627
646
  The tool calls that were made in the last step.
628
647
  */
629
- readonly toolCalls: ToolCallArray<TOOLS>;
648
+ readonly toolCalls: Array<TypedToolCall<TOOLS>>;
649
+ /**
650
+ The static tool calls that were made in the last step.
651
+ */
652
+ readonly staticToolCalls: Array<StaticToolCall<TOOLS>>;
653
+ /**
654
+ The dynamic tool calls that were made in the last step.
655
+ */
656
+ readonly dynamicToolCalls: Array<DynamicToolCall>;
630
657
  /**
631
658
  The results of the tool calls from the last step.
632
659
  */
633
- readonly toolResults: ToolResultArray<TOOLS>;
660
+ readonly toolResults: Array<TypedToolResult<TOOLS>>;
661
+ /**
662
+ The static tool results that were made in the last step.
663
+ */
664
+ readonly staticToolResults: Array<StaticToolResult<TOOLS>>;
665
+ /**
666
+ The dynamic tool results that were made in the last step.
667
+ */
668
+ readonly dynamicToolResults: Array<DynamicToolResult>;
634
669
  /**
635
670
  The reason why the generation finished.
636
671
  */
@@ -1442,8 +1477,12 @@ type InferUIMessageTools<T extends UIMessage> = T extends UIMessage<unknown, UID
1442
1477
  type InferUIMessageToolCall<UI_MESSAGE extends UIMessage> = ValueOf<{
1443
1478
  [NAME in keyof InferUIMessageTools<UI_MESSAGE>]: ToolCall<NAME & string, InferUIMessageTools<UI_MESSAGE>[NAME] extends {
1444
1479
  input: infer INPUT;
1445
- } ? INPUT : never>;
1446
- }>;
1480
+ } ? INPUT : never> & {
1481
+ dynamic?: false;
1482
+ };
1483
+ }> | (ToolCall<string, unknown> & {
1484
+ dynamic: true;
1485
+ });
1447
1486
 
1448
1487
  type DataUIMessageChunk<DATA_TYPES extends UIDataTypes> = ValueOf<{
1449
1488
  [NAME in keyof DATA_TYPES & string]: {
@@ -1685,13 +1724,37 @@ interface StreamTextResult<TOOLS extends ToolSet, PARTIAL_OUTPUT> {
1685
1724
 
1686
1725
  Resolved when the response is finished.
1687
1726
  */
1688
- readonly toolCalls: Promise<ToolCallUnion<TOOLS>[]>;
1727
+ readonly toolCalls: Promise<TypedToolCall<TOOLS>[]>;
1728
+ /**
1729
+ The static tool calls that have been executed in the last step.
1730
+
1731
+ Resolved when the response is finished.
1732
+ */
1733
+ readonly staticToolCalls: Promise<StaticToolCall<TOOLS>[]>;
1734
+ /**
1735
+ The dynamic tool calls that have been executed in the last step.
1736
+
1737
+ Resolved when the response is finished.
1738
+ */
1739
+ readonly dynamicToolCalls: Promise<DynamicToolCall[]>;
1740
+ /**
1741
+ The static tool results that have been generated in the last step.
1742
+
1743
+ Resolved when the response is finished.
1744
+ */
1745
+ readonly staticToolResults: Promise<StaticToolResult<TOOLS>[]>;
1746
+ /**
1747
+ The dynamic tool results that have been generated in the last step.
1748
+
1749
+ Resolved when the response is finished.
1750
+ */
1751
+ readonly dynamicToolResults: Promise<DynamicToolResult[]>;
1689
1752
  /**
1690
1753
  The tool results that have been generated in the last step.
1691
1754
 
1692
1755
  Resolved when the all tool executions are finished.
1693
1756
  */
1694
- readonly toolResults: Promise<ToolResultUnion<TOOLS>[]>;
1757
+ readonly toolResults: Promise<TypedToolResult<TOOLS>[]>;
1695
1758
  /**
1696
1759
  The reason why the generation finished. Taken from the last step.
1697
1760
 
@@ -1872,11 +1935,11 @@ type TextStreamPart<TOOLS extends ToolSet> = {
1872
1935
  file: GeneratedFile;
1873
1936
  } | ({
1874
1937
  type: 'tool-call';
1875
- } & ToolCallUnion<TOOLS>) | ({
1938
+ } & TypedToolCall<TOOLS>) | ({
1876
1939
  type: 'tool-result';
1877
- } & ToolResultUnion<TOOLS>) | ({
1940
+ } & TypedToolResult<TOOLS>) | ({
1878
1941
  type: 'tool-error';
1879
- } & ToolErrorUnion<TOOLS>) | {
1942
+ } & TypedToolError<TOOLS>) | {
1880
1943
  type: 'start-step';
1881
1944
  request: LanguageModelRequestMetadata;
1882
1945
  warnings: CallWarning[];
@@ -2214,11 +2277,11 @@ type SingleRequestTextStreamPart<TOOLS extends ToolSet> = {
2214
2277
  file: GeneratedFile;
2215
2278
  } | ({
2216
2279
  type: 'tool-call';
2217
- } & ToolCallUnion<TOOLS>) | ({
2280
+ } & TypedToolCall<TOOLS>) | ({
2218
2281
  type: 'tool-result';
2219
- } & ToolResultUnion<TOOLS>) | ({
2282
+ } & TypedToolResult<TOOLS>) | ({
2220
2283
  type: 'tool-error';
2221
- } & ToolErrorUnion<TOOLS>) | {
2284
+ } & TypedToolError<TOOLS>) | {
2222
2285
  type: 'file';
2223
2286
  file: GeneratedFile;
2224
2287
  } | {
@@ -4140,4 +4203,4 @@ declare global {
4140
4203
  var AI_SDK_DEFAULT_PROVIDER: ProviderV2 | undefined;
4141
4204
  }
4142
4205
 
4143
- export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolCallUnion, ToolChoice, ToolErrorUnion, ToolResultUnion, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };
4206
+ export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, CoreAssistantMessage, CoreMessage, CoreSystemMessage, CoreToolMessage, CoreUserMessage, CreateUIMessage, DataUIPart, DeepPartial, DefaultChatTransport, DownloadError, DynamicToolCall, DynamicToolError, DynamicToolResult, DynamicToolUIPart, EmbedManyResult, EmbedResult, Embedding, EmbeddingModel, EmbeddingModelUsage, ErrorHandler, Agent as Experimental_Agent, AgentSettings as Experimental_AgentSettings, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONRPCError, JSONRPCMessage, JSONRPCNotification, JSONRPCRequest, JSONRPCResponse, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MCPClientError, MCPTransport, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputSpecifiedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningUIPart, RepairTextFunction, RetryError, SerialJobExecutor, SourceDocumentUIPart, SourceUrlUIPart, SpeechModel, SpeechModelResponseMetadata, SpeechWarning, StaticToolCall, StaticToolError, StaticToolResult, StepResult, StepStartUIPart, StopCondition, StreamObjectOnFinishCallback, StreamObjectResult, StreamTextOnChunkCallback, StreamTextOnErrorCallback, StreamTextOnFinishCallback, StreamTextOnStepFinishCallback, StreamTextResult, StreamTextTransform, TelemetrySettings, TextStreamChatTransport, TextStreamPart, TextUIPart, ToolCallRepairError, ToolCallRepairFunction, ToolChoice, ToolSet, ToolUIPart, TranscriptionModel, TranscriptionModelResponseMetadata, TranscriptionWarning, TypedToolCall, TypedToolError, TypedToolResult, UIDataPartSchemas, UIDataTypes, UIMessage, UIMessageChunk, UIMessagePart, UIMessageStreamOnFinishCallback, UIMessageStreamOptions, UIMessageStreamWriter, UITool, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, createMCPClient as experimental_createMCPClient, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, hasToolCall, isDeepEqualData, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, readUIMessageStream, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, userModelMessageSchema, wrapLanguageModel, wrapProvider };