@ai-sdk/anthropic 3.0.134 → 3.0.135

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/anthropic",
3
- "version": "3.0.134",
3
+ "version": "3.0.135",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@ai-sdk/provider": "3.0.19",
40
- "@ai-sdk/provider-utils": "4.0.61"
40
+ "@ai-sdk/provider-utils": "4.0.62"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -649,55 +649,61 @@ export type AnthropicResponseContextManagement = {
649
649
  applied_edits: AnthropicResponseContextManagementEdit[];
650
650
  };
651
651
 
652
- const anthropicStopDetailsSchema = z.object({
653
- type: z.string(),
654
- category: z.string().nullish(),
655
- explanation: z.string().nullish(),
656
- recommended_model: z.string().nullish(),
657
- });
652
+ const anthropicStopDetailsSchema = () =>
653
+ z.object({
654
+ type: z.string(),
655
+ category: z.string().nullish(),
656
+ explanation: z.string().nullish(),
657
+ recommended_model: z.string().nullish(),
658
+ });
658
659
 
659
- export type AnthropicStopDetails = z.infer<typeof anthropicStopDetailsSchema>;
660
+ export type AnthropicStopDetails = z.infer<
661
+ ReturnType<typeof anthropicStopDetailsSchema>
662
+ >;
660
663
 
661
- const anthropicSafeguardResultSchema = z.object({
662
- type: z.string(),
663
- status: z.object({
664
+ const anthropicSafeguardResultSchema = () =>
665
+ z.object({
664
666
  type: z.string(),
665
- tool_uses: z
666
- .record(
667
- z.string(),
668
- z.object({
669
- type: z.string(),
670
- outcome: z.string().nullish(),
671
- explanation: z.string().nullish(),
672
- }),
673
- )
674
- .nullish(),
675
- }),
676
- });
667
+ status: z.object({
668
+ type: z.string(),
669
+ tool_uses: z
670
+ .record(
671
+ z.string(),
672
+ z.object({
673
+ type: z.string(),
674
+ outcome: z.string().nullish(),
675
+ explanation: z.string().nullish(),
676
+ }),
677
+ )
678
+ .nullish(),
679
+ }),
680
+ });
677
681
 
678
682
  export type AnthropicSafeguardResult = z.infer<
679
- typeof anthropicSafeguardResultSchema
683
+ ReturnType<typeof anthropicSafeguardResultSchema>
680
684
  >;
681
685
 
682
- const anthropicToolCallCallerSchema = z.union([
683
- z.object({
684
- type: z.literal('code_execution_20250825'),
685
- tool_id: z.string(),
686
- }),
687
- z.object({
688
- type: z.literal('code_execution_20260120'),
689
- tool_id: z.string(),
690
- }),
691
- z.object({
692
- type: z.literal('direct'),
693
- }),
694
- ]);
686
+ const anthropicToolCallCallerSchema = () =>
687
+ z.union([
688
+ z.object({
689
+ type: z.literal('code_execution_20250825'),
690
+ tool_id: z.string(),
691
+ }),
692
+ z.object({
693
+ type: z.literal('code_execution_20260120'),
694
+ tool_id: z.string(),
695
+ }),
696
+ z.object({
697
+ type: z.literal('direct'),
698
+ }),
699
+ ]);
695
700
 
696
- const anthropicInputTransformationSchema = z.object({
697
- type: z.string(),
698
- path: z.string(),
699
- reason: z.string(),
700
- });
701
+ const anthropicInputTransformationSchema = () =>
702
+ z.object({
703
+ type: z.string(),
704
+ path: z.string(),
705
+ reason: z.string(),
706
+ });
701
707
 
702
708
  // limited version of the schema, focussed on what is needed for the implementation
703
709
  // this approach limits breakages when the API changes and increases efficiency
@@ -761,7 +767,7 @@ export const anthropicMessagesResponseSchema = lazySchema(() =>
761
767
  name: z.string(),
762
768
  input: z.unknown(),
763
769
  // Programmatic tool calling: caller info when triggered from code execution
764
- caller: anthropicToolCallCallerSchema.optional(),
770
+ caller: anthropicToolCallCallerSchema().optional(),
765
771
  // Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
766
772
  toolset_name: z.string().nullish(),
767
773
  }),
@@ -770,7 +776,7 @@ export const anthropicMessagesResponseSchema = lazySchema(() =>
770
776
  id: z.string(),
771
777
  name: z.string(),
772
778
  input: z.record(z.string(), z.unknown()).nullish(),
773
- caller: anthropicToolCallCallerSchema.optional(),
779
+ caller: anthropicToolCallCallerSchema().optional(),
774
780
  }),
