ai 5.0.199 → 5.0.200

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,32 @@
1
1
  # ai
2
2
 
3
+ ## 5.0.200
4
+
5
+ ### Patch Changes
6
+
7
+ - eea9166: fix: harden download URL SSRF guard against hostname and redirect bypasses
8
+
9
+ `validateDownloadUrl` and the file download helpers (`downloadBlob`, `download`) could be bypassed in several ways when handling untrusted URLs:
10
+
11
+ - A fully-qualified hostname with a trailing dot (e.g. `localhost.`, `myhost.local.`) skipped the localhost/`.local` blocklist.
12
+ - IPv6 addresses that embed an IPv4 address in their last 32 bits — IPv4-compatible (`::127.0.0.1`), IPv4-translated (`::ffff:0:127.0.0.1`), and NAT64 (`64:ff9b::127.0.0.1`, including the `64:ff9b:1::/48` local-use prefix) — were not decoded and checked against the private IPv4 ranges.
13
+ - Redirects were validated only _after_ `fetch` had already followed them, so the request to a redirect target (e.g. an internal/metadata address) had already been issued before the check ran.
14
+ - Several reserved/internal address ranges were not blocked: CGNAT (`100.64.0.0/10`, used by some cloud providers for internal traffic), benchmarking (`198.18.0.0/15`), IETF protocol assignments (`192.0.0.0/24`), the reserved `240.0.0.0/4` block (including the `255.255.255.255` broadcast address), and IPv6 site-local (`fec0::/10`) and multicast (`ff00::/8`).
15
+
16
+ The validator now strips trailing dots before the hostname checks and fully expands IPv6 addresses to detect embedded private IPv4 targets. The download helpers now follow redirects manually (`redirect: 'manual'`), re-validating each hop before requesting it, so an unsafe redirect target is never fetched. When a redirect cannot be inspected because the runtime returns an opaque response, the helpers fail closed (reject the redirect) on the server; only in a real browser — where SSRF is not reachable (fetch is constrained by CORS and cannot reach a server's internal network or cloud-metadata endpoints) — is the redirect followed natively so legitimate redirected downloads keep working.
17
+
18
+ - 15cf74f: Harden stream text processing and middleware against prototype pollution from stream part IDs.
19
+ - 8ad6f80: fix: redact server error details from UI message streams by default
20
+
21
+ `streamText(...).toUIMessageStream()` and `createUIMessageStream` defaulted their `onError` callback to `getErrorMessage`, which serializes the raw error (`error.toString()` / `JSON.stringify(error)`) into the client-facing `{ type: 'error', errorText }` chunk — and also into `tool-output-error` parts. The documented default was `() => 'An error occurred.'`, so applications relying on the documented behavior were unknowingly streaming server exception details (internal hostnames, paths, provider request data, validation inputs) to end users.
22
+
23
+ The default `onError` now returns the documented generic `'An error occurred.'`. Raw error details are only emitted when the developer explicitly supplies an `onError` handler. This also redacts `tool-output-error` and invalid-tool-input error text by default; pass an `onError` to surface richer messages.
24
+
25
+ - Updated dependencies [9f67efe]
26
+ - Updated dependencies [eea9166]
27
+ - @ai-sdk/provider-utils@3.0.26
28
+ - @ai-sdk/gateway@2.0.99
29
+
3
30
  ## 5.0.199
4
31
 
5
32
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3964,7 +3964,21 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
3964
3964
  onError: ErrorHandler | undefined;
3965
3965
  }
3966
3966
 
