@ai-sdk/anthropic 2.0.100 → 2.0.101
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 +6 -0
- package/dist/index.d.mts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +103 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +103 -35
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +102 -34
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +102 -34
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -169,11 +169,19 @@ interface AnthropicMessageMetadata {
|
|
|
169
169
|
} | null;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
|
|
172
|
+
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
173
173
|
/**
|
|
174
174
|
* Anthropic provider options for system messages.
|
|
175
175
|
*/
|
|
176
176
|
declare const anthropicSystemMessageProviderOptions: z.ZodObject<{
|
|
177
|
+
clearAt: z.ZodOptional<z.ZodLiteral<"next_user_message">>;
|
|
178
|
+
effort: z.ZodOptional<z.ZodEnum<{
|
|
179
|
+
low: "low";
|
|
180
|
+
medium: "medium";
|
|
181
|
+
high: "high";
|
|
182
|
+
xhigh: "xhigh";
|
|
183
|
+
max: "max";
|
|
184
|
+
}>>;
|
|
177
185
|
toolChanges: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
178
186
|
type: z.ZodLiteral<"tool_addition">;
|
|
179
187
|
toolName: z.ZodString;
|
|
@@ -190,17 +198,28 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
190
198
|
jsonTool: "jsonTool";
|
|
191
199
|
auto: "auto";
|
|
192
200
|
}>>;
|
|
193
|
-
thinking: z.ZodOptional<z.
|
|
201
|
+
thinking: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
194
202
|
type: z.ZodLiteral<"adaptive">;
|
|
195
203
|
display: z.ZodOptional<z.ZodEnum<{
|
|
196
204
|
omitted: "omitted";
|
|
197
205
|
summarized: "summarized";
|
|
206
|
+
updates: "updates";
|
|
198
207
|
}>>;
|
|
208
|
+
blockBinding: z.ZodOptional<z.ZodObject<{
|
|
209
|
+
prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
|
|
210
|
+
}, z.core.$strip>>;
|
|
199
211
|
}, z.core.$strip>, z.ZodObject<{
|
|
200
212
|
type: z.ZodLiteral<"enabled">;
|
|
201
213
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
214
|
+
blockBinding: z.ZodOptional<z.ZodObject<{
|
|
215
|
+
prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
|
|
216
|
+
}, z.core.$strip>>;
|
|
202
217
|
}, z.core.$strip>, z.ZodObject<{
|
|
203
218
|
type: z.ZodLiteral<"disabled">;
|
|
219
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
220
|
+
blockBinding: z.ZodObject<{
|
|
221
|
+
prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
|
|
222
|
+
}, z.core.$strip>;
|
|
204
223
|
}, z.core.$strip>]>>;
|
|
205
224
|
disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
|
|
206
225
|
cacheControl: z.ZodOptional<z.ZodObject<{
|
package/dist/index.d.ts
CHANGED
|
@@ -169,11 +169,19 @@ interface AnthropicMessageMetadata {
|
|
|
169
169
|
} | null;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
|
|
172
|
+
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-fable-5-1' | 'claude-sonnet-5' | (string & {});
|
|
173
173
|
/**
|
|
174
174
|
* Anthropic provider options for system messages.
|
|
175
175
|
*/
|
|
176
176
|
declare const anthropicSystemMessageProviderOptions: z.ZodObject<{
|
|
177
|
+
clearAt: z.ZodOptional<z.ZodLiteral<"next_user_message">>;
|
|
178
|
+
effort: z.ZodOptional<z.ZodEnum<{
|
|
179
|
+
low: "low";
|
|
180
|
+
medium: "medium";
|
|
181
|
+
high: "high";
|
|
182
|
+
xhigh: "xhigh";
|
|
183
|
+
max: "max";
|
|
184
|
+
}>>;
|
|
177
185
|
toolChanges: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
178
186
|
type: z.ZodLiteral<"tool_addition">;
|
|
179
187
|
toolName: z.ZodString;
|
|
@@ -190,17 +198,28 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
190
198
|
jsonTool: "jsonTool";
|
|
191
199
|
auto: "auto";
|
|
192
200
|
}>>;
|
|
193
|
-
thinking: z.ZodOptional<z.
|
|
201
|
+
thinking: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
194
202
|
type: z.ZodLiteral<"adaptive">;
|
|
195
203
|
display: z.ZodOptional<z.ZodEnum<{
|
|
196
204
|
omitted: "omitted";
|
|
197
205
|
summarized: "summarized";
|
|
206
|
+
updates: "updates";
|
|
198
207
|
}>>;
|
|
208
|
+
blockBinding: z.ZodOptional<z.ZodObject<{
|
|
209
|
+
prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
|
|
210
|
+
}, z.core.$strip>>;
|
|
199
211
|
}, z.core.$strip>, z.ZodObject<{
|
|
200
212
|
type: z.ZodLiteral<"enabled">;
|
|
201
213
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
214
|
+
blockBinding: z.ZodOptional<z.ZodObject<{
|
|
215
|
+
prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
|
|
216
|
+
}, z.core.$strip>>;
|
|
202
217
|
}, z.core.$strip>, z.ZodObject<{
|
|
203
218
|
type: z.ZodLiteral<"disabled">;
|
|
219
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
220
|
+
blockBinding: z.ZodObject<{
|
|
221
|
+
prefixMismatchBehavior: z.ZodLiteral<"drop_block">;
|
|
222
|
+
}, z.core.$strip>;
|
|
204
223
|
}, z.core.$strip>]>>;
|
|
205
224
|
disableParallelToolUse: z.ZodOptional<z.ZodBoolean>;
|
|
206
225
|
cacheControl: z.ZodOptional<z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
31
31
|
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
33
|
// src/version.ts
|
|
34
|
-
var VERSION = true ? "2.0.
|
|
34
|
+
var VERSION = true ? "2.0.101" : "0.0.0-test";
|
|
35
35
|
|
|
36
36
|
// src/anthropic-messages-language-model.ts
|
|
37
37
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -666,6 +666,19 @@ var anthropicFilePartProviderOptions = import_v43.z.object({
|
|
|
666
666
|
context: import_v43.z.string().optional()
|
|
667
667
|
});
|
|
668
668
|
var anthropicSystemMessageProviderOptions = import_v43.z.object({
|
|
669
|
+
/**
|
|
670
|
+
* Controls when a mid-conversation system message is cleared.
|
|
671
|
+
*
|
|
672
|
+
* The value is forwarded to Anthropic as `clear_at`. The required
|
|
673
|
+
* `mid-conversation-system-clear-at-2026-08-21` beta is added automatically.
|
|
674
|
+
*/
|
|
675
|
+
clearAt: import_v43.z.literal("next_user_message").optional(),
|
|
676
|
+
/**
|
|
677
|
+
* Overrides the effort for the turn following this mid-conversation system
|
|
678
|
+
* message. The required `mid-conversation-effort-2026-08-01` beta is added
|
|
679
|
+
* automatically.
|
|
680
|
+
*/
|
|
681
|
+
effort: import_v43.z.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
669
682
|
/**
|
|
670
683
|
* Mid-conversation tool changes. Adds or removes tools from the
|
|
671
684
|
* conversation's tool set between turns without invalidating the prompt
|
|
@@ -693,6 +706,14 @@ var anthropicSystemMessageProviderOptions = import_v43.z.object({
|
|
|
693
706
|
])
|
|
694
707
|
).optional()
|
|
695
708
|
});
|
|
709
|
+
var anthropicThinkingBlockBinding = import_v43.z.object({
|
|
710
|
+
/**
|
|
711
|
+
* Controls behavior when a replayed thinking block does not match its
|
|
712
|
+
* conversation prefix. The `drop_block` behavior drops the mismatched block
|
|
713
|
+
* instead of returning an invalid signature error.
|
|
714
|
+
*/
|
|
715
|
+
prefixMismatchBehavior: import_v43.z.literal("drop_block")
|
|
716
|
+
});
|
|
696
717
|
var anthropicProviderOptions = import_v43.z.object({
|
|
697
718
|
/**
|
|
698
719
|
* Whether to send reasoning to the model.
|
|
@@ -704,8 +725,8 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
704
725
|
* Determines how structured outputs are generated.
|
|
705
726
|
*
|
|
706
727
|
* - `outputFormat`: Use the `output_format` parameter to specify the structured output format.
|
|
707
|
-
* - `jsonTool`: Use a special JSON response tool to specify the structured output format (default).
|
|
708
|
-
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool'.
|
|
728
|
+
* - `jsonTool`: Use a special JSON response tool to specify the structured output format (default for most models).
|
|
729
|
+
* - `auto`: Use 'outputFormat' when supported, otherwise use 'jsonTool' (default for Fable 5.1).
|
|
709
730
|
*/
|
|
710
731
|
structuredOutputMode: import_v43.z.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
711
732
|
/**
|
|
@@ -714,7 +735,7 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
714
735
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
715
736
|
* Requires a minimum budget of 1,024 tokens and counts towards the `max_tokens` limit.
|
|
716
737
|
*/
|
|
717
|
-
thinking: import_v43.z.
|
|
738
|
+
thinking: import_v43.z.union([
|
|
718
739
|
import_v43.z.object({
|
|
719
740
|
/** for Sonnet 4.6, Opus 4.6, and newer models */
|
|
720
741
|
type: import_v43.z.literal("adaptive"),
|
|
@@ -722,16 +743,34 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
722
743
|
* Controls whether thinking content is included in the response.
|
|
723
744
|
* - `"omitted"`: Thinking blocks are present but text is empty (default for Opus 4.7+).
|
|
724
745
|
* - `"summarized"`: Thinking content is returned. Required to see reasoning output.
|
|
746
|
+
* - `"updates"`: Thinking summaries are emitted between tool calls.
|
|
747
|
+
*/
|
|
748
|
+
display: import_v43.z.enum(["omitted", "summarized", "updates"]).optional(),
|
|
749
|
+
/**
|
|
750
|
+
* Controls handling for thinking blocks whose conversation prefix no
|
|
751
|
+
* longer matches. Forwarded as `block_binding`.
|
|
725
752
|
*/
|
|
726
|
-
|
|
753
|
+
blockBinding: anthropicThinkingBlockBinding.optional()
|
|
727
754
|
}),
|
|
728
755
|
import_v43.z.object({
|
|
729
756
|
/** for models before Opus 4.6, except Sonnet 4.6 still supports it */
|
|
730
757
|
type: import_v43.z.literal("enabled"),
|
|
731
|
-
budgetTokens: import_v43.z.number().optional()
|
|
758
|
+
budgetTokens: import_v43.z.number().optional(),
|
|
759
|
+
/**
|
|
760
|
+
* Controls handling for thinking blocks whose conversation prefix no
|
|
761
|
+
* longer matches. Forwarded as `block_binding`.
|
|
762
|
+
*/
|
|
763
|
+
blockBinding: anthropicThinkingBlockBinding.optional()
|
|
732
764
|
}),
|
|
733
765
|
import_v43.z.object({
|
|
734
766
|
type: import_v43.z.literal("disabled")
|
|
767
|
+
}),
|
|
768
|
+
import_v43.z.object({
|
|
769
|
+
/**
|
|
770
|
+
* Configure prefix mismatch handling without changing the model's
|
|
771
|
+
* default thinking mode.
|
|
772
|
+
*/
|
|
773
|
+
blockBinding: anthropicThinkingBlockBinding
|
|
735
774
|
})
|
|
736
775
|
]).optional(),
|
|
737
776
|
/**
|
|
@@ -1474,7 +1513,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1474
1513
|
warnings,
|
|
1475
1514
|
cacheControlValidator
|
|
1476
1515
|
}) {
|
|
1477
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1516
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
1478
1517
|
const betas = /* @__PURE__ */ new Set();
|
|
1479
1518
|
const blocks = groupIntoBlocks(prompt);
|
|
1480
1519
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -1508,6 +1547,8 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1508
1547
|
case "system": {
|
|
1509
1548
|
const content = [];
|
|
1510
1549
|
let toolChangeCount = 0;
|
|
1550
|
+
let clearAt = void 0;
|
|
1551
|
+
let effort = void 0;
|
|
1511
1552
|
for (const { content: text, providerOptions } of block.messages) {
|
|
1512
1553
|
const systemMessageOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
1513
1554
|
provider: "anthropic",
|
|
@@ -1515,7 +1556,9 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1515
1556
|
schema: anthropicSystemMessageProviderOptions
|
|
1516
1557
|
});
|
|
1517
1558
|
const toolChanges = (_a = systemMessageOptions == null ? void 0 : systemMessageOptions.toolChanges) != null ? _a : [];
|
|
1518
|
-
|
|
1559
|
+
clearAt = (_b = systemMessageOptions == null ? void 0 : systemMessageOptions.clearAt) != null ? _b : clearAt;
|
|
1560
|
+
effort = (_c = systemMessageOptions == null ? void 0 : systemMessageOptions.effort) != null ? _c : effort;
|
|
1561
|
+
if (text !== "" || toolChanges.length === 0 && (systemMessageOptions == null ? void 0 : systemMessageOptions.clearAt) == null && (systemMessageOptions == null ? void 0 : systemMessageOptions.effort) == null) {
|
|
1519
1562
|
content.push({
|
|
1520
1563
|
type: "text",
|
|
1521
1564
|
text,
|
|
@@ -1536,22 +1579,34 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1536
1579
|
});
|
|
1537
1580
|
}
|
|
1538
1581
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1582
|
+
const hasMidConversationOptions = toolChangeCount > 0 || clearAt != null || effort != null;
|
|
1583
|
+
if (i === 0 || system == null && !hasMidConversationOptions) {
|
|
1584
|
+
if (hasMidConversationOptions) {
|
|
1541
1585
|
warnings.push({
|
|
1542
1586
|
type: "other",
|
|
1543
|
-
message: "
|
|
1587
|
+
message: "mid-conversation Anthropic system message options on the initial system message are not supported. The options have been ignored."
|
|
1544
1588
|
});
|
|
1545
1589
|
}
|
|
1546
1590
|
system = content.filter(
|
|
1547
1591
|
(part) => part.type === "text"
|
|
1548
1592
|
);
|
|
1549
1593
|
} else {
|
|
1550
|
-
messages.push({
|
|
1594
|
+
messages.push({
|
|
1595
|
+
role: "system",
|
|
1596
|
+
content,
|
|
1597
|
+
...clearAt != null && { clear_at: clearAt },
|
|
1598
|
+
...effort != null && { output_config: { effort } }
|
|
1599
|
+
});
|
|
1551
1600
|
betas.add("mid-conversation-system-2026-04-07");
|
|
1552
1601
|
if (toolChangeCount > 0) {
|
|
1553
1602
|
betas.add("mid-conversation-tool-changes-2026-07-01");
|
|
1554
1603
|
}
|
|
1604
|
+
if (clearAt != null) {
|
|
1605
|
+
betas.add("mid-conversation-system-clear-at-2026-08-21");
|
|
1606
|
+
}
|
|
1607
|
+
if (effort != null) {
|
|
1608
|
+
betas.add("mid-conversation-effort-2026-08-01");
|
|
1609
|
+
}
|
|
1555
1610
|
}
|
|
1556
1611
|
break;
|
|
1557
1612
|
}
|
|
@@ -1564,10 +1619,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1564
1619
|
for (let j = 0; j < content.length; j++) {
|
|
1565
1620
|
const part = content[j];
|
|
1566
1621
|
const isLastPart = j === content.length - 1;
|
|
1567
|
-
const cacheControl = (
|
|
1622
|
+
const cacheControl = (_d = validator.getCacheControl(part.providerOptions, {
|
|
1568
1623
|
type: "user message part",
|
|
1569
1624
|
canCache: true
|
|
1570
|
-
})) != null ?
|
|
1625
|
+
})) != null ? _d : isLastPart ? validator.getCacheControl(message.providerOptions, {
|
|
1571
1626
|
type: "user message",
|
|
1572
1627
|
canCache: true
|
|
1573
1628
|
}) : void 0;
|
|
@@ -1612,7 +1667,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1612
1667
|
media_type: "application/pdf",
|
|
1613
1668
|
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
1614
1669
|
},
|
|
1615
|
-
title: (
|
|
1670
|
+
title: (_e = metadata.title) != null ? _e : part.filename,
|
|
1616
1671
|
...metadata.context && { context: metadata.context },
|
|
1617
1672
|
...enableCitations && {
|
|
1618
1673
|
citations: { enabled: true }
|
|
@@ -1636,7 +1691,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1636
1691
|
media_type: "text/plain",
|
|
1637
1692
|
data: convertToString(part.data)
|
|
1638
1693
|
},
|
|
1639
|
-
title: (
|
|
1694
|
+
title: (_f = metadata.title) != null ? _f : part.filename,
|
|
1640
1695
|
...metadata.context && { context: metadata.context },
|
|
1641
1696
|
...enableCitations && {
|
|
1642
1697
|
citations: { enabled: true }
|
|
@@ -1658,10 +1713,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1658
1713
|
for (let i2 = 0; i2 < content.length; i2++) {
|
|
1659
1714
|
const part = content[i2];
|
|
1660
1715
|
const isLastPart = i2 === content.length - 1;
|
|
1661
|
-
const cacheControl = (
|
|
1716
|
+
const cacheControl = (_g = validator.getCacheControl(part.providerOptions, {
|
|
1662
1717
|
type: "tool result part",
|
|
1663
1718
|
canCache: true
|
|
1664
|
-
})) != null ?
|
|
1719
|
+
})) != null ? _g : isLastPart ? validator.getCacheControl(message.providerOptions, {
|
|
1665
1720
|
type: "tool result message",
|
|
1666
1721
|
canCache: true
|
|
1667
1722
|
}) : void 0;
|
|
@@ -1743,16 +1798,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1743
1798
|
for (let k = 0; k < content.length; k++) {
|
|
1744
1799
|
const part = content[k];
|
|
1745
1800
|
const isLastContentPart = k === content.length - 1;
|
|
1746
|
-
const cacheControl = (
|
|
1801
|
+
const cacheControl = (_h = validator.getCacheControl(part.providerOptions, {
|
|
1747
1802
|
type: "assistant message part",
|
|
1748
1803
|
canCache: true
|
|
1749
|
-
})) != null ?
|
|
1804
|
+
})) != null ? _h : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
|
|
1750
1805
|
type: "assistant message",
|
|
1751
1806
|
canCache: true
|
|
1752
1807
|
}) : void 0;
|
|
1753
1808
|
switch (part.type) {
|
|
1754
1809
|
case "text": {
|
|
1755
|
-
const textMetadata = (
|
|
1810
|
+
const textMetadata = (_i = part.providerOptions) == null ? void 0 : _i.anthropic;
|
|
1756
1811
|
if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
|
|
1757
1812
|
anthropicContent.push({
|
|
1758
1813
|
type: "compaction",
|
|
@@ -2321,7 +2376,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2321
2376
|
toolChoice,
|
|
2322
2377
|
providerOptions
|
|
2323
2378
|
}) {
|
|
2324
|
-
var _a, _b, _c, _d, _e
|
|
2379
|
+
var _a, _b, _c, _d, _e;
|
|
2325
2380
|
const warnings = [];
|
|
2326
2381
|
if (frequencyPenalty != null) {
|
|
2327
2382
|
warnings.push({
|
|
@@ -2410,7 +2465,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2410
2465
|
}
|
|
2411
2466
|
}
|
|
2412
2467
|
const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
|
|
2413
|
-
const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "jsonTool";
|
|
2468
|
+
const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : this.modelId.includes("claude-fable-5-1") ? "auto" : "jsonTool";
|
|
2414
2469
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2415
2470
|
const jsonResponseToolName = getJsonResponseToolName(tools);
|
|
2416
2471
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
@@ -2433,7 +2488,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2433
2488
|
warnings,
|
|
2434
2489
|
cacheControlValidator
|
|
2435
2490
|
});
|
|
2436
|
-
|
|
2491
|
+
const thinkingOptions = anthropicOptions == null ? void 0 : anthropicOptions.thinking;
|
|
2492
|
+
const thinkingType = thinkingOptions != null && "type" in thinkingOptions ? thinkingOptions.type : void 0;
|
|
2493
|
+
if (rejectsThinkingDisabledAboveHighEffort && thinkingType === "disabled" && anthropicOptions != null && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
|
|
2437
2494
|
warnings.push({
|
|
2438
2495
|
type: "unsupported-setting",
|
|
2439
2496
|
setting: "providerOptions.anthropic.effort",
|
|
@@ -2441,10 +2498,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2441
2498
|
});
|
|
2442
2499
|
anthropicOptions.effort = "high";
|
|
2443
2500
|
}
|
|
2444
|
-
const thinkingType = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.type;
|
|
2445
2501
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2446
|
-
let thinkingBudget =
|
|
2447
|
-
const thinkingDisplay =
|
|
2502
|
+
let thinkingBudget = thinkingOptions != null && "budgetTokens" in thinkingOptions ? thinkingOptions.budgetTokens : void 0;
|
|
2503
|
+
const thinkingDisplay = thinkingOptions != null && "display" in thinkingOptions ? thinkingOptions.display : void 0;
|
|
2504
|
+
const thinkingBlockBinding = thinkingOptions != null && "blockBinding" in thinkingOptions ? thinkingOptions.blockBinding : void 0;
|
|
2448
2505
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2449
2506
|
const baseArgs = {
|
|
2450
2507
|
// model id:
|
|
@@ -2456,11 +2513,16 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2456
2513
|
top_p: topP,
|
|
2457
2514
|
stop_sequences: stopSequences,
|
|
2458
2515
|
// provider specific settings:
|
|
2459
|
-
...isThinking && {
|
|
2516
|
+
...(isThinking || thinkingBlockBinding != null) && {
|
|
2460
2517
|
thinking: {
|
|
2461
|
-
type: thinkingType,
|
|
2518
|
+
...thinkingType != null && { type: thinkingType },
|
|
2462
2519
|
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
2463
|
-
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
2520
|
+
...thinkingDisplay != null && { display: thinkingDisplay },
|
|
2521
|
+
...thinkingBlockBinding != null && {
|
|
2522
|
+
block_binding: {
|
|
2523
|
+
prefix_mismatch_behavior: thinkingBlockBinding.prefixMismatchBehavior
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2464
2526
|
}
|
|
2465
2527
|
},
|
|
2466
2528
|
...((anthropicOptions == null ? void 0 : anthropicOptions.effort) || (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
@@ -2497,14 +2559,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2497
2559
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
2498
2560
|
cache_control: anthropicOptions.cacheControl
|
|
2499
2561
|
},
|
|
2500
|
-
...((
|
|
2562
|
+
...((_c = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _c.userId) != null && {
|
|
2501
2563
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
2502
2564
|
},
|
|
2503
2565
|
// container with agent skills:
|
|
2504
2566
|
...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
|
|
2505
2567
|
container: {
|
|
2506
2568
|
id: anthropicOptions.container.id,
|
|
2507
|
-
skills: (
|
|
2569
|
+
skills: (_d = anthropicOptions.container.skills) == null ? void 0 : _d.map((skill) => ({
|
|
2508
2570
|
type: skill.type,
|
|
2509
2571
|
skill_id: skill.skillId,
|
|
2510
2572
|
version: skill.version
|
|
@@ -2630,6 +2692,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2630
2692
|
if (anthropicOptions == null ? void 0 : anthropicOptions.effort) {
|
|
2631
2693
|
betas.add("effort-2025-11-24");
|
|
2632
2694
|
}
|
|
2695
|
+
if (thinkingDisplay === "updates") {
|
|
2696
|
+
betas.add("thinking-display-updates-2026-08-18");
|
|
2697
|
+
}
|
|
2698
|
+
if (thinkingBlockBinding != null) {
|
|
2699
|
+
betas.add("thinking-binding-controls-2026-08-01");
|
|
2700
|
+
}
|
|
2633
2701
|
if (anthropicOptions == null ? void 0 : anthropicOptions.taskBudget) {
|
|
2634
2702
|
betas.add("task-budgets-2026-03-13");
|
|
2635
2703
|
}
|
|
@@ -2641,7 +2709,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2641
2709
|
} else if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
|
|
2642
2710
|
betas.add("server-side-fallback-2026-06-01");
|
|
2643
2711
|
}
|
|
2644
|
-
if (useStructuredOutput) {
|
|
2712
|
+
if (useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null) {
|
|
2645
2713
|
betas.add("structured-outputs-2025-11-13");
|
|
2646
2714
|
}
|
|
2647
2715
|
const contextManagement = anthropicOptions == null ? void 0 : anthropicOptions.contextManagement;
|
|
@@ -2681,7 +2749,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2681
2749
|
...betas,
|
|
2682
2750
|
...toolsBetas,
|
|
2683
2751
|
...userSuppliedBetas,
|
|
2684
|
-
...(
|
|
2752
|
+
...(_e = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _e : []
|
|
2685
2753
|
]),
|
|
2686
2754
|
jsonResponseToolName: jsonResponseTool != null ? jsonResponseToolName : void 0
|
|
2687
2755
|
};
|
|
@@ -3741,7 +3809,7 @@ function getModelCapabilities(modelId) {
|
|
|
3741
3809
|
rejectsThinkingDisabledAboveHighEffort: true,
|
|
3742
3810
|
isKnownModel: true
|
|
3743
3811
|
};
|
|
3744
|
-
} else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
|
|
3812
|
+
} else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5-1") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
|
|
3745
3813
|
return {
|
|
3746
3814
|
maxOutputTokens: 128e3,
|
|
3747
3815
|
supportsStructuredOutput: true,
|