@ai-sdk/anthropic 2.0.89 → 2.0.91
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 +14 -0
- package/dist/index.d.mts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +163 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +163 -56
- 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 +162 -55
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +162 -55
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 2.0.91
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0ab9755: feat (provider/anthropic): support fallbacks 'default' mode, which routes safety classifier refusals to Anthropic's recommended fallback model (adds the server-side-fallback-2026-07-01 beta automatically)
|
|
8
|
+
- 0ab9755: feat (provider/anthropic): support mid-conversation tool changes via the toolChanges system message provider option, emitting tool_addition/tool_removal content blocks and the mid-conversation-tool-changes-2026-07-01 beta
|
|
9
|
+
- 0ab9755: feat (provider/anthropic): add claude-opus-5 model id with frontier-tier capabilities (128k output tokens, structured output, adaptive thinking, xhigh effort, sampling parameter rejection, thinking-disabled only at effort high or below)
|
|
10
|
+
|
|
11
|
+
## 2.0.90
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- db28434: fix (provider/anthropic): use current-generation capability defaults for unrecognized Claude model IDs while retaining conservative defaults for legacy Claude and non-Claude models.
|
|
16
|
+
|
|
3
17
|
## 2.0.89
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -169,7 +169,20 @@ 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-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-sonnet-5' | (string & {});
|
|
173
|
+
/**
|
|
174
|
+
* Anthropic provider options for system messages.
|
|
175
|
+
*/
|
|
176
|
+
declare const anthropicSystemMessageProviderOptions: z.ZodObject<{
|
|
177
|
+
toolChanges: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
178
|
+
type: z.ZodLiteral<"tool_addition">;
|
|
179
|
+
toolName: z.ZodString;
|
|
180
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
181
|
+
type: z.ZodLiteral<"tool_removal">;
|
|
182
|
+
toolName: z.ZodString;
|
|
183
|
+
}, z.core.$strip>]>>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
type AnthropicSystemMessageProviderOptions = z.infer<typeof anthropicSystemMessageProviderOptions>;
|
|
173
186
|
declare const anthropicProviderOptions: z.ZodObject<{
|
|
174
187
|
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
175
188
|
structuredOutputMode: z.ZodOptional<z.ZodEnum<{
|
|
@@ -225,7 +238,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
225
238
|
us: "us";
|
|
226
239
|
global: "global";
|
|
227
240
|
}>>;
|
|
228
|
-
fallbacks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
241
|
+
fallbacks: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"default">, z.ZodArray<z.ZodObject<{
|
|
229
242
|
model: z.ZodString;
|
|
230
243
|
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
231
244
|
thinking: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -234,7 +247,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
234
247
|
fast: "fast";
|
|
235
248
|
standard: "standard";
|
|
236
249
|
}>>;
|
|
237
|
-
}, z.core.$strip
|
|
250
|
+
}, z.core.$strip>>]>>;
|
|
238
251
|
contextManagement: z.ZodOptional<z.ZodObject<{
|
|
239
252
|
edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
240
253
|
type: z.ZodLiteral<"clear_tool_uses_20250919">;
|
|
@@ -903,4 +916,4 @@ declare const anthropic: AnthropicProvider;
|
|
|
903
916
|
|
|
904
917
|
declare const VERSION: string;
|
|
905
918
|
|
|
906
|
-
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic };
|
|
919
|
+
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicSystemMessageProviderOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic };
|
package/dist/index.d.ts
CHANGED
|
@@ -169,7 +169,20 @@ 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-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-sonnet-5' | (string & {});
|
|
173
|
+
/**
|
|
174
|
+
* Anthropic provider options for system messages.
|
|
175
|
+
*/
|
|
176
|
+
declare const anthropicSystemMessageProviderOptions: z.ZodObject<{
|
|
177
|
+
toolChanges: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
178
|
+
type: z.ZodLiteral<"tool_addition">;
|
|
179
|
+
toolName: z.ZodString;
|
|
180
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
181
|
+
type: z.ZodLiteral<"tool_removal">;
|
|
182
|
+
toolName: z.ZodString;
|
|
183
|
+
}, z.core.$strip>]>>>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
type AnthropicSystemMessageProviderOptions = z.infer<typeof anthropicSystemMessageProviderOptions>;
|
|
173
186
|
declare const anthropicProviderOptions: z.ZodObject<{
|
|
174
187
|
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
175
188
|
structuredOutputMode: z.ZodOptional<z.ZodEnum<{
|
|
@@ -225,7 +238,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
225
238
|
us: "us";
|
|
226
239
|
global: "global";
|
|
227
240
|
}>>;
|
|
228
|
-
fallbacks: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
241
|
+
fallbacks: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"default">, z.ZodArray<z.ZodObject<{
|
|
229
242
|
model: z.ZodString;
|
|
230
243
|
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
231
244
|
thinking: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -234,7 +247,7 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
234
247
|
fast: "fast";
|
|
235
248
|
standard: "standard";
|
|
236
249
|
}>>;
|
|
237
|
-
}, z.core.$strip
|
|
250
|
+
}, z.core.$strip>>]>>;
|
|
238
251
|
contextManagement: z.ZodOptional<z.ZodObject<{
|
|
239
252
|
edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
240
253
|
type: z.ZodLiteral<"clear_tool_uses_20250919">;
|
|
@@ -903,4 +916,4 @@ declare const anthropic: AnthropicProvider;
|
|
|
903
916
|
|
|
904
917
|
declare const VERSION: string;
|
|
905
918
|
|
|
906
|
-
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic };
|
|
919
|
+
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicSystemMessageProviderOptions, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic };
|
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.91" : "0.0.0-test";
|
|
35
35
|
|
|
36
36
|
// src/anthropic-messages-language-model.ts
|
|
37
37
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -665,7 +665,40 @@ var anthropicFilePartProviderOptions = import_v43.z.object({
|
|
|
665
665
|
*/
|
|
666
666
|
context: import_v43.z.string().optional()
|
|
667
667
|
});
|
|
668
|
+
var anthropicSystemMessageProviderOptions = import_v43.z.object({
|
|
669
|
+
/**
|
|
670
|
+
* Mid-conversation tool changes. Adds or removes tools from the
|
|
671
|
+
* conversation's tool set between turns without invalidating the prompt
|
|
672
|
+
* cache.
|
|
673
|
+
*
|
|
674
|
+
* Only supported on system messages that appear mid-conversation (not the
|
|
675
|
+
* initial system prompt). A system message carrying tool changes must come
|
|
676
|
+
* right before an assistant message or at the end of the messages.
|
|
677
|
+
*
|
|
678
|
+
* Tools referenced by a `tool_addition` must be declared in the `tools`
|
|
679
|
+
* option (typically with `deferLoading: true` so they are not loaded until
|
|
680
|
+
* the addition surfaces them). The required
|
|
681
|
+
* `mid-conversation-tool-changes-2026-07-01` beta is added automatically.
|
|
682
|
+
*/
|
|
683
|
+
toolChanges: import_v43.z.array(
|
|
684
|
+
import_v43.z.discriminatedUnion("type", [
|
|
685
|
+
import_v43.z.object({
|
|
686
|
+
type: import_v43.z.literal("tool_addition"),
|
|
687
|
+
toolName: import_v43.z.string()
|
|
688
|
+
}),
|
|
689
|
+
import_v43.z.object({
|
|
690
|
+
type: import_v43.z.literal("tool_removal"),
|
|
691
|
+
toolName: import_v43.z.string()
|
|
692
|
+
})
|
|
693
|
+
])
|
|
694
|
+
).optional()
|
|
695
|
+
});
|
|
668
696
|
var anthropicProviderOptions = import_v43.z.object({
|
|
697
|
+
/**
|
|
698
|
+
* Whether to send reasoning to the model.
|
|
699
|
+
*
|
|
700
|
+
* This allows you to deactivate reasoning inputs for models that do not support them.
|
|
701
|
+
*/
|
|
669
702
|
sendReasoning: import_v43.z.boolean().optional(),
|
|
670
703
|
/**
|
|
671
704
|
* Determines how structured outputs are generated.
|
|
@@ -774,30 +807,35 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
774
807
|
*/
|
|
775
808
|
inferenceGeo: import_v43.z.enum(["us", "global"]).optional(),
|
|
776
809
|
/**
|
|
777
|
-
* Server-side fallback
|
|
810
|
+
* Server-side fallback configuration.
|
|
778
811
|
*
|
|
779
812
|
* When the primary model's safety classifiers block a turn, the API
|
|
780
|
-
* automatically retries it on
|
|
781
|
-
* `content-filter` finish reason means the
|
|
782
|
-
*
|
|
783
|
-
* Each entry is merged into the request as a direct request to that entry's
|
|
784
|
-
* model, so it must be formatted accordingly: `model` is required, and an
|
|
785
|
-
* entry may additionally override `max_tokens`, `thinking`, `output_config`,
|
|
786
|
-
* and `speed` for that attempt only (`speed` additionally requires the speed
|
|
787
|
-
* beta). The value is passed through to the API as-is.
|
|
813
|
+
* automatically retries it server-side on a fallback model. A
|
|
814
|
+
* `content-filter` finish reason means the fallback(s) refused as well.
|
|
788
815
|
*
|
|
789
|
-
*
|
|
790
|
-
*
|
|
816
|
+
* - `'default'` (recommended): the API routes the retry to Anthropic's
|
|
817
|
+
* recommended fallback model based on the refusal category. Requires the
|
|
818
|
+
* `server-side-fallback-2026-07-01` beta, which is added automatically.
|
|
819
|
+
* - Array form: an explicit fallback chain. Each entry is merged into the
|
|
820
|
+
* request as a direct request to that entry's model, so it must be
|
|
821
|
+
* formatted accordingly: `model` is required, and an entry may
|
|
822
|
+
* additionally override `max_tokens`, `thinking`, `output_config`, and
|
|
823
|
+
* `speed` for that attempt only (`speed` additionally requires the speed
|
|
824
|
+
* beta). The value is passed through to the API as-is, and the
|
|
825
|
+
* `server-side-fallback-2026-06-01` beta is added automatically.
|
|
791
826
|
*/
|
|
792
|
-
fallbacks: import_v43.z.
|
|
793
|
-
import_v43.z.
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
827
|
+
fallbacks: import_v43.z.union([
|
|
828
|
+
import_v43.z.literal("default"),
|
|
829
|
+
import_v43.z.array(
|
|
830
|
+
import_v43.z.object({
|
|
831
|
+
model: import_v43.z.string(),
|
|
832
|
+
max_tokens: import_v43.z.number().int().optional(),
|
|
833
|
+
thinking: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
|
|
834
|
+
output_config: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
|
|
835
|
+
speed: import_v43.z.enum(["fast", "standard"]).optional()
|
|
836
|
+
})
|
|
837
|
+
)
|
|
838
|
+
]).optional(),
|
|
801
839
|
/**
|
|
802
840
|
* Context management configuration for automatic context window management.
|
|
803
841
|
* Enables features like automatic compaction and clearing of tool uses/thinking blocks.
|
|
@@ -1436,7 +1474,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1436
1474
|
warnings,
|
|
1437
1475
|
cacheControlValidator
|
|
1438
1476
|
}) {
|
|
1439
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1477
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1440
1478
|
const betas = /* @__PURE__ */ new Set();
|
|
1441
1479
|
const blocks = groupIntoBlocks(prompt);
|
|
1442
1480
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -1468,19 +1506,52 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1468
1506
|
const type = block.type;
|
|
1469
1507
|
switch (type) {
|
|
1470
1508
|
case "system": {
|
|
1471
|
-
const content =
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1509
|
+
const content = [];
|
|
1510
|
+
let toolChangeCount = 0;
|
|
1511
|
+
for (const { content: text, providerOptions } of block.messages) {
|
|
1512
|
+
const systemMessageOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
1513
|
+
provider: "anthropic",
|
|
1514
|
+
providerOptions,
|
|
1515
|
+
schema: anthropicSystemMessageProviderOptions
|
|
1516
|
+
});
|
|
1517
|
+
const toolChanges = (_a = systemMessageOptions == null ? void 0 : systemMessageOptions.toolChanges) != null ? _a : [];
|
|
1518
|
+
if (text !== "" || toolChanges.length === 0) {
|
|
1519
|
+
content.push({
|
|
1520
|
+
type: "text",
|
|
1521
|
+
text,
|
|
1522
|
+
cache_control: validator.getCacheControl(providerOptions, {
|
|
1523
|
+
type: "system message",
|
|
1524
|
+
canCache: true
|
|
1525
|
+
})
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
for (const toolChange of toolChanges) {
|
|
1529
|
+
toolChangeCount++;
|
|
1530
|
+
content.push({
|
|
1531
|
+
type: toolChange.type,
|
|
1532
|
+
tool: {
|
|
1533
|
+
type: "tool_reference",
|
|
1534
|
+
name: toolChange.toolName
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
if (i === 0 || system == null && toolChangeCount === 0) {
|
|
1540
|
+
if (toolChangeCount > 0) {
|
|
1541
|
+
warnings.push({
|
|
1542
|
+
type: "other",
|
|
1543
|
+
message: "tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored."
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
system = content.filter(
|
|
1547
|
+
(part) => part.type === "text"
|
|
1548
|
+
);
|
|
1481
1549
|
} else {
|
|
1482
1550
|
messages.push({ role: "system", content });
|
|
1483
1551
|
betas.add("mid-conversation-system-2026-04-07");
|
|
1552
|
+
if (toolChangeCount > 0) {
|
|
1553
|
+
betas.add("mid-conversation-tool-changes-2026-07-01");
|
|
1554
|
+
}
|
|
1484
1555
|
}
|
|
1485
1556
|
break;
|
|
1486
1557
|
}
|
|
@@ -1493,10 +1564,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1493
1564
|
for (let j = 0; j < content.length; j++) {
|
|
1494
1565
|
const part = content[j];
|
|
1495
1566
|
const isLastPart = j === content.length - 1;
|
|
1496
|
-
const cacheControl = (
|
|
1567
|
+
const cacheControl = (_b = validator.getCacheControl(part.providerOptions, {
|
|
1497
1568
|
type: "user message part",
|
|
1498
1569
|
canCache: true
|
|
1499
|
-
})) != null ?
|
|
1570
|
+
})) != null ? _b : isLastPart ? validator.getCacheControl(message.providerOptions, {
|
|
1500
1571
|
type: "user message",
|
|
1501
1572
|
canCache: true
|
|
1502
1573
|
}) : void 0;
|
|
@@ -1541,7 +1612,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1541
1612
|
media_type: "application/pdf",
|
|
1542
1613
|
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
1543
1614
|
},
|
|
1544
|
-
title: (
|
|
1615
|
+
title: (_c = metadata.title) != null ? _c : part.filename,
|
|
1545
1616
|
...metadata.context && { context: metadata.context },
|
|
1546
1617
|
...enableCitations && {
|
|
1547
1618
|
citations: { enabled: true }
|
|
@@ -1565,7 +1636,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1565
1636
|
media_type: "text/plain",
|
|
1566
1637
|
data: convertToString(part.data)
|
|
1567
1638
|
},
|
|
1568
|
-
title: (
|
|
1639
|
+
title: (_d = metadata.title) != null ? _d : part.filename,
|
|
1569
1640
|
...metadata.context && { context: metadata.context },
|
|
1570
1641
|
...enableCitations && {
|
|
1571
1642
|
citations: { enabled: true }
|
|
@@ -1587,10 +1658,10 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1587
1658
|
for (let i2 = 0; i2 < content.length; i2++) {
|
|
1588
1659
|
const part = content[i2];
|
|
1589
1660
|
const isLastPart = i2 === content.length - 1;
|
|
1590
|
-
const cacheControl = (
|
|
1661
|
+
const cacheControl = (_e = validator.getCacheControl(part.providerOptions, {
|
|
1591
1662
|
type: "tool result part",
|
|
1592
1663
|
canCache: true
|
|
1593
|
-
})) != null ?
|
|
1664
|
+
})) != null ? _e : isLastPart ? validator.getCacheControl(message.providerOptions, {
|
|
1594
1665
|
type: "tool result message",
|
|
1595
1666
|
canCache: true
|
|
1596
1667
|
}) : void 0;
|
|
@@ -1672,16 +1743,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1672
1743
|
for (let k = 0; k < content.length; k++) {
|
|
1673
1744
|
const part = content[k];
|
|
1674
1745
|
const isLastContentPart = k === content.length - 1;
|
|
1675
|
-
const cacheControl = (
|
|
1746
|
+
const cacheControl = (_f = validator.getCacheControl(part.providerOptions, {
|
|
1676
1747
|
type: "assistant message part",
|
|
1677
1748
|
canCache: true
|
|
1678
|
-
})) != null ?
|
|
1749
|
+
})) != null ? _f : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
|
|
1679
1750
|
type: "assistant message",
|
|
1680
1751
|
canCache: true
|
|
1681
1752
|
}) : void 0;
|
|
1682
1753
|
switch (part.type) {
|
|
1683
1754
|
case "text": {
|
|
1684
|
-
const textMetadata = (
|
|
1755
|
+
const textMetadata = (_g = part.providerOptions) == null ? void 0 : _g.anthropic;
|
|
1685
1756
|
if ((textMetadata == null ? void 0 : textMetadata.type) === "compaction") {
|
|
1686
1757
|
anthropicContent.push({
|
|
1687
1758
|
type: "compaction",
|
|
@@ -2208,7 +2279,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2208
2279
|
toolChoice,
|
|
2209
2280
|
providerOptions
|
|
2210
2281
|
}) {
|
|
2211
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2282
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
2212
2283
|
const warnings = [];
|
|
2213
2284
|
if (frequencyPenalty != null) {
|
|
2214
2285
|
warnings.push({
|
|
@@ -2267,6 +2338,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2267
2338
|
maxOutputTokens: maxOutputTokensForModel,
|
|
2268
2339
|
supportsStructuredOutput,
|
|
2269
2340
|
rejectsSamplingParameters,
|
|
2341
|
+
rejectsThinkingDisabledAboveHighEffort,
|
|
2270
2342
|
isKnownModel
|
|
2271
2343
|
} = getModelCapabilities(this.modelId);
|
|
2272
2344
|
if (!isKnownModel && maxOutputTokens == null) {
|
|
@@ -2301,7 +2373,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2301
2373
|
topP = void 0;
|
|
2302
2374
|
}
|
|
2303
2375
|
}
|
|
2304
|
-
const isAnthropicModel = isKnownModel || this.modelId.
|
|
2376
|
+
const isAnthropicModel = isKnownModel || this.modelId.includes("claude-");
|
|
2305
2377
|
const structureOutputMode = (_a = anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _a : "jsonTool";
|
|
2306
2378
|
const useStructuredOutput = structureOutputMode === "outputFormat" || structureOutputMode === "auto" && supportsStructuredOutput;
|
|
2307
2379
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useStructuredOutput ? {
|
|
@@ -2324,10 +2396,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2324
2396
|
warnings,
|
|
2325
2397
|
cacheControlValidator
|
|
2326
2398
|
});
|
|
2327
|
-
|
|
2399
|
+
if (rejectsThinkingDisabledAboveHighEffort && ((_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.type) === "disabled" && (anthropicOptions.effort === "xhigh" || anthropicOptions.effort === "max")) {
|
|
2400
|
+
warnings.push({
|
|
2401
|
+
type: "unsupported-setting",
|
|
2402
|
+
setting: "providerOptions.anthropic.effort",
|
|
2403
|
+
details: `effort '${anthropicOptions.effort}' is not supported by ${this.modelId} when thinking is disabled. The effort has been lowered to 'high'.`
|
|
2404
|
+
});
|
|
2405
|
+
anthropicOptions.effort = "high";
|
|
2406
|
+
}
|
|
2407
|
+
const thinkingType = (_d = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _d.type;
|
|
2328
2408
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
2329
|
-
let thinkingBudget = thinkingType === "enabled" ? (
|
|
2330
|
-
const thinkingDisplay = thinkingType === "adaptive" ? (
|
|
2409
|
+
let thinkingBudget = thinkingType === "enabled" ? (_e = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _e.budgetTokens : void 0;
|
|
2410
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_f = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _f.display : void 0;
|
|
2331
2411
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
2332
2412
|
const baseArgs = {
|
|
2333
2413
|
// model id:
|
|
@@ -2374,20 +2454,20 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2374
2454
|
...(anthropicOptions == null ? void 0 : anthropicOptions.inferenceGeo) && {
|
|
2375
2455
|
inference_geo: anthropicOptions.inferenceGeo
|
|
2376
2456
|
},
|
|
2377
|
-
...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0 && {
|
|
2457
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) != null && (anthropicOptions.fallbacks === "default" || anthropicOptions.fallbacks.length > 0) && {
|
|
2378
2458
|
fallbacks: anthropicOptions.fallbacks
|
|
2379
2459
|
},
|
|
2380
2460
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
2381
2461
|
cache_control: anthropicOptions.cacheControl
|
|
2382
2462
|
},
|
|
2383
|
-
...((
|
|
2463
|
+
...((_g = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _g.userId) != null && {
|
|
2384
2464
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
2385
2465
|
},
|
|
2386
2466
|
// container with agent skills:
|
|
2387
2467
|
...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
|
|
2388
2468
|
container: {
|
|
2389
2469
|
id: anthropicOptions.container.id,
|
|
2390
|
-
skills: (
|
|
2470
|
+
skills: (_h = anthropicOptions.container.skills) == null ? void 0 : _h.map((skill) => ({
|
|
2391
2471
|
type: skill.type,
|
|
2392
2472
|
skill_id: skill.skillId,
|
|
2393
2473
|
version: skill.version
|
|
@@ -2519,7 +2599,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2519
2599
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
2520
2600
|
betas.add("fast-mode-2026-02-01");
|
|
2521
2601
|
}
|
|
2522
|
-
if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks)
|
|
2602
|
+
if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) === "default") {
|
|
2603
|
+
betas.add("server-side-fallback-2026-07-01");
|
|
2604
|
+
} else if ((anthropicOptions == null ? void 0 : anthropicOptions.fallbacks) && anthropicOptions.fallbacks.length > 0) {
|
|
2523
2605
|
betas.add("server-side-fallback-2026-06-01");
|
|
2524
2606
|
}
|
|
2525
2607
|
if (useStructuredOutput) {
|
|
@@ -2562,7 +2644,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2562
2644
|
...betas,
|
|
2563
2645
|
...toolsBetas,
|
|
2564
2646
|
...userSuppliedBetas,
|
|
2565
|
-
...(
|
|
2647
|
+
...(_i = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _i : []
|
|
2566
2648
|
]),
|
|
2567
2649
|
usesJsonResponseTool: jsonResponseTool != null
|
|
2568
2650
|
};
|
|
@@ -3578,11 +3660,20 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3578
3660
|
}
|
|
3579
3661
|
};
|
|
3580
3662
|
function getModelCapabilities(modelId) {
|
|
3581
|
-
if (modelId.includes("claude-opus-
|
|
3663
|
+
if (modelId.includes("claude-opus-5")) {
|
|
3582
3664
|
return {
|
|
3583
3665
|
maxOutputTokens: 128e3,
|
|
3584
3666
|
supportsStructuredOutput: true,
|
|
3585
3667
|
rejectsSamplingParameters: true,
|
|
3668
|
+
rejectsThinkingDisabledAboveHighEffort: true,
|
|
3669
|
+
isKnownModel: true
|
|
3670
|
+
};
|
|
3671
|
+
} else if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7") || modelId.includes("claude-fable-5") || modelId.includes("claude-sonnet-5")) {
|
|
3672
|
+
return {
|
|
3673
|
+
maxOutputTokens: 128e3,
|
|
3674
|
+
supportsStructuredOutput: true,
|
|
3675
|
+
rejectsSamplingParameters: true,
|
|
3676
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3586
3677
|
isKnownModel: true
|
|
3587
3678
|
};
|
|
3588
3679
|
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
@@ -3590,6 +3681,7 @@ function getModelCapabilities(modelId) {
|
|
|
3590
3681
|
maxOutputTokens: 128e3,
|
|
3591
3682
|
supportsStructuredOutput: true,
|
|
3592
3683
|
rejectsSamplingParameters: false,
|
|
3684
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3593
3685
|
isKnownModel: true
|
|
3594
3686
|
};
|
|
3595
3687
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
@@ -3597,6 +3689,7 @@ function getModelCapabilities(modelId) {
|
|
|
3597
3689
|
maxOutputTokens: 64e3,
|
|
3598
3690
|
supportsStructuredOutput: true,
|
|
3599
3691
|
rejectsSamplingParameters: false,
|
|
3692
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3600
3693
|
isKnownModel: true
|
|
3601
3694
|
};
|
|
3602
3695
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
@@ -3604,6 +3697,7 @@ function getModelCapabilities(modelId) {
|
|
|
3604
3697
|
maxOutputTokens: 32e3,
|
|
3605
3698
|
supportsStructuredOutput: true,
|
|
3606
3699
|
rejectsSamplingParameters: false,
|
|
3700
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3607
3701
|
isKnownModel: true
|
|
3608
3702
|
};
|
|
3609
3703
|
} else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
|
|
@@ -3611,6 +3705,7 @@ function getModelCapabilities(modelId) {
|
|
|
3611
3705
|
maxOutputTokens: 64e3,
|
|
3612
3706
|
supportsStructuredOutput: false,
|
|
3613
3707
|
rejectsSamplingParameters: false,
|
|
3708
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3614
3709
|
isKnownModel: true
|
|
3615
3710
|
};
|
|
3616
3711
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
@@ -3618,27 +3713,39 @@ function getModelCapabilities(modelId) {
|
|
|
3618
3713
|
maxOutputTokens: 32e3,
|
|
3619
3714
|
supportsStructuredOutput: false,
|
|
3620
3715
|
rejectsSamplingParameters: false,
|
|
3716
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3621
3717
|
isKnownModel: true
|
|
3622
3718
|
};
|
|
3623
|
-
} else if (modelId.includes("claude-3-
|
|
3719
|
+
} else if (modelId.includes("claude-3-haiku")) {
|
|
3624
3720
|
return {
|
|
3625
|
-
maxOutputTokens:
|
|
3721
|
+
maxOutputTokens: 4096,
|
|
3626
3722
|
supportsStructuredOutput: false,
|
|
3627
3723
|
rejectsSamplingParameters: false,
|
|
3724
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3628
3725
|
isKnownModel: true
|
|
3629
3726
|
};
|
|
3630
|
-
} else if (
|
|
3727
|
+
} else if (/claude-(?:instant(?:-|$)|v?2(?=$|[-.:])|3(?=$|[-.]))/.test(modelId)) {
|
|
3631
3728
|
return {
|
|
3632
3729
|
maxOutputTokens: 4096,
|
|
3633
3730
|
supportsStructuredOutput: false,
|
|
3634
3731
|
rejectsSamplingParameters: false,
|
|
3635
|
-
|
|
3732
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3733
|
+
isKnownModel: false
|
|
3734
|
+
};
|
|
3735
|
+
} else if (modelId.includes("claude-")) {
|
|
3736
|
+
return {
|
|
3737
|
+
maxOutputTokens: 128e3,
|
|
3738
|
+
supportsStructuredOutput: true,
|
|
3739
|
+
rejectsSamplingParameters: true,
|
|
3740
|
+
rejectsThinkingDisabledAboveHighEffort: true,
|
|
3741
|
+
isKnownModel: false
|
|
3636
3742
|
};
|
|
3637
3743
|
} else {
|
|
3638
3744
|
return {
|
|
3639
3745
|
maxOutputTokens: 4096,
|
|
3640
3746
|
supportsStructuredOutput: false,
|
|
3641
3747
|
rejectsSamplingParameters: false,
|
|
3748
|
+
rejectsThinkingDisabledAboveHighEffort: false,
|
|
3642
3749
|
isKnownModel: false
|
|
3643
3750
|
};
|
|
3644
3751
|
}
|