@ai-sdk/provider-utils 5.0.0-beta.5 → 5.0.0-beta.7

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.mjs CHANGED
@@ -294,10 +294,13 @@ function validateDownloadUrl(url) {
294
294
  message: `Invalid URL: ${url}`
295
295
  });
296
296
  }
297
+ if (parsed.protocol === "data:") {
298
+ return;
299
+ }
297
300
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
298
301
  throw new DownloadError({
299
302
  url,
300
- message: `URL scheme must be http or https, got ${parsed.protocol}`
303
+ message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
301
304
  });
302
305
  }
303
306
  const hostname = parsed.hostname;
@@ -574,7 +577,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
574
577
  }
575
578
 
576
579
  // src/version.ts
577
- var VERSION = true ? "5.0.0-beta.5" : "0.0.0-test";
580
+ var VERSION = true ? "5.0.0-beta.7" : "0.0.0-test";
578
581
 
579
582
  // src/get-from-api.ts
580
583
  var getOriginalFetch = () => globalThis.fetch;
@@ -739,6 +742,63 @@ function loadApiKey({
739
742
  return apiKey;
740
743
  }
741
744
 
745
+ // src/map-reasoning-to-provider.ts
746
+ function isCustomReasoning(reasoning) {
747
+ return reasoning !== void 0 && reasoning !== "provider-default";
748
+ }
749
+ function mapReasoningToProviderEffort({
750
+ reasoning,
751
+ effortMap,
752
+ warnings
753
+ }) {
754
+ const mapped = effortMap[reasoning];
755
+ if (mapped == null) {
756
+ warnings.push({
757
+ type: "unsupported",
758
+ feature: "reasoning",
759
+ details: `reasoning "${reasoning}" is not supported by this model.`
760
+ });
761
+ return void 0;
762
+ }
763
+ if (mapped !== reasoning) {
764
+ warnings.push({
765
+ type: "compatibility",
766
+ feature: "reasoning",
767
+ details: `reasoning "${reasoning}" is not directly supported by this model. mapped to effort "${mapped}".`
768
+ });
769
+ }
770
+ return mapped;
771
+ }
772
+ var DEFAULT_REASONING_BUDGET_PERCENTAGES = {
773
+ minimal: 0.02,
774
+ low: 0.1,
775
+ medium: 0.3,
776
+ high: 0.6,
777
+ xhigh: 0.9
778
+ };
779
+ function mapReasoningToProviderBudget({
780
+ reasoning,
781
+ maxOutputTokens,
782
+ maxReasoningBudget,
783
+ minReasoningBudget = 1024,
784
+ budgetPercentages = DEFAULT_REASONING_BUDGET_PERCENTAGES,
785
+ warnings
786
+ }) {
787
+ const pct = budgetPercentages[reasoning];
788
+ if (pct == null) {
789
+ warnings.push({
790
+ type: "unsupported",
791
+ feature: "reasoning",
792
+ details: `reasoning "${reasoning}" is not supported by this model.`
793
+ });
794
+ return void 0;
795
+ }
796
+ return Math.min(
797
+ maxReasoningBudget,
798
+ Math.max(minReasoningBudget, Math.round(maxOutputTokens * pct))
799
+ );
800
+ }
801
+
742
802
  // src/load-optional-setting.ts
743
803
  function loadOptionalSetting({
744
804
  settingValue,
@@ -2722,6 +2782,7 @@ export {
2722
2782
  getRuntimeEnvironmentUserAgent,
2723
2783
  injectJsonInstructionIntoMessages,
2724
2784
  isAbortError,
2785
+ isCustomReasoning,
2725
2786
  isNonNullable,
2726
2787
  isParsableJson,
2727
2788
  isUrlSupported,
@@ -2730,6 +2791,8 @@ export {
2730
2791
  loadApiKey,
2731
2792
  loadOptionalSetting,
2732
2793
  loadSetting,
2794
+ mapReasoningToProviderBudget,
2795
+ mapReasoningToProviderEffort,
2733
2796
  mediaTypeToExtension,
2734
2797
  normalizeHeaders,
2735
2798
  parseJSON,