3967
- declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, originalMessages, onFinish, generateId, }: {
3967
+ /**
3968
+ * Creates a UI message stream that can be used to send messages to the client.
3969
+ *
3970
+ * @param options.execute - A function that is called with a writer to write UI message chunks to the stream.
3971
+ * @param options.onError - A function that extracts an error message from an error. Defaults to `() => 'An error occurred.'` so server-side error details are not leaked to the client; supply your own to surface richer messages.
3972
+ * @param options.originalMessages - The original messages. If provided, persistence mode is assumed
3973
+ * and a message ID is provided for the response message.
3974
+ * @param options.onStepFinish - A callback that is called when each step finishes. Useful for persisting intermediate messages.
3975
+ * @param options.onFinish - A callback that is called when the stream finishes.
3976
+ * @param options.generateId - A function that generates a unique ID. Defaults to the built-in ID generator.
3977
+ *
3978
+ * @returns A `ReadableStream` of UI message chunks.
3979
+ */
3980
+ declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, // prevent leaking server error details to the client by default
3981
+ originalMessages, onFinish, generateId, }: {
3968
3982
  execute: (options: {
3969
3983
  writer: UIMessageStreamWriter<UI_MESSAGE>;
3970
3984
  }) => Promise<void> | void;
package/dist/index.d.ts CHANGED
@@ -3964,7 +3964,21 @@ interface UIMessageStreamWriter<UI_MESSAGE extends UIMessage = UIMessage> {
3964
3964
  onError: ErrorHandler | undefined;
3965
3965
  }
3966
3966
 
3967
- declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, originalMessages, onFinish, generateId, }: {
3967
+ /**
3968
+ * Creates a UI message stream that can be used to send messages to the client.
3969
+ *
3970
+ * @param options.execute - A function that is called with a writer to write UI message chunks to the stream.
3971
+ * @param options.onError - A function that extracts an error message from an error. Defaults to `() => 'An error occurred.'` so server-side error details are not leaked to the client; supply your own to surface richer messages.
3972
+ * @param options.originalMessages - The original messages. If provided, persistence mode is assumed
3973
+ * and a message ID is provided for the response message.
3974
+ * @param options.onStepFinish - A callback that is called when each step finishes. Useful for persisting intermediate messages.
3975
+ * @param options.onFinish - A callback that is called when the stream finishes.
3976
+ * @param options.generateId - A function that generates a unique ID. Defaults to the built-in ID generator.
3977
+ *
3978
+ * @returns A `ReadableStream` of UI message chunks.
3979
+ */
3980
+ declare function createUIMessageStream<UI_MESSAGE extends UIMessage>({ execute, onError, // prevent leaking server error details to the client by default
3981
+ originalMessages, onFinish, generateId, }: {
3968
3982
  execute: (options: {
3969
3983
  writer: UIMessageStreamWriter<UI_MESSAGE>;
3970
3984
  }) => Promise<void> | void;
package/dist/index.js CHANGED
@@ -778,7 +778,7 @@ function detectMediaType({
778
778
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
779
779
 
780
780
  // src/version.ts
781
- var VERSION = true ? "5.0.199" : "0.0.0-test";
781
+ var VERSION = true ? "5.0.200" : "0.0.0-test";
782
782
 
783
783
  // src/util/download/download.ts
784
784
  var download = async ({
@@ -788,21 +788,19 @@ var download = async ({
788
788
  }) => {
789
789
  var _a16;
790
790
  const urlText = url.toString();
791
- (0, import_provider_utils2.validateDownloadUrl)(urlText);
792
791
  try {
793
- const response = await fetch(urlText, {
794
- headers: (0, import_provider_utils2.withUserAgentSuffix)(
795
- {},
796
- `ai-sdk/${VERSION}`,
797
- (0, import_provider_utils2.getRuntimeEnvironmentUserAgent)()
798
- ),
799
- signal: abortSignal
792
+ const headers = (0, import_provider_utils2.withUserAgentSuffix)(
793
+ {},
794
+ `ai-sdk/${VERSION}`,
795
+ (0, import_provider_utils2.getRuntimeEnvironmentUserAgent)()
796
+ );
797
+ const response = await (0, import_provider_utils2.fetchWithValidatedRedirects)({
798
+ url: urlText,
799
+ headers,
800
+ abortSignal
800
801
  });
801
- if (response.redirected) {
802
- (0, import_provider_utils2.validateDownloadUrl)(response.url);
803
- }
804
802
  if (!response.ok) {
805
- throw new DownloadError({
803
+ throw new import_provider_utils2.DownloadError({
806
804
  url: urlText,
807
805
  statusCode: response.status,
808
806
  statusText: response.statusText
@@ -818,10 +816,10 @@ var download = async ({
818
816
  mediaType: (_a16 = response.headers.get("content-type")) != null ? _a16 : void 0
819
817
  };
820
818
  } catch (error) {
821
- if (DownloadError.isInstance(error)) {
819
+ if (import_provider_utils2.DownloadError.isInstance(error)) {
822
820
  throw error;
823
821
  }
824
- throw new DownloadError({ url: urlText, cause: error });
822
+ throw new import_provider_utils2.DownloadError({ url: urlText, cause: error });
825
823
  }
826
824
  };
827
825
 
@@ -2839,7 +2837,6 @@ function asContent({
2839
2837
  }
2840
2838
 
2841
2839
  // src/generate-text/stream-text.ts
2842
- var import_provider23 = require("@ai-sdk/provider");
2843
2840
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
2844
2841
 
2845
2842
  // src/util/prepare-headers.ts
@@ -4730,8 +4727,8 @@ var DefaultStreamTextResult = class {
4730
4727
  let recordedWarnings = [];
4731
4728
  const recordedSteps = [];
4732
4729
  let rootSpan;
4733
- let activeTextContent = {};
4734
- let activeReasoningContent = {};
4730
+ let activeTextContent = createIdMap();
4731
+ let activeReasoningContent = createIdMap();
4735
4732
  const eventProcessor = new TransformStream({
4736
4733
  async transform(chunk, controller) {
4737
4734
  var _a16, _b, _c, _d;
@@ -4835,6 +4832,9 @@ var DefaultStreamTextResult = class {
4835
4832
  recordedContent.push(part);
4836
4833
  }
4837
4834
  if (part.type === "start-step") {
4835
+ recordedContent = [];
4836
+ activeReasoningContent = createIdMap();
4837
+ activeTextContent = createIdMap();
4838
4838
  recordedRequest = part.request;
4839
4839
  recordedWarnings = part.warnings;
4840
4840
  }
@@ -4859,8 +4859,8 @@ var DefaultStreamTextResult = class {
4859
4859
  logWarnings(recordedWarnings);
4860
4860
  recordedSteps.push(currentStepResult);
4861
4861
  recordedContent = [];
4862
- activeReasoningContent = {};
4863
- activeTextContent = {};
4862
+ activeReasoningContent = createIdMap();
4863
+ activeTextContent = createIdMap();
4864
4864
  recordedResponseMessages.push(...stepMessages);
4865
4865
  stepFinish.resolve();
4866
4866
  }
@@ -5566,7 +5566,8 @@ var DefaultStreamTextResult = class {
5566
5566
  sendSources = false,
5567
5567
  sendStart = true,
5568
5568
  sendFinish = true,
5569
- onError = import_provider23.getErrorMessage
5569
+ onError = () => "An error occurred."
5570
+ // prevent leaking server error details to the client by default
5570
5571
  } = {}) {
5571
5572
  const responseMessageId = generateMessageId != null ? getResponseUIMessageId({
5572
5573
  originalMessages,
@@ -6612,7 +6613,7 @@ function extractReasoningContent(content) {
6612
6613
  }
6613
6614
 
6614
6615
  // src/generate-object/output-strategy.ts
6615
- var import_provider24 = require("@ai-sdk/provider");
6616
+ var import_provider23 = require("@ai-sdk/provider");
6616
6617
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
6617
6618
  var noSchemaOutputStrategy = {
6618
6619
  type: "no-schema",
@@ -6633,7 +6634,7 @@ var noSchemaOutputStrategy = {
6633
6634
  } : { success: true, value };
6634
6635
  },
6635
6636
  createElementStream() {
6636
- throw new import_provider24.UnsupportedFunctionalityError({
6637
+ throw new import_provider23.UnsupportedFunctionalityError({
6637
6638
  functionality: "element streams in no-schema mode"
6638
6639
  });
6639
6640
  }
@@ -6655,7 +6656,7 @@ var objectOutputStrategy = (schema) => ({
6655
6656
  return (0, import_provider_utils19.safeValidateTypes)({ value, schema });
6656
6657
  },
6657
6658
  createElementStream() {
6658
- throw new import_provider24.UnsupportedFunctionalityError({
6659
+ throw new import_provider23.UnsupportedFunctionalityError({
6659
6660
  functionality: "element streams in object mode"
6660
6661
  });
6661
6662
  }
@@ -6683,10 +6684,10 @@ var arrayOutputStrategy = (schema) => {
6683
6684
  isFinalDelta
6684
6685
  }) {
6685
6686
  var _a16;
6686
- if (!(0, import_provider24.isJSONObject)(value) || !(0, import_provider24.isJSONArray)(value.elements)) {
6687
+ if (!(0, import_provider23.isJSONObject)(value) || !(0, import_provider23.isJSONArray)(value.elements)) {
6687
6688
  return {
6688
6689
  success: false,
6689
- error: new import_provider24.TypeValidationError({
6690
+ error: new import_provider23.TypeValidationError({
6690
6691
  value,
6691
6692
  cause: "value must be an object that contains an array of elements"
6692
6693
  })
@@ -6726,10 +6727,10 @@ var arrayOutputStrategy = (schema) => {
6726
6727
  };
6727
6728
  },
6728
6729
  async validateFinalResult(value) {
6729
- if (!(0, import_provider24.isJSONObject)(value) || !(0, import_provider24.isJSONArray)(value.elements)) {
6730
+ if (!(0, import_provider23.isJSONObject)(value) || !(0, import_provider23.isJSONArray)(value.elements)) {
6730
6731
  return {
6731
6732
  success: false,
6732
- error: new import_provider24.TypeValidationError({
6733
+ error: new import_provider23.TypeValidationError({
6733
6734
  value,
6734
6735
  cause: "value must be an object that contains an array of elements"
6735
6736
  })
@@ -6794,10 +6795,10 @@ var enumOutputStrategy = (enumValues) => {
6794
6795
  additionalProperties: false
6795
6796
  },
6796
6797
  async validateFinalResult(value) {
6797
- if (!(0, import_provider24.isJSONObject)(value) || typeof value.result !== "string") {
6798
+ if (!(0, import_provider23.isJSONObject)(value) || typeof value.result !== "string") {
6798
6799
  return {
6799
6800
  success: false,
6800
- error: new import_provider24.TypeValidationError({
6801
+ error: new import_provider23.TypeValidationError({
6801
6802
  value,
6802
6803
  cause: 'value must be an object that contains a string in the "result" property.'
6803
6804
  })
@@ -6806,17 +6807,17 @@ var enumOutputStrategy = (enumValues) => {
6806
6807
  const result = value.result;
6807
6808
  return enumValues.includes(result) ? { success: true, value: result } : {
6808
6809
  success: false,
6809
- error: new import_provider24.TypeValidationError({
6810
+ error: new import_provider23.TypeValidationError({
6810
6811
  value,
6811
6812
  cause: "value must be a string in the enum"
6812
6813
  })
6813
6814
  };
6814
6815
  },
6815
6816
  async validatePartialResult({ value, textDelta }) {
6816
- if (!(0, import_provider24.isJSONObject)(value) || typeof value.result !== "string") {
6817
+ if (!(0, import_provider23.isJSONObject)(value) || typeof value.result !== "string") {
6817
6818
  return {
6818
6819
  success: false,
6819
- error: new import_provider24.TypeValidationError({
6820
+ error: new import_provider23.TypeValidationError({
6820
6821
  value,
6821
6822
  cause: 'value must be an object that contains a string in the "result" property.'
6822
6823
  })
@@ -6829,7 +6830,7 @@ var enumOutputStrategy = (enumValues) => {
6829
6830
  if (value.result.length === 0 || possibleEnumValues.length === 0) {
6830
6831
  return {
6831
6832
  success: false,
6832
- error: new import_provider24.TypeValidationError({
6833
+ error: new import_provider23.TypeValidationError({
6833
6834
  value,
6834
6835
  cause: "value must be a string in the enum"
6835
6836
  })
@@ -6844,7 +6845,7 @@ var enumOutputStrategy = (enumValues) => {
6844
6845
  };
6845
6846
  },
6846
6847
  createElementStream() {
6847
- throw new import_provider24.UnsupportedFunctionalityError({
6848
+ throw new import_provider23.UnsupportedFunctionalityError({
6848
6849
  functionality: "element streams in enum mode"
6849
6850
  });
6850
6851
  }
@@ -6872,7 +6873,7 @@ function getOutputStrategy({
6872
6873
  }
6873
6874
 
6874
6875
  // src/generate-object/parse-and-validate-object-result.ts
6875
- var import_provider25 = require("@ai-sdk/provider");
6876
+ var import_provider24 = require("@ai-sdk/provider");
6876
6877
  var import_provider_utils20 = require("@ai-sdk/provider-utils");
6877
6878
  async function parseAndValidateObjectResult(result, outputStrategy, context) {
6878
6879
  const parseResult = await (0, import_provider_utils20.safeParseJSON)({ text: result });
@@ -6910,7 +6911,7 @@ async function parseAndValidateObjectResultWithRepair(result, outputStrategy, re
6910
6911
  try {
6911
6912
  return await parseAndValidateObjectResult(result, outputStrategy, context);
6912
6913
  } catch (error) {
6913
- if (repairText != null && NoObjectGeneratedError.isInstance(error) && (import_provider25.JSONParseError.isInstance(error.cause) || import_provider25.TypeValidationError.isInstance(error.cause))) {
6914
+ if (repairText != null && NoObjectGeneratedError.isInstance(error) && (import_provider24.JSONParseError.isInstance(error.cause) || import_provider24.TypeValidationError.isInstance(error.cause))) {
6914
6915
  const repairedText = await repairText({
6915
6916
  text: result,
6916
6917
  error: error.cause
@@ -8223,7 +8224,7 @@ function pruneMessages({
8223
8224
 
8224
8225
  // src/generate-text/smooth-stream.ts
8225
8226
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
8226
- var import_provider26 = require("@ai-sdk/provider");
8227
+ var import_provider25 = require("@ai-sdk/provider");
8227
8228
  var CHUNKING_REGEXPS = {
8228
8229
  word: /\S+\s+/m,
8229
8230
  line: /\n+/m
@@ -8253,7 +8254,7 @@ function smoothStream({
8253
8254
  } else {
8254
8255
  const chunkingRegex = typeof chunking === "string" ? CHUNKING_REGEXPS[chunking] : chunking;
8255
8256
  if (chunkingRegex == null) {
8256
- throw new import_provider26.InvalidArgumentError({
8257
+ throw new import_provider25.InvalidArgumentError({
8257
8258
  argument: "chunking",
8258
8259
  message: `Chunking must be "word" or "line" or a RegExp. Received: ${chunking}`
8259
8260
  });
@@ -8374,7 +8375,7 @@ function extractReasoningMiddleware({
8374
8375
  },
8375
8376
  wrapStream: async ({ doStream }) => {
8376
8377
  const { stream, ...rest } = await doStream();
8377
- const reasoningExtractions = {};
8378
+ const reasoningExtractions = createIdMap();
8378
8379
  let delayedTextStart;
8379
8380
  return {
8380
8381
  stream: stream.pipeThrough(
@@ -8625,7 +8626,7 @@ function wrapProvider({
8625
8626
  }
8626
8627
 
8627
8628
  // src/registry/custom-provider.ts
8628
- var import_provider27 = require("@ai-sdk/provider");
8629
+ var import_provider26 = require("@ai-sdk/provider");
8629
8630
  function customProvider({
8630
8631
  languageModels,
8631
8632
  textEmbeddingModels,
@@ -8642,7 +8643,7 @@ function customProvider({
8642
8643
  if (fallbackProvider) {
8643
8644
  return fallbackProvider.languageModel(modelId);
8644
8645
  }
8645
- throw new import_provider27.NoSuchModelError({ modelId, modelType: "languageModel" });
8646
+ throw new import_provider26.NoSuchModelError({ modelId, modelType: "languageModel" });
8646
8647
  },
8647
8648
  textEmbeddingModel(modelId) {
8648
8649
  if (textEmbeddingModels != null && modelId in textEmbeddingModels) {
@@ -8651,7 +8652,7 @@ function customProvider({
8651
8652
  if (fallbackProvider) {
8652
8653
  return fallbackProvider.textEmbeddingModel(modelId);
8653
8654
  }
8654
- throw new import_provider27.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
8655
+ throw new import_provider26.NoSuchModelError({ modelId, modelType: "textEmbeddingModel" });
8655
8656
  },
8656
8657
  imageModel(modelId) {
8657
8658
  if (imageModels != null && modelId in imageModels) {
@@ -8660,7 +8661,7 @@ function customProvider({
8660
8661
  if (fallbackProvider == null ? void 0 : fallbackProvider.imageModel) {
8661
8662
  return fallbackProvider.imageModel(modelId);
8662
8663
  }
8663
- throw new import_provider27.NoSuchModelError({ modelId, modelType: "imageModel" });
8664
+ throw new import_provider26.NoSuchModelError({ modelId, modelType: "imageModel" });
8664
8665
  },
8665
8666
  transcriptionModel(modelId) {
8666
8667
  if (transcriptionModels != null && modelId in transcriptionModels) {
@@ -8669,7 +8670,7 @@ function customProvider({
8669
8670
  if (fallbackProvider == null ? void 0 : fallbackProvider.transcriptionModel) {
8670
8671
  return fallbackProvider.transcriptionModel(modelId);
8671
8672
  }
8672
- throw new import_provider27.NoSuchModelError({ modelId, modelType: "transcriptionModel" });
8673
+ throw new import_provider26.NoSuchModelError({ modelId, modelType: "transcriptionModel" });
8673
8674
  },
8674
8675
  speechModel(modelId) {
8675
8676
  if (speechModels != null && modelId in speechModels) {
@@ -8678,19 +8679,19 @@ function customProvider({
8678
8679
  if (fallbackProvider == null ? void 0 : fallbackProvider.speechModel) {
8679
8680
  return fallbackProvider.speechModel(modelId);
8680
8681
  }
8681
- throw new import_provider27.NoSuchModelError({ modelId, modelType: "speechModel" });
8682
+ throw new import_provider26.NoSuchModelError({ modelId, modelType: "speechModel" });
8682
8683
  }
8683
8684
  };
8684
8685
  }
8685
8686
  var experimental_customProvider = customProvider;
8686
8687
 
8687
8688
  // src/registry/no-such-provider-error.ts
8688
- var import_provider28 = require("@ai-sdk/provider");
8689
+ var import_provider27 = require("@ai-sdk/provider");
8689
8690
  var name15 = "AI_NoSuchProviderError";
8690
8691
  var marker15 = `vercel.ai.error.${name15}`;
8691
8692
  var symbol15 = Symbol.for(marker15);
8692
8693
  var _a15;
8693
- var NoSuchProviderError = class extends import_provider28.NoSuchModelError {
8694
+ var NoSuchProviderError = class extends import_provider27.NoSuchModelError {
8694
8695
  constructor({
8695
8696
  modelId,
8696
8697
  modelType,
@@ -8704,13 +8705,13 @@ var NoSuchProviderError = class extends import_provider28.NoSuchModelError {
8704
8705
  this.availableProviders = availableProviders;
8705
8706
  }
8706
8707
  static isInstance(error) {
8707
- return import_provider28.AISDKError.hasMarker(error, marker15);
8708
+ return import_provider27.AISDKError.hasMarker(error, marker15);
8708
8709
  }
8709
8710
  };
8710
8711
  _a15 = symbol15;
8711
8712
 
8712
8713
  // src/registry/provider-registry.ts
8713
- var import_provider29 = require("@ai-sdk/provider");
8714
+ var import_provider28 = require("@ai-sdk/provider");
8714
8715
  function createProviderRegistry(providers, {
8715
8716
  separator = ":",
8716
8717
  languageModelMiddleware
@@ -8755,7 +8756,7 @@ var DefaultProviderRegistry = class {
8755
8756
  splitId(id, modelType) {
8756
8757
  const index = id.indexOf(this.separator);
8757
8758
  if (index === -1) {
8758
- throw new import_provider29.NoSuchModelError({
8759
+ throw new import_provider28.NoSuchModelError({
8759
8760
  modelId: id,
8760
8761
  modelType,
8761
8762
  message: `Invalid ${modelType} id for registry: ${id} (must be in the format "providerId${this.separator}modelId")`
@@ -8771,7 +8772,7 @@ var DefaultProviderRegistry = class {
8771
8772
  modelId
8772
8773
  );
8773
8774
  if (model == null) {
8774
- throw new import_provider29.NoSuchModelError({ modelId: id, modelType: "languageModel" });
8775
+ throw new import_provider28.NoSuchModelError({ modelId: id, modelType: "languageModel" });
8775
8776
  }
8776
8777
  if (this.languageModelMiddleware != null) {
8777
8778
  model = wrapLanguageModel({
@@ -8787,7 +8788,7 @@ var DefaultProviderRegistry = class {
8787
8788
  const provider = this.getProvider(providerId, "textEmbeddingModel");
8788
8789
  const model = (_a16 = provider.textEmbeddingModel) == null ? void 0 : _a16.call(provider, modelId);
8789
8790
  if (model == null) {
8790
- throw new import_provider29.NoSuchModelError({
8791
+ throw new import_provider28.NoSuchModelError({
8791
8792
  modelId: id,
8792
8793
  modelType: "textEmbeddingModel"
8793
8794
  });
@@ -8800,7 +8801,7 @@ var DefaultProviderRegistry = class {
8800
8801
  const provider = this.getProvider(providerId, "imageModel");
8801
8802
  const model = (_a16 = provider.imageModel) == null ? void 0 : _a16.call(provider, modelId);
8802
8803
  if (model == null) {
8803
- throw new import_provider29.NoSuchModelError({ modelId: id, modelType: "imageModel" });
8804
+ throw new import_provider28.NoSuchModelError({ modelId: id, modelType: "imageModel" });
8804
8805
  }
8805
8806
  return model;
8806
8807
  }
@@ -8810,7 +8811,7 @@ var DefaultProviderRegistry = class {
8810
8811
  const provider = this.getProvider(providerId, "transcriptionModel");
8811
8812
  const model = (_a16 = provider.transcriptionModel) == null ? void 0 : _a16.call(provider, modelId);
8812
8813
  if (model == null) {
8813
- throw new import_provider29.NoSuchModelError({
8814
+ throw new import_provider28.NoSuchModelError({
8814
8815
  modelId: id,
8815
8816
  modelType: "transcriptionModel"
8816
8817
  });
@@ -8823,7 +8824,7 @@ var DefaultProviderRegistry = class {
8823
8824
  const provider = this.getProvider(providerId, "speechModel");
8824
8825
  const model = (_a16 = provider.speechModel) == null ? void 0 : _a16.call(provider, modelId);
8825
8826
  if (model == null) {
8826
- throw new import_provider29.NoSuchModelError({ modelId: id, modelType: "speechModel" });
8827
+ throw new import_provider28.NoSuchModelError({ modelId: id, modelType: "speechModel" });
8827
8828
  }
8828
8829
  return model;
8829
8830
  }
@@ -8833,8 +8834,8 @@ var DefaultProviderRegistry = class {
8833
8834
  var import_provider_utils27 = require("@ai-sdk/provider-utils");
8834
8835
 
8835
8836
  // src/error/no-transcript-generated-error.ts
8836
- var import_provider30 = require("@ai-sdk/provider");
8837
- var NoTranscriptGeneratedError = class extends import_provider30.AISDKError {
8837
+ var import_provider29 = require("@ai-sdk/provider");
8838
+ var NoTranscriptGeneratedError = class extends import_provider29.AISDKError {
8838
8839
  constructor(options) {
8839
8840
  super({
8840
8841
  name: "AI_NoTranscriptGeneratedError",
@@ -9612,7 +9613,7 @@ var TextStreamChatTransport = class extends HttpChatTransport {
9612
9613
  };
9613
9614
 
9614
9615
  // src/ui/validate-ui-messages.ts
9615
- var import_provider31 = require("@ai-sdk/provider");
9616
+ var import_provider30 = require("@ai-sdk/provider");
9616
9617
  var import_provider_utils32 = require("@ai-sdk/provider-utils");
9617
9618
  var import_v48 = require("zod/v4");
9618
9619
  var uiMessagesSchema = (0, import_provider_utils32.lazyValidator)(
@@ -9853,7 +9854,7 @@ async function safeValidateUIMessages({
9853
9854
  if (!dataSchema) {
9854
9855
  return {
9855
9856
  success: false,
9856
- error: new import_provider31.TypeValidationError({
9857
+ error: new import_provider30.TypeValidationError({
9857
9858
  value: dataPart.data,
9858
9859
  cause: `No data schema found for data part ${dataName}`
9859
9860
  })
@@ -9877,7 +9878,7 @@ async function safeValidateUIMessages({
9877
9878
  if (!tool2) {
9878
9879
  return {
9879
9880
  success: false,
9880
- error: new import_provider31.TypeValidationError({
9881
+ error: new import_provider30.TypeValidationError({
9881
9882
  value: toolPart.input,
9882
9883
  cause: `No tool schema found for tool part ${toolName}`
9883
9884
  })
@@ -9931,7 +9932,8 @@ async function validateUIMessages({
9931
9932
  var import_provider_utils33 = require("@ai-sdk/provider-utils");
9932
9933
  function createUIMessageStream({
9933
9934
  execute,
9934
- onError = import_provider_utils33.getErrorMessage,
9935
+ onError = () => "An error occurred.",
9936
+ // prevent leaking server error details to the client by default
9935
9937
  originalMessages,
9936
9938
  onFinish,
9937
9939
  generateId: generateId3 = import_provider_utils33.generateId