@fairyhunter13/ai-anthropic 3.0.58-fork.11 → 3.0.58-fork.12

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.js CHANGED
@@ -2845,6 +2845,58 @@ function mapAnthropicStopReason({
2845
2845
  }
2846
2846
 
2847
2847
  // src/anthropic-messages-language-model.ts
2848
+ function isCustomReasoning(reasoning) {
2849
+ return reasoning !== void 0 && reasoning !== "provider-default";
2850
+ }
2851
+ function mapReasoningToProviderEffort({
2852
+ reasoning,
2853
+ effortMap,
2854
+ warnings
2855
+ }) {
2856
+ const mapped = effortMap[reasoning];
2857
+ if (mapped == null) {
2858
+ warnings.push({
2859
+ type: "unsupported",
2860
+ feature: "reasoning",
2861
+ details: `reasoning "${reasoning}" is not supported by this model.`
2862
+ });
2863
+ return void 0;
2864
+ }
2865
+ if (mapped !== reasoning) {
2866
+ warnings.push({
2867
+ type: "compatibility",
2868
+ feature: "reasoning",
2869
+ details: `reasoning "${reasoning}" is not directly supported by this model. mapped to effort "${mapped}".`
2870
+ });
2871
+ }
2872
+ return mapped;
2873
+ }
2874
+ var DEFAULT_REASONING_BUDGET_PERCENTAGES = {
2875
+ minimal: 0.02,
2876
+ low: 0.1,
2877
+ medium: 0.3,
2878
+ high: 0.6,
2879
+ xhigh: 0.9
2880
+ };
2881
+ function mapReasoningToProviderBudget({
2882
+ reasoning,
2883
+ maxOutputTokens,
2884
+ maxReasoningBudget,
2885
+ minReasoningBudget = 1024,
2886
+ budgetPercentages = DEFAULT_REASONING_BUDGET_PERCENTAGES,
2887
+ warnings
2888
+ }) {
2889
+ const pct = budgetPercentages[reasoning];
2890
+ if (pct == null) {
2891
+ warnings.push({
2892
+ type: "unsupported",
2893
+ feature: "reasoning",
2894
+ details: `reasoning "${reasoning}" is not supported by this model.`
2895
+ });
2896
+ return void 0;
2897
+ }
2898
+ return Math.min(maxReasoningBudget, Math.max(minReasoningBudget, Math.round(maxOutputTokens * pct)));
2899
+ }
2848
2900
  function createCitationSource(citation, citationDocuments, generateId3) {
2849
2901
  var _a;
2850
2902
  if (citation.type === "web_search_result_location") {
@@ -3030,7 +3082,7 @@ var AnthropicMessagesLanguageModel = class {
3030
3082
  cacheControlValidator,
3031
3083
  toolNameMapping
3032
3084
  });
3033
- if ((0, import_provider_utils15.isCustomReasoning)(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3085
+ if (isCustomReasoning(reasoning) && (anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null && (anthropicOptions == null ? void 0 : anthropicOptions.effort) == null) {
3034
3086
  const reasoningConfig = resolveAnthropicReasoningConfig({
3035
3087
  reasoning,
3036
3088
  supportsAdaptiveThinking,
@@ -4663,14 +4715,14 @@ function resolveAnthropicReasoningConfig({
4663
4715
  maxOutputTokensForModel,
4664
4716
  warnings
4665
4717
  }) {
4666
- if (!(0, import_provider_utils15.isCustomReasoning)(reasoning)) {
4718
+ if (!isCustomReasoning(reasoning)) {
4667
4719
  return void 0;
4668
4720
  }
4669
4721
  if (reasoning === "none") {
4670
4722
  return { thinking: { type: "disabled" } };
4671
4723
  }
4672
4724
  if (supportsAdaptiveThinking) {
4673
- const effort = (0, import_provider_utils15.mapReasoningToProviderEffort)({
4725
+ const effort = mapReasoningToProviderEffort({
4674
4726
  reasoning,
4675
4727
  effortMap: {
4676
4728
  minimal: "low",
@@ -4683,7 +4735,7 @@ function resolveAnthropicReasoningConfig({
4683
4735
  });
4684
4736
  return { thinking: { type: "adaptive" }, effort };
4685
4737
  }
4686
- const budgetTokens = (0, import_provider_utils15.mapReasoningToProviderBudget)({
4738
+ const budgetTokens = mapReasoningToProviderBudget({
4687
4739
  reasoning,
4688
4740
  maxOutputTokens: maxOutputTokensForModel,
4689
4741
  maxReasoningBudget: maxOutputTokensForModel,