@ai-sdk/anthropic 3.0.116 → 3.0.118

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,19 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.118
4
+
5
+ ### Patch Changes
6
+
7
+ - c11f450: feat(anthropic): expand preserved thinking support to cover `prefix_mismatch_behavior: 'error'`
8
+
9
+ ## 3.0.117
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [1a4dbb1]
14
+ - @ai-sdk/provider@3.0.16
15
+ - @ai-sdk/provider-utils@4.0.51
16
+
3
17
  ## 3.0.116
4
18
 
5
19
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -47,6 +47,17 @@ interface AnthropicMessageMetadata {
47
47
  usage: JSONObject;
48
48
  cacheCreationInputTokens: number | null;
49
49
  stopSequence: string | null;
50
+ /**
51
+ * Input blocks that Anthropic transformed before inference. This is
52
+ * populated when thinking binding controls drop a mismatched thinking block.
53
+ * Values are intentionally open-ended so new transformation types and
54
+ * reasons remain forward compatible.
55
+ */
56
+ inputTransformations?: Array<{
57
+ type: string;
58
+ path: string;
59
+ reason: string;
60
+ }>;
50
61
  /**
51
62
  * Details about why the request stopped. Present only when the API returns
52
63
  * a `refusal` stop reason together with a `stop_details` object (a
@@ -221,7 +232,10 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
221
232
  updates: "updates";
222
233
  }>>;
223
234
  blockBinding: z.ZodOptional<z.ZodObject<{
224
- prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
235
+ prefixMismatchBehavior: z.ZodEnum<{
236
+ error: "error";
237
+ drop_block: "drop_block";
238
+ }>;
225
239
  }, z.core.$strip>>;
226
240
  }, z.core.$strip>, z.ZodObject<{
227
241
  type: z.ZodLiteral<"enabled">;
@@ -230,7 +244,10 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
230
244
  type: z.ZodLiteral<"disabled">;
231
245
  }, z.core.$strip>]>, z.ZodObject<{
232
246
  blockBinding: z.ZodObject<{
233
- prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
247
+ prefixMismatchBehavior: z.ZodEnum<{
248
+ error: "error";
249
+ drop_block: "drop_block";
250
+ }>;
234
251
  }, z.core.$strip>;
235
252
  }, z.core.$strip>]>>;
236
253
  disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
package/dist/index.d.ts CHANGED
@@ -47,6 +47,17 @@ interface AnthropicMessageMetadata {
47
47
  usage: JSONObject;
48
48
  cacheCreationInputTokens: number | null;
49
49
  stopSequence: string | null;
50
+ /**
51
+ * Input blocks that Anthropic transformed before inference. This is
52
+ * populated when thinking binding controls drop a mismatched thinking block.
53
+ * Values are intentionally open-ended so new transformation types and
54
+ * reasons remain forward compatible.
55
+ */
56
+ inputTransformations?: Array<{
57
+ type: string;
58
+ path: string;
59
+ reason: string;
60
+ }>;
50
61
  /**
51
62
  * Details about why the request stopped. Present only when the API returns
52
63
  * a `refusal` stop reason together with a `stop_details` object (a
@@ -221,7 +232,10 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
221
232
  updates: "updates";
222
233
  }>>;
223
234
  blockBinding: z.ZodOptional<z.ZodObject<{
224
- prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
235
+ prefixMismatchBehavior: z.ZodEnum<{
236
+ error: "error";
237
+ drop_block: "drop_block";
238
+ }>;
225
239
  }, z.core.$strip>>;
226
240
  }, z.core.$strip>, z.ZodObject<{
227
241
  type: z.ZodLiteral<"enabled">;
@@ -230,7 +244,10 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
230
244
  type: z.ZodLiteral<"disabled">;
231
245
  }, z.core.$strip>]>, z.ZodObject<{
232
246
  blockBinding: z.ZodObject<{
233
- prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
247
+ prefixMismatchBehavior: z.ZodEnum<{
248
+ error: "error";
249
+ drop_block: "drop_block";
250
+ }>;
234
251
  }, z.core.$strip>;
235
252
  }, z.core.$strip>]>>;
236
253
  disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
package/dist/index.js CHANGED
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
32
32
  var import_provider_utils26 = require("@ai-sdk/provider-utils");
33
33
 
34
34
  // src/version.ts
35
- var VERSION = true ? "3.0.116" : "0.0.0-test";
35
+ var VERSION = true ? "3.0.118" : "0.0.0-test";
36
36
 
37
37
  // src/anthropic-messages-language-model.ts
38
38
  var import_provider3 = require("@ai-sdk/provider");
@@ -79,6 +79,11 @@ var anthropicToolCallCallerSchema = import_v42.z.union([
79
79
  type: import_v42.z.literal("direct")
80
80
  })
81
81
  ]);
82
+ var anthropicInputTransformationSchema = import_v42.z.object({
83
+ type: import_v42.z.string(),
84
+ path: import_v42.z.string(),
85
+ reason: import_v42.z.string()
86
+ });
82
87
  var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
83
88
  () => (0, import_provider_utils2.zodSchema)(
84
89
  import_v42.z.object({
@@ -358,6 +363,7 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
358
363
  stop_reason: import_v42.z.string().nullish(),
359
364
  stop_sequence: import_v42.z.string().nullish(),
360
365
  stop_details: anthropicStopDetailsSchema.nullish(),
366
+ input_transformations: import_v42.z.array(anthropicInputTransformationSchema).nullish(),
361
367
  usage: import_v42.z.looseObject({
362
368
  input_tokens: import_v42.z.number(),
363
369
  output_tokens: import_v42.z.number(),
@@ -442,6 +448,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
442
448
  ])
443
449
  ).nullish(),
444
450
  stop_reason: import_v42.z.string().nullish(),
451
+ input_transformations: import_v42.z.array(anthropicInputTransformationSchema).nullish(),
445
452
  container: import_v42.z.object({
446
453
  expires_at: import_v42.z.string(),
447
454
  id: import_v42.z.string()
@@ -802,6 +809,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
802
809
  })
803
810
  ).nullish()
804
811
  }),
812
+ input_transformations: import_v42.z.array(anthropicInputTransformationSchema).nullish(),
805
813
  context_management: import_v42.z.object({
806
814
  applied_edits: import_v42.z.array(
807
815
  import_v42.z.union([
@@ -909,7 +917,7 @@ var anthropicSystemMessageProviderOptions = import_v43.z.object({
909
917
  ).optional()
910
918
  });
911
919
  var anthropicThinkingBlockBinding = import_v43.z.object({
912
- prefixMismatchBehavior: import_v43.z.literal("drop_block")
920
+ prefixMismatchBehavior: import_v43.z.enum(["error", "drop_block"])
913
921
  });
914
922
  var anthropicLanguageModelOptions = import_v43.z.object({
915
923
  /**
@@ -4438,6 +4446,7 @@ var AnthropicMessagesLanguageModel = class {
4438
4446
  cacheCreationInputTokens: (_a2 = response.usage.cache_creation_input_tokens) != null ? _a2 : null,
4439
4447
  stopSequence: (_b2 = response.stop_sequence) != null ? _b2 : null,
4440
4448
  ...stopDetails != null ? { stopDetails } : {},
4449
+ ...response.input_transformations != null ? { inputTransformations: response.input_transformations } : {},
4441
4450
  iterations: response.usage.iterations ? response.usage.iterations.map(
4442
4451
  (iter) => ({
4443
4452
  type: iter.type,
@@ -4527,6 +4536,7 @@ var AnthropicMessagesLanguageModel = class {
4527
4536
  let cacheCreationInputTokens = null;
4528
4537
  let stopSequence = null;
4529
4538
  let stopDetails = void 0;
4539
+ let inputTransformations;
4530
4540
  let container = null;
4531
4541
  let isJsonResponseFromTool = false;
4532
4542
  let isMessageOpen = false;
@@ -5191,6 +5201,9 @@ var AnthropicMessagesLanguageModel = class {
5191
5201
  ...value.message.usage
5192
5202
  };
5193
5203
  cacheCreationInputTokens = (_g = value.message.usage.cache_creation_input_tokens) != null ? _g : null;
5204
+ if (value.message.input_transformations != null) {
5205
+ inputTransformations = value.message.input_transformations;
5206
+ }
5194
5207
  if (value.message.container != null) {
5195
5208
  container = {
5196
5209
  expiresAt: value.message.container.expires_at,
@@ -5291,6 +5304,9 @@ var AnthropicMessagesLanguageModel = class {
5291
5304
  value.context_management
5292
5305
  );
5293
5306
  }
5307
+ if (value.input_transformations != null) {
5308
+ inputTransformations = value.input_transformations;
5309
+ }
5294
5310
  rawUsage = {
5295
5311
  ...rawUsage,
5296
5312
  ...value.usage
@@ -5305,6 +5321,7 @@ var AnthropicMessagesLanguageModel = class {
5305
5321
  cacheCreationInputTokens,
5306
5322
  stopSequence,
5307
5323
  ...stopDetails != null ? { stopDetails } : {},
5324
+ ...inputTransformations != null ? { inputTransformations } : {},
5308
5325
  iterations: usage.iterations ? usage.iterations.map(
5309
5326
  (iter) => ({
5310
5327
  type: iter.type,