@ai-sdk/anthropic 2.0.31 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.32
4
+
5
+ ### Patch Changes
6
+
7
+ - 492b1ee: feat(provider/anthropic): add support for Agent Skills
8
+
3
9
  ## 2.0.31
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -6,7 +6,7 @@ The **[Anthropic provider](https://ai-sdk.dev/providers/ai-sdk-providers/anthrop
6
6
 
7
7
  The Anthropic provider is available in the `@ai-sdk/anthropic` module. You can install it with
8
8
 
9
- ```
9
+ ```bash
10
10
  npm i @ai-sdk/anthropic
11
11
  ```
12
12
 
package/dist/index.d.mts CHANGED
@@ -15,6 +15,14 @@ declare const anthropicProviderOptions: z.ZodObject<{
15
15
  type: z.ZodLiteral<"ephemeral">;
16
16
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
17
17
  }, z.core.$strip>>;
18
+ container: z.ZodOptional<z.ZodObject<{
19
+ id: z.ZodOptional<z.ZodString>;
20
+ skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
21
+ type: z.ZodUnion<readonly [z.ZodLiteral<"anthropic">, z.ZodLiteral<"custom">]>;
22
+ skillId: z.ZodString;
23
+ version: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>>>;
25
+ }, z.core.$strip>>;
18
26
  }, z.core.$strip>;
19
27
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
20
28
 
package/dist/index.d.ts CHANGED
@@ -15,6 +15,14 @@ declare const anthropicProviderOptions: z.ZodObject<{
15
15
  type: z.ZodLiteral<"ephemeral">;
16
16
  ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
17
17
  }, z.core.$strip>>;
18
+ container: z.ZodOptional<z.ZodObject<{
19
+ id: z.ZodOptional<z.ZodString>;
20
+ skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
21
+ type: z.ZodUnion<readonly [z.ZodLiteral<"anthropic">, z.ZodLiteral<"custom">]>;
22
+ skillId: z.ZodString;
23
+ version: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>>>;
25
+ }, z.core.$strip>>;
18
26
  }, z.core.$strip>;
19
27
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
20
28
 
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.31" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.32" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -543,6 +543,21 @@ var anthropicProviderOptions = import_v43.z.object({
543
543
  cacheControl: import_v43.z.object({
544
544
  type: import_v43.z.literal("ephemeral"),
545
545
  ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
546
+ }).optional(),
547
+ /**
548
+ * Agent Skills configuration. Skills enable Claude to perform specialized tasks
549
+ * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
550
+ * Requires code execution tool to be enabled.
551
+ */
552
+ container: import_v43.z.object({
553
+ id: import_v43.z.string().optional(),
554
+ skills: import_v43.z.array(
555
+ import_v43.z.object({
556
+ type: import_v43.z.union([import_v43.z.literal("anthropic"), import_v43.z.literal("custom")]),
557
+ skillId: import_v43.z.string(),
558
+ version: import_v43.z.string().optional()
559
+ })
560
+ ).optional()
546
561
  }).optional()
547
562
  });
548
563
 
@@ -1649,7 +1664,7 @@ var AnthropicMessagesLanguageModel = class {
1649
1664
  toolChoice,
1650
1665
  providerOptions
1651
1666
  }) {
1652
- var _a, _b, _c;
1667
+ var _a, _b, _c, _d;
1653
1668
  const warnings = [];
1654
1669
  if (frequencyPenalty != null) {
1655
1670
  warnings.push({
@@ -1695,7 +1710,7 @@ var AnthropicMessagesLanguageModel = class {
1695
1710
  providerOptions,
1696
1711
  schema: anthropicProviderOptions
1697
1712
  });
1698
- const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
1713
+ const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
1699
1714
  prompt,
1700
1715
  sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
1701
1716
  warnings
@@ -1717,6 +1732,17 @@ var AnthropicMessagesLanguageModel = class {
1717
1732
  ...isThinking && {
1718
1733
  thinking: { type: "enabled", budget_tokens: thinkingBudget }
1719
1734
  },
1735
+ // container with agent skills:
1736
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
1737
+ container: {
1738
+ id: anthropicOptions.container.id,
1739
+ skills: (_d = anthropicOptions.container.skills) == null ? void 0 : _d.map((skill) => ({
1740
+ type: skill.type,
1741
+ skill_id: skill.skillId,
1742
+ version: skill.version
1743
+ }))
1744
+ }
1745
+ },
1720
1746
  // prompt:
1721
1747
  system: messagesPrompt.system,
1722
1748
  messages: messagesPrompt.messages
@@ -1758,11 +1784,24 @@ var AnthropicMessagesLanguageModel = class {
1758
1784
  warnings.push({
1759
1785
  type: "unsupported-setting",
1760
1786
  setting: "maxOutputTokens",
1761
- details: `${maxTokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${maxOutputTokensForModel} max output tokens. The max output tokens have been limited to ${maxOutputTokensForModel}.`
1787
+ details: `${baseArgs.max_tokens} (maxOutputTokens + thinkingBudget) is greater than ${this.modelId} ${maxOutputTokensForModel} max output tokens. The max output tokens have been limited to ${maxOutputTokensForModel}.`
1762
1788
  });
1763
1789
  }
1764
1790
  baseArgs.max_tokens = maxOutputTokensForModel;
1765
1791
  }
1792
+ if ((anthropicOptions == null ? void 0 : anthropicOptions.container) && anthropicOptions.container.skills && anthropicOptions.container.skills.length > 0) {
1793
+ betas.add("code-execution-2025-08-25");
1794
+ betas.add("skills-2025-10-02");
1795
+ betas.add("files-api-2025-04-14");
1796
+ if (!(tools == null ? void 0 : tools.some(
1797
+ (tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
1798
+ ))) {
1799
+ warnings.push({
1800
+ type: "other",
1801
+ message: "code execution tool is required when using skills"
1802
+ });
1803
+ }
1804
+ }
1766
1805
  const {
1767
1806
  tools: anthropicTools2,
1768
1807
  toolChoice: anthropicToolChoice,
@@ -1786,7 +1825,7 @@ var AnthropicMessagesLanguageModel = class {
1786
1825
  tool_choice: anthropicToolChoice
1787
1826
  },
1788
1827
  warnings: [...warnings, ...toolWarnings],
1789
- betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
1828
+ betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
1790
1829
  usesJsonResponseTool: jsonResponseTool != null
1791
1830
  };
1792
1831
  }