@ai-sdk/anthropic 4.0.51 → 4.0.53
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 +23 -0
- package/dist/index.d.ts +19 -2
- package/dist/index.js +98 -19
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -1
- package/dist/internal/index.js +19 -2
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +11 -4
- package/package.json +3 -3
- package/src/anthropic-api.ts +15 -0
- package/src/anthropic-batch.ts +98 -16
- package/src/anthropic-language-model-options.ts +2 -2
- package/src/anthropic-language-model.ts +15 -0
- package/src/anthropic-message-metadata.ts +12 -0
package/dist/internal/index.d.ts
CHANGED
|
@@ -730,6 +730,11 @@ declare const anthropicResponseSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
730
730
|
explanation?: string | null | undefined;
|
|
731
731
|
recommended_model?: string | null | undefined;
|
|
732
732
|
} | null | undefined;
|
|
733
|
+
input_transformations?: {
|
|
734
|
+
type: string;
|
|
735
|
+
path: string;
|
|
736
|
+
reason: string;
|
|
737
|
+
}[] | null | undefined;
|
|
733
738
|
container?: {
|
|
734
739
|
expires_at: string;
|
|
735
740
|
id: string;
|
|
@@ -887,7 +892,7 @@ declare class AnthropicLanguageModel implements LanguageModelV4 {
|
|
|
887
892
|
} | undefined;
|
|
888
893
|
thinking?: {
|
|
889
894
|
block_binding?: {
|
|
890
|
-
prefix_mismatch_behavior: "drop_block";
|
|
895
|
+
prefix_mismatch_behavior: "error" | "drop_block";
|
|
891
896
|
} | undefined;
|
|
892
897
|
display?: "omitted" | "summarized" | "updates" | undefined;
|
|
893
898
|
budget_tokens?: number | undefined;
|
package/dist/internal/index.js
CHANGED
|
@@ -214,6 +214,11 @@ var anthropicMcpToolResultContentSchema = z3.union([
|
|
|
214
214
|
])
|
|
215
215
|
)
|
|
216
216
|
]);
|
|
217
|
+
var anthropicInputTransformationSchema = z3.object({
|
|
218
|
+
type: z3.string(),
|
|
219
|
+
path: z3.string(),
|
|
220
|
+
reason: z3.string()
|
|
221
|
+
});
|
|
217
222
|
var anthropicResponseSchema = lazySchema3(
|
|
218
223
|
() => zodSchema3(
|
|
219
224
|
z3.object({
|
|
@@ -468,6 +473,7 @@ var anthropicResponseSchema = lazySchema3(
|
|
|
468
473
|
stop_reason: z3.string().nullish(),
|
|
469
474
|
stop_sequence: z3.string().nullish(),
|
|
470
475
|
stop_details: anthropicStopDetailsSchema.nullish(),
|
|
476
|
+
input_transformations: z3.array(anthropicInputTransformationSchema).nullish(),
|
|
471
477
|
usage: z3.looseObject({
|
|
472
478
|
input_tokens: z3.number(),
|
|
473
479
|
output_tokens: z3.number(),
|
|
@@ -552,6 +558,7 @@ var anthropicChunkSchema = lazySchema3(
|
|
|
552
558
|
])
|
|
553
559
|
).nullish(),
|
|
554
560
|
stop_reason: z3.string().nullish(),
|
|
561
|
+
input_transformations: z3.array(anthropicInputTransformationSchema).nullish(),
|
|
555
562
|
container: z3.object({
|
|
556
563
|
expires_at: z3.string(),
|
|
557
564
|
id: z3.string()
|
|
@@ -889,6 +896,7 @@ var anthropicChunkSchema = lazySchema3(
|
|
|
889
896
|
})
|
|
890
897
|
).nullish()
|
|
891
898
|
}),
|
|
899
|
+
input_transformations: z3.array(anthropicInputTransformationSchema).nullish(),
|
|
892
900
|
context_management: z3.object({
|
|
893
901
|
applied_edits: z3.array(
|
|
894
902
|
z3.union([
|
|
@@ -1037,7 +1045,7 @@ var anthropicLanguageModelOptions = z4.object({
|
|
|
1037
1045
|
* prefix. Requires the `thinking-binding-controls-2026-08-01` beta.
|
|
1038
1046
|
*/
|
|
1039
1047
|
blockBinding: z4.object({
|
|
1040
|
-
prefixMismatchBehavior: z4.
|
|
1048
|
+
prefixMismatchBehavior: z4.enum(["error", "drop_block"])
|
|
1041
1049
|
}).optional()
|
|
1042
1050
|
}),
|
|
1043
1051
|
z4.object({
|
|
@@ -1052,7 +1060,7 @@ var anthropicLanguageModelOptions = z4.object({
|
|
|
1052
1060
|
z4.object({
|
|
1053
1061
|
type: z4.never().optional(),
|
|
1054
1062
|
blockBinding: z4.object({
|
|
1055
|
-
prefixMismatchBehavior: z4.
|
|
1063
|
+
prefixMismatchBehavior: z4.enum(["error", "drop_block"])
|
|
1056
1064
|
})
|
|
1057
1065
|
})
|
|
1058
1066
|
]).optional(),
|
|
@@ -4808,6 +4816,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
4808
4816
|
usage: response.usage,
|
|
4809
4817
|
stopSequence: (_a2 = response.stop_sequence) != null ? _a2 : null,
|
|
4810
4818
|
...stopDetails != null ? { stopDetails } : {},
|
|
4819
|
+
...response.input_transformations != null ? { inputTransformations: response.input_transformations } : {},
|
|
4811
4820
|
iterations: response.usage.iterations ? response.usage.iterations.map(
|
|
4812
4821
|
(iter) => ({
|
|
4813
4822
|
type: iter.type,
|
|
@@ -4895,6 +4904,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
4895
4904
|
let rawUsage = void 0;
|
|
4896
4905
|
let stopSequence = null;
|
|
4897
4906
|
let stopDetails = void 0;
|
|
4907
|
+
let inputTransformations;
|
|
4898
4908
|
let container = null;
|
|
4899
4909
|
let isJsonResponseFromTool = false;
|
|
4900
4910
|
let isMessageOpen = false;
|
|
@@ -5564,6 +5574,9 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
5564
5574
|
rawUsage = {
|
|
5565
5575
|
...value.message.usage
|
|
5566
5576
|
};
|
|
5577
|
+
if (value.message.input_transformations != null) {
|
|
5578
|
+
inputTransformations = value.message.input_transformations;
|
|
5579
|
+
}
|
|
5567
5580
|
if (value.message.container != null) {
|
|
5568
5581
|
container = {
|
|
5569
5582
|
expiresAt: value.message.container.expires_at,
|
|
@@ -5663,6 +5676,9 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
5663
5676
|
value.context_management
|
|
5664
5677
|
);
|
|
5665
5678
|
}
|
|
5679
|
+
if (value.input_transformations != null) {
|
|
5680
|
+
inputTransformations = value.input_transformations;
|
|
5681
|
+
}
|
|
5666
5682
|
rawUsage = {
|
|
5667
5683
|
...rawUsage,
|
|
5668
5684
|
...value.usage
|
|
@@ -5676,6 +5692,7 @@ var AnthropicLanguageModel = class _AnthropicLanguageModel {
|
|
|
5676
5692
|
usage: rawUsage != null ? rawUsage : null,
|
|
5677
5693
|
stopSequence,
|
|
5678
5694
|
...stopDetails != null ? { stopDetails } : {},
|
|
5695
|
+
...inputTransformations != null ? { inputTransformations } : {},
|
|
5679
5696
|
iterations: usage.iterations ? usage.iterations.map(
|
|
5680
5697
|
(iter) => ({
|
|
5681
5698
|
type: iter.type,
|