ai 5.0.271 → 5.0.273

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,29 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.273
4
+
5
+ ### Patch Changes
6
+
7
+ - 223133e: fix(ai): prevent deleted tools named after Object.prototype properties from exposing persisted output to models
8
+ - 51e2b34: fix(ai): prevent unavailable tools from exposing persisted output to models
9
+ - 5f95b09: fix(ai): avoid duplicate slashes in chat reconnect URLs
10
+ - Updated dependencies [4a65dd5]
11
+ - Updated dependencies [8f63231]
12
+ - Updated dependencies [95c921d]
13
+ - Updated dependencies [c858a31]
14
+ - @ai-sdk/gateway@2.0.164
15
+
16
+ ## 5.0.272
17
+
18
+ ### Patch Changes
19
+
20
+ - 8db50f1: fix(ui): export `isDynamicToolUIPart` from `ai` package
21
+ - Updated dependencies [44f892a]
22
+ - Updated dependencies [10f2cf9]
23
+ - Updated dependencies [78cac2e]
24
+ - Updated dependencies [fda0906]
25
+ - @ai-sdk/gateway@2.0.163
26
+
3
27
  ## 5.0.271
4
28
 
5
29
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1672,6 +1672,13 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1672
1672
  }>;
1673
1673
  type DynamicToolUIPart = {
1674
1674
  type: 'dynamic-tool';
1675
+ /**
1676
+ * `false` when a static tool part was normalized to a dynamic tool part
1677
+ * because its current tool schema was unavailable or incompatible.
1678
+ *
1679
+ * This preserves its static origin across persistence boundaries.
1680
+ */
1681
+ dynamic?: false;
1675
1682
  /**
1676
1683
  * Name of the tool that is being called.
1677
1684
  */
@@ -1730,6 +1737,7 @@ declare function isFileUIPart(part: UIMessagePart<UIDataTypes, UITools>): part i
1730
1737
  */
1731
1738
  declare function isReasoningUIPart(part: UIMessagePart<UIDataTypes, UITools>): part is ReasoningUIPart;
1732
1739
  declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
1740
+ declare function isDynamicToolUIPart(part: UIMessagePart<UIDataTypes, UITools>): part is DynamicToolUIPart;
1733
1741
  declare function isToolOrDynamicToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS> | DynamicToolUIPart;
1734
1742
  declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): keyof TOOLS;
1735
1743
  declare function getToolOrDynamicToolName(part: ToolUIPart<UITools> | DynamicToolUIPart): string;
@@ -4531,4 +4539,4 @@ declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages
4531
4539
  */
4532
4540
  declare function validateUIMessages<UI_MESSAGE extends UIMessage>(options: ValidateUIMessagesOptions<UI_MESSAGE>): Promise<Array<UI_MESSAGE>>;
4533
4541
 
4534
- export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, 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, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, 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, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
4542
+ export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, 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, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, 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, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
package/dist/index.d.ts CHANGED
@@ -1672,6 +1672,13 @@ type ToolUIPart<TOOLS extends UITools = UITools> = ValueOf<{
1672
1672
  }>;
