@ai-sdk/anthropic 2.0.30 → 2.0.32
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 +12 -0
- package/README.md +1 -1
- package/dist/index.d.mts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +69 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +68 -7
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +68 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -536,6 +536,21 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
536
536
|
cacheControl: import_v43.z.object({
|
|
537
537
|
type: import_v43.z.literal("ephemeral"),
|
|
538
538
|
ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
|
|
539
|
+
}).optional(),
|
|
540
|
+
/**
|
|
541
|
+
* Agent Skills configuration. Skills enable Claude to perform specialized tasks
|
|
542
|
+
* like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
|
|
543
|
+
* Requires code execution tool to be enabled.
|
|
544
|
+
*/
|
|
545
|
+
container: import_v43.z.object({
|
|
546
|
+
id: import_v43.z.string().optional(),
|
|
547
|
+
skills: import_v43.z.array(
|
|
548
|
+
import_v43.z.object({
|
|
549
|
+
type: import_v43.z.union([import_v43.z.literal("anthropic"), import_v43.z.literal("custom")]),
|
|
550
|
+
skillId: import_v43.z.string(),
|
|
551
|
+
version: import_v43.z.string().optional()
|
|
552
|
+
})
|
|
553
|
+
).optional()
|
|
539
554
|
}).optional()
|
|
540
555
|
});
|
|
541
556
|
|
|
@@ -1629,8 +1644,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1629
1644
|
}
|
|
1630
1645
|
async getArgs({
|
|
1631
1646
|
prompt,
|
|
1632
|
-
maxOutputTokens
|
|
1633
|
-
// 4096: max model output tokens TODO update default in v5
|
|
1647
|
+
maxOutputTokens,
|
|
1634
1648
|
temperature,
|
|
1635
1649
|
topP,
|
|
1636
1650
|
topK,
|
|
@@ -1643,7 +1657,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1643
1657
|
toolChoice,
|
|
1644
1658
|
providerOptions
|
|
1645
1659
|
}) {
|
|
1646
|
-
var _a, _b, _c;
|
|
1660
|
+
var _a, _b, _c, _d;
|
|
1647
1661
|
const warnings = [];
|
|
1648
1662
|
if (frequencyPenalty != null) {
|
|
1649
1663
|
warnings.push({
|
|
@@ -1689,18 +1703,20 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1689
1703
|
providerOptions,
|
|
1690
1704
|
schema: anthropicProviderOptions
|
|
1691
1705
|
});
|
|
1692
|
-
const { prompt: messagesPrompt, betas
|
|
1706
|
+
const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
|
|
1693
1707
|
prompt,
|
|
1694
1708
|
sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
|
|
1695
1709
|
warnings
|
|
1696
1710
|
});
|
|
1697
1711
|
const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
|
|
1698
1712
|
const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
|
|
1713
|
+
const maxOutputTokensForModel = getMaxOutputTokensForModel(this.modelId);
|
|
1714
|
+
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
1699
1715
|
const baseArgs = {
|
|
1700
1716
|
// model id:
|
|
1701
1717
|
model: this.modelId,
|
|
1702
1718
|
// standardized settings:
|
|
1703
|
-
max_tokens:
|
|
1719
|
+
max_tokens: maxTokens,
|
|
1704
1720
|
temperature,
|
|
1705
1721
|
top_k: topK,
|
|
1706
1722
|
top_p: topP,
|
|
@@ -1709,6 +1725,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1709
1725
|
...isThinking && {
|
|
1710
1726
|
thinking: { type: "enabled", budget_tokens: thinkingBudget }
|
|
1711
1727
|
},
|
|
1728
|
+
// container with agent skills:
|
|
1729
|
+
...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
|
|
1730
|
+
container: {
|
|
1731
|
+
id: anthropicOptions.container.id,
|
|
1732
|
+
skills: (_d = anthropicOptions.container.skills) == null ? void 0 : _d.map((skill) => ({
|
|
1733
|
+
type: skill.type,
|
|
1734
|
+
skill_id: skill.skillId,
|
|
1735
|
+
version: skill.version
|
|
1736
|
+
}))
|
|
1737
|
+
}
|
|
1738
|
+
},
|
|
1712
1739
|
// prompt:
|
|
1713
1740
|
system: messagesPrompt.system,
|
|
1714
1741
|
messages: messagesPrompt.messages
|
|
@@ -1743,7 +1770,30 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1743
1770
|
details: "topP is not supported when thinking is enabled"
|
|
1744
1771
|
});
|
|
1745
1772
|
}
|
|
1746
|
-
baseArgs.max_tokens =
|
|
1773
|
+
baseArgs.max_tokens = maxTokens + thinkingBudget;
|
|
1774
|
+
}
|
|
1775
|
+
if (baseArgs.max_tokens > maxOutputTokensForModel) {
|
|
1776
|
+
if (maxOutputTokens != null) {
|
|
1777
|
+
warnings.push({
|
|
1778
|
+
type: "unsupported-setting",
|
|
1779
|
+
setting: "maxOutputTokens",
|
|
1780
|
+
details: `${baseArgs.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${maxOutputTokensForModel} max output tokens. The max output tokens have been limited to ${maxOutputTokensForModel}.`
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
baseArgs.max_tokens = maxOutputTokensForModel;
|
|
1784
|
+
}
|
|
1785
|
+
if ((anthropicOptions == null ? void 0 : anthropicOptions.container) && anthropicOptions.container.skills && anthropicOptions.container.skills.length > 0) {
|
|
1786
|
+
betas.add("code-execution-2025-08-25");
|
|
1787
|
+
betas.add("skills-2025-10-02");
|
|
1788
|
+
betas.add("files-api-2025-04-14");
|
|
1789
|
+
if (!(tools == null ? void 0 : tools.some(
|
|
1790
|
+
(tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
|
|
1791
|
+
))) {
|
|
1792
|
+
warnings.push({
|
|
1793
|
+
type: "other",
|
|
1794
|
+
message: "code execution tool is required when using skills"
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1747
1797
|
}
|
|
1748
1798
|
const {
|
|
1749
1799
|
tools: anthropicTools2,
|
|
@@ -1768,7 +1818,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1768
1818
|
tool_choice: anthropicToolChoice
|
|
1769
1819
|
},
|
|
1770
1820
|
warnings: [...warnings, ...toolWarnings],
|
|
1771
|
-
betas: /* @__PURE__ */ new Set([...
|
|
1821
|
+
betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
|
|
1772
1822
|
usesJsonResponseTool: jsonResponseTool != null
|
|
1773
1823
|
};
|
|
1774
1824
|
}
|
|
@@ -2523,6 +2573,17 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2523
2573
|
};
|
|
2524
2574
|
}
|
|
2525
2575
|
};
|
|
2576
|
+
function getMaxOutputTokensForModel(modelId) {
|
|
2577
|
+
if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
|
|
2578
|
+
return 64e3;
|
|
2579
|
+
} else if (modelId.includes("claude-opus-4-")) {
|
|
2580
|
+
return 32e3;
|
|
2581
|
+
} else if (modelId.includes("claude-3-5-haiku")) {
|
|
2582
|
+
return 8192;
|
|
2583
|
+
} else {
|
|
2584
|
+
return 4096;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2526
2587
|
|
|
2527
2588
|
// src/tool/bash_20241022.ts
|
|
2528
2589
|
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|