@ai-sdk/anthropic 3.0.0-beta.28 → 3.0.0-beta.30

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,20 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 3.0.0-beta.30
4
+
5
+ ### Patch Changes
6
+
7
+ - 9354297: feat(provider/anthropic): add support for Agent Skills
8
+
9
+ ## 3.0.0-beta.29
10
+
11
+ ### Patch Changes
12
+
13
+ - 3794514: feat: flexible tool output content support
14
+ - Updated dependencies [3794514]
15
+ - @ai-sdk/provider-utils@4.0.0-beta.19
16
+ - @ai-sdk/provider@3.0.0-beta.8
17
+
3
18
  ## 3.0.0-beta.28
4
19
 
5
20
  ### 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
@@ -25,6 +25,14 @@ declare const anthropicProviderOptions: z.ZodObject<{
25
25
  allowedTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
26
26
  }, z.core.$strip>>>;
27
27
  }, z.core.$strip>>>;
28
+ container: z.ZodOptional<z.ZodObject<{
29
+ id: z.ZodOptional<z.ZodString>;
30
+ skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
31
+ type: z.ZodUnion<readonly [z.ZodLiteral<"anthropic">, z.ZodLiteral<"custom">]>;
32
+ skillId: z.ZodString;
33
+ version: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>>>;
35
+ }, z.core.$strip>>;
28
36
  }, z.core.$strip>;
29
37
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
30
38
 
package/dist/index.d.ts CHANGED
@@ -25,6 +25,14 @@ declare const anthropicProviderOptions: z.ZodObject<{
25
25
  allowedTools: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
26
26
  }, z.core.$strip>>>;
27
27
  }, z.core.$strip>>>;
28
+ container: z.ZodOptional<z.ZodObject<{
29
+ id: z.ZodOptional<z.ZodString>;
30
+ skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
31
+ type: z.ZodUnion<readonly [z.ZodLiteral<"anthropic">, z.ZodLiteral<"custom">]>;
32
+ skillId: z.ZodString;
33
+ version: z.ZodOptional<z.ZodString>;
34
+ }, z.core.$strip>>>;
35
+ }, z.core.$strip>>;
28
36
  }, z.core.$strip>;
29
37
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
30
38
 
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 ? "3.0.0-beta.28" : "0.0.0-test";
34
+ var VERSION = true ? "3.0.0-beta.30" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -591,7 +591,22 @@ var anthropicProviderOptions = import_v43.z.object({
591
591
  allowedTools: import_v43.z.array(import_v43.z.string()).nullish()
592
592
  }).nullish()
593
593
  })
594
- ).optional()
594
+ ).optional(),
595
+ /**
596
+ * Agent Skills configuration. Skills enable Claude to perform specialized tasks
597
+ * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
598
+ * Requires code execution tool to be enabled.
599
+ */
600
+ container: import_v43.z.object({
601
+ id: import_v43.z.string().optional(),
602
+ skills: import_v43.z.array(
603
+ import_v43.z.object({
604
+ type: import_v43.z.union([import_v43.z.literal("anthropic"), import_v43.z.literal("custom")]),
605
+ skillId: import_v43.z.string(),
606
+ version: import_v43.z.string().optional()
607
+ })
608
+ ).optional()
609
+ }).optional()
595
610
  });
596
611
 
597
612
  // src/anthropic-prepare-tools.ts
@@ -1263,20 +1278,20 @@ async function convertToAnthropicMessagesPrompt({
1263
1278
  return {
1264
1279
  type: "text",
1265
1280
  text: contentPart.text,
1266
- cache_control: void 0
1281
+ cache_control: cacheControl
1267
1282
  };
1268
- case "media": {
1269
- if (contentPart.mediaType.startsWith("image/")) {
1270
- return {
1271
- type: "image",
1272
- source: {
1273
- type: "base64",
1274
- media_type: contentPart.mediaType,
1275
- data: contentPart.data
1276
- },
1277
- cache_control: void 0
1278
- };
1279
- }
1283
+ case "image-data": {
1284
+ return {
1285
+ type: "image",
1286
+ source: {
1287
+ type: "base64",
1288
+ media_type: contentPart.mediaType,
1289
+ data: contentPart.data
1290
+ },
1291
+ cache_control: cacheControl
1292
+ };
1293
+ }
1294
+ case "file-data": {
1280
1295
  if (contentPart.mediaType === "application/pdf") {
1281
1296
  betas.add("pdfs-2024-09-25");
1282
1297
  return {
@@ -1286,15 +1301,24 @@ async function convertToAnthropicMessagesPrompt({
1286
1301
  media_type: contentPart.mediaType,
1287
1302
  data: contentPart.data
1288
1303
  },
1289
- cache_control: void 0
1304
+ cache_control: cacheControl
1290
1305
  };
1291
1306
  }
1292
- throw new import_provider2.UnsupportedFunctionalityError({
1293
- functionality: `media type: ${contentPart.mediaType}`
1307
+ warnings.push({
1308
+ type: "other",
1309
+ message: `unsupported tool content part type: ${contentPart.type} with media type: ${contentPart.mediaType}`
1310
+ });
1311
+ return void 0;
1312
+ }
1313
+ default: {
1314
+ warnings.push({
1315
+ type: "other",
1316
+ message: `unsupported tool content part type: ${contentPart.type}`
1294
1317
  });
1318
+ return void 0;
1295
1319
  }
1296
1320
  }
1297
- });
1321
+ }).filter(import_provider_utils10.isNonNullable);
1298
1322
  break;
1299
1323
  case "text":
1300
1324
  case "error-text":
@@ -1739,7 +1763,7 @@ var AnthropicMessagesLanguageModel = class {
1739
1763
  toolChoice,
1740
1764
  providerOptions
1741
1765
  }) {
1742
- var _a, _b, _c;
1766
+ var _a, _b, _c, _d;
1743
1767
  const warnings = [];
1744
1768
  if (frequencyPenalty != null) {
1745
1769
  warnings.push({
@@ -1820,6 +1844,17 @@ var AnthropicMessagesLanguageModel = class {
1820
1844
  } : void 0
1821
1845
  }))
1822
1846
  },
1847
+ // container with agent skills:
1848
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
1849
+ container: {
1850
+ id: anthropicOptions.container.id,
1851
+ skills: (_d = anthropicOptions.container.skills) == null ? void 0 : _d.map((skill) => ({
1852
+ type: skill.type,
1853
+ skill_id: skill.skillId,
1854
+ version: skill.version
1855
+ }))
1856
+ }
1857
+ },
1823
1858
  // prompt:
1824
1859
  system: messagesPrompt.system,
1825
1860
  messages: messagesPrompt.messages
@@ -1869,6 +1904,19 @@ var AnthropicMessagesLanguageModel = class {
1869
1904
  if ((anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0) {
1870
1905
  betas.add("mcp-client-2025-04-04");
1871
1906
  }
1907
+ if ((anthropicOptions == null ? void 0 : anthropicOptions.container) && anthropicOptions.container.skills && anthropicOptions.container.skills.length > 0) {
1908
+ betas.add("code-execution-2025-08-25");
1909
+ betas.add("skills-2025-10-02");
1910
+ betas.add("files-api-2025-04-14");
1911
+ if (!(tools == null ? void 0 : tools.some(
1912
+ (tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
1913
+ ))) {
1914
+ warnings.push({
1915
+ type: "other",
1916
+ message: "code execution tool is required when using skills"
1917
+ });
1918
+ }
1919
+ }
1872
1920
  const {
1873
1921
  tools: anthropicTools2,
1874
1922
  toolChoice: anthropicToolChoice,