1673
1673
  type DynamicToolUIPart = {
1674
1674
  type: 'dynamic-tool';
1675
+ /**
1676
+ * `false` when a static tool part was normalized to a dynamic tool part
1677
+ * because its current tool schema was unavailable or incompatible.
1678
+ *
1679
+ * This preserves its static origin across persistence boundaries.
1680
+ */
1681
+ dynamic?: false;
1675
1682
  /**
1676
1683
  * Name of the tool that is being called.
1677
1684
  */
@@ -1730,6 +1737,7 @@ declare function isFileUIPart(part: UIMessagePart<UIDataTypes, UITools>): part i
1730
1737
  */
1731
1738
  declare function isReasoningUIPart(part: UIMessagePart<UIDataTypes, UITools>): part is ReasoningUIPart;
1732
1739
  declare function isToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS>;
1740
+ declare function isDynamicToolUIPart(part: UIMessagePart<UIDataTypes, UITools>): part is DynamicToolUIPart;
1733
1741
  declare function isToolOrDynamicToolUIPart<TOOLS extends UITools>(part: UIMessagePart<UIDataTypes, TOOLS>): part is ToolUIPart<TOOLS> | DynamicToolUIPart;
1734
1742
  declare function getToolName<TOOLS extends UITools>(part: ToolUIPart<TOOLS>): keyof TOOLS;
1735
1743
  declare function getToolOrDynamicToolName(part: ToolUIPart<UITools> | DynamicToolUIPart): string;
@@ -4531,4 +4539,4 @@ declare function safeValidateUIMessages<UI_MESSAGE extends UIMessage>({ messages
4531
4539
  */
4532
4540
  declare function validateUIMessages<UI_MESSAGE extends UIMessage>(options: ValidateUIMessagesOptions<UI_MESSAGE>): Promise<Array<UI_MESSAGE>>;
4533
4541
 
4534
- export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, 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, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, 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, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
4542
+ export { AbstractChat, AsyncIterableStream, CallSettings, CallWarning, ChatInit, ChatOnDataCallback, ChatOnErrorCallback, ChatOnFinishCallback, ChatOnToolCallCallback, ChatRequestOptions, ChatState, ChatStatus, ChatTransport, ChunkDetector, CompletionRequestOptions, ContentPart, 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, DownloadFunction as Experimental_DownloadFunction, GenerateImageResult as Experimental_GenerateImageResult, GeneratedFile as Experimental_GeneratedImage, InferAgentUIMessage as Experimental_InferAgentUIMessage, LogWarningsFunction as Experimental_LogWarningsFunction, SpeechResult as Experimental_SpeechResult, TranscriptionResult as Experimental_TranscriptionResult, Warning as Experimental_Warning, FileUIPart, FinishReason, GenerateObjectResult, GenerateTextOnStepFinishCallback, GenerateTextResult, GeneratedAudioFile, GeneratedFile, HttpChatTransport, HttpChatTransportInitOptions, ImageModel, ImageGenerationWarning as ImageModelCallWarning, ImageModelProviderMetadata, ImageModelResponseMetadata, InferUIDataParts, InferUIMessageChunk, InferUITool, InferUITools, InvalidArgumentError, InvalidDataContentError, InvalidMessageRoleError, InvalidStreamPartError, InvalidToolInputError, JSONValue, JsonToSseTransformStream, LanguageModel, LanguageModelMiddleware, LanguageModelRequestMetadata, LanguageModelResponseMetadata, LanguageModelUsage, MessageConversionError, NoImageGeneratedError, NoObjectGeneratedError, NoOutputGeneratedError, NoOutputSpecifiedError, NoSpeechGeneratedError, NoSuchProviderError, NoSuchToolError, ObjectStreamPart, output as Output, Output as OutputInterface, PrepareReconnectToStreamRequest, PrepareSendMessagesRequest, PrepareStepFunction, PrepareStepResult, Prompt, Provider, ProviderMetadata, ProviderRegistryProvider, ReasoningOutput, ReasoningUIPart, RepairTextFunction, RetryError, SafeValidateUIMessagesResult, 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, UIMessageStreamOutcome, UIMessageStreamWriter, UIMessageStreamWriterWithOutcome, UITool, UIToolInvocation, UITools, UI_MESSAGE_STREAM_HEADERS, UnsupportedModelVersionError, UseCompletionOptions, assistantModelMessageSchema, callCompletionApi, consumeStream, convertFileListToFileUIParts, convertToCoreMessages, convertToModelMessages, coreAssistantMessageSchema, coreMessageSchema, coreSystemMessageSchema, coreToolMessageSchema, coreUserMessageSchema, cosineSimilarity, createDownload, createProviderRegistry, createTextStreamResponse, createUIMessageStream, createUIMessageStreamResponse, customProvider, defaultSettingsMiddleware, embed, embedMany, experimental_createProviderRegistry, experimental_customProvider, generateImage as experimental_generateImage, generateSpeech as experimental_generateSpeech, transcribe as experimental_transcribe, extractReasoningMiddleware, generateObject, generateText, getTextFromDataUrl, getToolName, getToolOrDynamicToolName, hasToolCall, isDataUIPart, isDeepEqualData, isDynamicToolUIPart, isFileUIPart, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart, isToolUIPart, lastAssistantMessageIsCompleteWithToolCalls, modelMessageSchema, parsePartialJson, pipeTextStreamToResponse, pipeUIMessageStreamToResponse, pruneMessages, readUIMessageStream, safeValidateUIMessages, simulateReadableStream, simulateStreamingMiddleware, smoothStream, stepCountIs, streamObject, streamText, systemModelMessageSchema, toolModelMessageSchema, uiMessageChunkSchema, userModelMessageSchema, validateUIMessages, wrapLanguageModel, wrapProvider };
package/dist/index.js CHANGED
@@ -100,6 +100,7 @@ __export(src_exports, {
100
100
  hasToolCall: () => hasToolCall,
101
101
  isDataUIPart: () => isDataUIPart,
102
102
  isDeepEqualData: () => isDeepEqualData,
103
+ isDynamicToolUIPart: () => isDynamicToolUIPart,
103
104
  isFileUIPart: () => isFileUIPart,
104
105
  isReasoningUIPart: () => isReasoningUIPart,
105
106
  isTextUIPart: () => isTextUIPart,
@@ -816,7 +817,7 @@ function detectMediaType({
816
817
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
817
818
 
818
819
  // src/version.ts
819
- var VERSION = true ? "5.0.271" : "0.0.0-test";
820
+ var VERSION = true ? "5.0.273" : "0.0.0-test";
820
821
 
821
822
  // src/util/download/download.ts
822
823
  var download = async ({
@@ -6387,6 +6388,20 @@ var DefaultStreamTextResult = class {
6387
6388
  }
6388
6389
  };
6389
6390
 
6391
+ // src/util/get-own.ts
6392
+ function getOwn(obj, key) {
6393
+ return obj != null && Object.hasOwn(obj, key) ? obj[key] : void 0;
6394
+ }
6395
+
6396
+ // src/ui/unavailable-tool.ts
6397
+ function markToolPartAsUnavailable(part) {
6398
+ part.dynamic = false;
6399
+ return part;
6400
+ }
6401
+ function isToolPartFromUnavailableTool(part) {
6402
+ return part.type === "dynamic-tool" && part.dynamic === false;
6403
+ }
6404
+
6390
6405
  // src/ui/convert-to-model-messages.ts
6391
6406
  function convertToModelMessages(messages, options) {
6392
6407
  const modelMessages = [];
@@ -6398,6 +6413,25 @@ function convertToModelMessages(messages, options) {
6398
6413
  )
6399
6414
  }));
6400
6415
  }
6416
+ function createModelOutput({
6417
+ toolPart,
6418
+ toolName,
6419
+ output,
6420
+ errorMode
6421
+ }) {
6422
+ const tool2 = getOwn(options == null ? void 0 : options.tools, toolName);
6423
+ if (errorMode === "none" && tool2 == null && isToolPartFromUnavailableTool(toolPart)) {
6424
+ return {
6425
+ type: "text",
6426
+ value: "Tool output omitted because the tool is no longer available."
6427
+ };
6428
+ }
6429
+ return createToolModelOutput({
6430
+ output,
6431
+ tool: tool2,
6432
+ errorMode
6433
+ });
6434
+ }
6401
6435
  for (const message of messages) {
6402
6436
  switch (message.role) {
6403
6437
  case "system": {
@@ -6451,7 +6485,7 @@ function convertToModelMessages(messages, options) {
6451
6485
  case "assistant": {
6452
6486
  if (message.parts != null) {
6453
6487
  let processBlock2 = function() {
6454
- var _a16, _b, _c;
6488
+ var _a16, _b;
6455
6489
  if (block.length === 0) {
6456
6490
  return;
6457
6491
  }
@@ -6503,9 +6537,10 @@ function convertToModelMessages(messages, options) {
6503
6537
  type: "tool-result",
6504
6538
  toolCallId: part.toolCallId,
6505
6539
  toolName,
6506
- output: createToolModelOutput({
6540
+ output: createModelOutput({
6541
+ toolPart: part,
6542
+ toolName,
6507
6543
  output: part.state === "output-error" ? part.errorText : part.output,
6508
- tool: (_b = options == null ? void 0 : options.tools) == null ? void 0 : _b[toolName],
6509
6544
  errorMode: part.state === "output-error" ? "json" : "none"
6510
6545
  }),
6511
6546
  ...part.callProviderMetadata != null ? { providerOptions: part.callProviderMetadata } : {}
@@ -6513,7 +6548,7 @@ function convertToModelMessages(messages, options) {
6513
6548
  }
6514
6549
  }
6515
6550
  } else if (isDataUIPart(part)) {
6516
- const dataPart = (_c = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _c.call(
6551
+ const dataPart = (_b = options == null ? void 0 : options.convertDataPart) == null ? void 0 : _b.call(
6517
6552
  options,
6518
6553
  part
6519
6554
  );
@@ -6536,7 +6571,6 @@ function convertToModelMessages(messages, options) {
6536
6571
  modelMessages.push({
6537
6572
  role: "tool",
6538
6573
  content: toolParts.map((toolPart) => {
6539
- var _a17;
6540
6574
  switch (toolPart.state) {
6541
6575
  case "output-error":
6542
6576
  case "output-available": {
@@ -6545,9 +6579,10 @@ function convertToModelMessages(messages, options) {
6545
6579
  type: "tool-result",
6546
6580
  toolCallId: toolPart.toolCallId,
6547
6581
  toolName,
6548
- output: createToolModelOutput({
6582
+ output: createModelOutput({
6583
+ toolPart,
6584
+ toolName,
6549
6585
  output: toolPart.state === "output-error" ? toolPart.errorText : toolPart.output,
6550
- tool: (_a17 = options == null ? void 0 : options.tools) == null ? void 0 : _a17[toolName],
6551
6586
  errorMode: toolPart.state === "output-error" ? "text" : "none"
6552
6587
  }),
6553
6588
  ...toolPart.callProviderMetadata != null ? { providerOptions: toolPart.callProviderMetadata } : {}
@@ -6740,11 +6775,6 @@ var DefaultEmbedResult = class {
6740
6775
  }
6741
6776
  };
6742
6777
 
6743
- // src/util/get-own.ts
6744
- function getOwn(obj, key) {
6745
- return obj != null && Object.hasOwn(obj, key) ? obj[key] : void 0;
6746
- }
6747
-
6748
6778
  // src/util/set-own.ts
6749
6779
  function setOwn(object2, key, value) {
6750
6780
  Object.defineProperty(object2, key, {
@@ -9777,7 +9807,9 @@ var import_provider_utils31 = require("@ai-sdk/provider-utils");
9777
9807
  var import_provider_utils30 = require("@ai-sdk/provider-utils");
9778
9808
  function appendPathToUrl(url, path) {
9779
9809
  const queryOrFragmentStart = url.search(/[?#]/);
9780
- return queryOrFragmentStart === -1 ? `${url}${path}` : `${url.slice(0, queryOrFragmentStart)}${path}${url.slice(queryOrFragmentStart)}`;
9810
+ const urlPath = queryOrFragmentStart === -1 ? url : url.slice(0, queryOrFragmentStart);
9811
+ const suffix = queryOrFragmentStart === -1 ? "" : url.slice(queryOrFragmentStart);
9812
+ return `${urlPath.endsWith("/") && path.startsWith("/") ? urlPath.slice(0, -1) : urlPath}${path}${suffix}`;
9781
9813
  }
9782
9814
  var HttpChatTransport = class {
9783
9815
  constructor({
@@ -10412,20 +10444,20 @@ function asDynamicToolPart(toolPart) {
10412
10444
  ...toolPart.callProviderMetadata === void 0 ? {} : { callProviderMetadata: toolPart.callProviderMetadata }
10413
10445
  };
10414
10446
  if (toolPart.state === "output-available") {
10415
- return {
10447
+ return markToolPartAsUnavailable({
10416
10448
  ...common,
10417
10449
  state: "output-available",
10418
10450
  input: toolPart.input,
10419
10451
  output: toolPart.output,
10420
10452
  ...toolPart.preliminary === void 0 ? {} : { preliminary: toolPart.preliminary }
10421
- };
10453
+ });
10422
10454
  }
10423
- return {
10455
+ return markToolPartAsUnavailable({
10424
10456
  ...common,
10425
10457
  state: "output-error",
10426
10458
  input: toolPart.input,
10427
10459
  errorText: toolPart.errorText
10428
- };
10460
+ });
10429
10461
  }
10430
10462
  var uiMessagesSchema = (0, import_provider_utils33.lazyValidator)(
10431
10463
  () => (0, import_provider_utils33.zodSchema)(
@@ -10481,6 +10513,7 @@ var uiMessagesSchema = (0, import_provider_utils33.lazyValidator)(
10481
10513
  }),
10482
10514
  import_v48.z.object({
10483
10515
  type: import_v48.z.literal("dynamic-tool"),
10516
+ dynamic: import_v48.z.literal(false).optional(),
10484
10517
  toolName: import_v48.z.string(),
10485
10518
  toolCallId: import_v48.z.string(),
10486
10519
  state: import_v48.z.literal("input-streaming"),
@@ -10492,6 +10525,7 @@ var uiMessagesSchema = (0, import_provider_utils33.lazyValidator)(
10492
10525
  }),
10493
10526
  import_v48.z.object({
10494
10527
  type: import_v48.z.literal("dynamic-tool"),
10528
+ dynamic: import_v48.z.literal(false).optional(),
10495
10529
  toolName: import_v48.z.string(),
10496
10530
  toolCallId: import_v48.z.string(),
10497
10531
  state: import_v48.z.literal("input-available"),
@@ -10503,6 +10537,7 @@ var uiMessagesSchema = (0, import_provider_utils33.lazyValidator)(
10503
10537
  }),
10504
10538
  import_v48.z.object({
10505
10539
  type: import_v48.z.literal("dynamic-tool"),
10540
+ dynamic: import_v48.z.literal(false).optional(),
10506
10541
  toolName: import_v48.z.string(),
10507
10542
  toolCallId: import_v48.z.string(),
10508
10543
  state: import_v48.z.literal("output-available"),
@@ -10515,6 +10550,7 @@ var uiMessagesSchema = (0, import_provider_utils33.lazyValidator)(
10515
10550
  }),
10516
10551
  import_v48.z.object({
10517
10552
  type: import_v48.z.literal("dynamic-tool"),
10553
+ dynamic: import_v48.z.literal(false).optional(),
10518
10554
  toolName: import_v48.z.string(),
10519
10555
  toolCallId: import_v48.z.string(),
10520
10556
  state: import_v48.z.literal("output-error"),
@@ -10714,7 +10750,7 @@ async function safeValidateUIMessages({
10714
10750
  }
10715
10751
  const toolPart = part;
10716
10752
  const toolName = toolPart.type.slice(5);
10717
- const tool2 = tools[toolName];
10753
+ const tool2 = getOwn(tools, toolName);
10718
10754
  if (!tool2 && (toolPart.state === "output-available" || toolPart.state === "output-error")) {
10719
10755
  message.parts[partIdx] = asDynamicToolPart(toolPart);
10720
10756
  continue;
@@ -11056,6 +11092,7 @@ function readUIMessageStream({
11056
11092
  hasToolCall,
11057
11093
  isDataUIPart,
11058
11094
  isDeepEqualData,
11095
+ isDynamicToolUIPart,
11059
11096
  isFileUIPart,
11060
11097
  isReasoningUIPart,
11061
11098
  isTextUIPart,