775
781
  z.object({
776
782
  type: z.literal('mcp_tool_use'),
@@ -793,7 +799,7 @@ export const anthropicMessagesResponseSchema = lazySchema(() =>
793
799
  z.object({
794
800
  type: z.literal('web_fetch_tool_result'),
795
801
  tool_use_id: z.string(),
796
- caller: anthropicToolCallCallerSchema.optional(),
802
+ caller: anthropicToolCallCallerSchema().optional(),
797
803
  content: z.union([
798
804
  z.object({
799
805
  type: z.literal('web_fetch_result'),
@@ -826,7 +832,7 @@ export const anthropicMessagesResponseSchema = lazySchema(() =>
826
832
  z.object({
827
833
  type: z.literal('web_search_tool_result'),
828
834
  tool_use_id: z.string(),
829
- caller: anthropicToolCallCallerSchema.optional(),
835
+ caller: anthropicToolCallCallerSchema().optional(),
830
836
  content: z.union([
831
837
  z.array(
832
838
  z.object({
@@ -989,11 +995,11 @@ export const anthropicMessagesResponseSchema = lazySchema(() =>
989
995
  ),
990
996
  stop_reason: z.string().nullish(),
991
997
  stop_sequence: z.string().nullish(),
992
- stop_details: anthropicStopDetailsSchema.nullish(),
998
+ stop_details: anthropicStopDetailsSchema().nullish(),
993
999
  input_transformations: z
994
- .array(anthropicInputTransformationSchema)
1000
+ .array(anthropicInputTransformationSchema())
995
1001
  .nullish(),
996
- safeguard_results: z.array(anthropicSafeguardResultSchema).nullish(),
1002
+ safeguard_results: z.array(anthropicSafeguardResultSchema()).nullish(),
997
1003
  usage: z.looseObject({
998
1004
  input_tokens: z.number(),
999
1005
  output_tokens: z.number(),
@@ -1087,7 +1093,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1087
1093
  id: z.string(),
1088
1094
  name: z.string(),
1089
1095
  input: z.unknown(),
1090
- caller: anthropicToolCallCallerSchema.optional(),
1096
+ caller: anthropicToolCallCallerSchema().optional(),
1091
1097
  toolset_name: z.string().nullish(),
1092
1098
  }),
1093
1099
  ]),
@@ -1095,7 +1101,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1095
1101
  .nullish(),
1096
1102
  stop_reason: z.string().nullish(),
1097
1103
  input_transformations: z
1098
- .array(anthropicInputTransformationSchema)
1104
+ .array(anthropicInputTransformationSchema())
1099
1105
  .nullish(),
1100
1106
  container: z
1101
1107
  .object({
@@ -1124,7 +1130,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1124
1130
  // Programmatic tool calling: input may be present directly for deferred tool calls
1125
1131
  input: z.record(z.string(), z.unknown()).optional(),
1126
1132
  // Programmatic tool calling: caller info when triggered from code execution
1127
- caller: anthropicToolCallCallerSchema.optional(),
1133
+ caller: anthropicToolCallCallerSchema().optional(),
1128
1134
  // Toolsets (e.g. computer toolset): name of the toolset this member call belongs to
1129
1135
  toolset_name: z.string().nullish(),
1130
1136
  }),
@@ -1141,7 +1147,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1141
1147
  id: z.string(),
1142
1148
  name: z.string(),
1143
1149
  input: z.record(z.string(), z.unknown()).nullish(),
1144
- caller: anthropicToolCallCallerSchema.optional(),
1150
+ caller: anthropicToolCallCallerSchema().optional(),
1145
1151
  }),
1146
1152
  z.object({
1147
1153
  type: z.literal('mcp_tool_use'),
@@ -1164,7 +1170,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1164
1170
  z.object({
1165
1171
  type: z.literal('web_fetch_tool_result'),
1166
1172
  tool_use_id: z.string(),
1167
- caller: anthropicToolCallCallerSchema.optional(),
1173
+ caller: anthropicToolCallCallerSchema().optional(),
1168
1174
  content: z.union([
1169
1175
  z.object({
1170
1176
  type: z.literal('web_fetch_result'),
@@ -1197,7 +1203,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1197
1203
  z.object({
1198
1204
  type: z.literal('web_search_tool_result'),
1199
1205
  tool_use_id: z.string(),
1200
- caller: anthropicToolCallCallerSchema.optional(),
1206
+ caller: anthropicToolCallCallerSchema().optional(),
1201
1207
  content: z.union([
1202
1208
  z.array(
1203
1209
  z.object({
@@ -1427,8 +1433,10 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1427
1433
  delta: z.object({
1428
1434
  stop_reason: z.string().nullish(),
1429
1435
  stop_sequence: z.string().nullish(),
1430
- stop_details: anthropicStopDetailsSchema.nullish(),
1431
- safeguard_results: z.array(anthropicSafeguardResultSchema).nullish(),
1436
+ stop_details: anthropicStopDetailsSchema().nullish(),
1437
+ safeguard_results: z
1438
+ .array(anthropicSafeguardResultSchema())
1439
+ .nullish(),
1432
1440
  container: z
1433
1441
  .object({
1434
1442
  expires_at: z.string(),
@@ -1477,7 +1485,7 @@ export const anthropicMessagesChunkSchema = lazySchema(() =>
1477
1485
  .nullish(),
1478
1486
  }),
1479
1487
  input_transformations: z
1480
- .array(anthropicInputTransformationSchema)
1488
+ .array(anthropicInputTransformationSchema())
1481
1489
  .nullish(),
1482
1490
  context_management: z
1483
1491
  .object({