@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.
@@ -570,7 +570,22 @@ var anthropicProviderOptions = z3.object({
570
570
  allowedTools: z3.array(z3.string()).nullish()
571
571
  }).nullish()
572
572
  })
573
- ).optional()
573
+ ).optional(),
574
+ /**
575
+ * Agent Skills configuration. Skills enable Claude to perform specialized tasks
576
+ * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
577
+ * Requires code execution tool to be enabled.
578
+ */
579
+ container: z3.object({
580
+ id: z3.string().optional(),
581
+ skills: z3.array(
582
+ z3.object({
583
+ type: z3.union([z3.literal("anthropic"), z3.literal("custom")]),
584
+ skillId: z3.string(),
585
+ version: z3.string().optional()
586
+ })
587
+ ).optional()
588
+ }).optional()
574
589
  });
575
590
 
576
591
  // src/anthropic-prepare-tools.ts
@@ -963,7 +978,8 @@ import {
963
978
  import {
964
979
  convertToBase64,
965
980
  parseProviderOptions,
966
- validateTypes as validateTypes2
981
+ validateTypes as validateTypes2,
982
+ isNonNullable
967
983
  } from "@ai-sdk/provider-utils";
968
984
 
969
985
  // src/tool/code-execution_20250522.ts
@@ -1266,20 +1282,20 @@ async function convertToAnthropicMessagesPrompt({
1266
1282
  return {
1267
1283
  type: "text",
1268
1284
  text: contentPart.text,
1269
- cache_control: void 0
1285
+ cache_control: cacheControl
1270
1286
  };
1271
- case "media": {
1272
- if (contentPart.mediaType.startsWith("image/")) {
1273
- return {
1274
- type: "image",
1275
- source: {
1276
- type: "base64",
1277
- media_type: contentPart.mediaType,
1278
- data: contentPart.data
1279
- },
1280
- cache_control: void 0
1281
- };
1282
- }
1287
+ case "image-data": {
1288
+ return {
1289
+ type: "image",
1290
+ source: {
1291
+ type: "base64",
1292
+ media_type: contentPart.mediaType,
1293
+ data: contentPart.data
1294
+ },
1295
+ cache_control: cacheControl
1296
+ };
1297
+ }
1298
+ case "file-data": {
1283
1299
  if (contentPart.mediaType === "application/pdf") {
1284
1300
  betas.add("pdfs-2024-09-25");
1285
1301
  return {
@@ -1289,15 +1305,24 @@ async function convertToAnthropicMessagesPrompt({
1289
1305
  media_type: contentPart.mediaType,
1290
1306
  data: contentPart.data
1291
1307
  },
1292
- cache_control: void 0
1308
+ cache_control: cacheControl
1293
1309
  };
1294
1310
  }
1295
- throw new UnsupportedFunctionalityError2({
1296
- functionality: `media type: ${contentPart.mediaType}`
1311
+ warnings.push({
1312
+ type: "other",
1313
+ message: `unsupported tool content part type: ${contentPart.type} with media type: ${contentPart.mediaType}`
1314
+ });
1315
+ return void 0;
1316
+ }
1317
+ default: {
1318
+ warnings.push({
1319
+ type: "other",
1320
+ message: `unsupported tool content part type: ${contentPart.type}`
1297
1321
  });
1322
+ return void 0;
1298
1323
  }
1299
1324
  }
1300
- });
1325
+ }).filter(isNonNullable);
1301
1326
  break;
1302
1327
  case "text":
1303
1328
  case "error-text":
@@ -1742,7 +1767,7 @@ var AnthropicMessagesLanguageModel = class {
1742
1767
  toolChoice,
1743
1768
  providerOptions
1744
1769
  }) {
1745
- var _a, _b, _c;
1770
+ var _a, _b, _c, _d;
1746
1771
  const warnings = [];
1747
1772
  if (frequencyPenalty != null) {
1748
1773
  warnings.push({
@@ -1823,6 +1848,17 @@ var AnthropicMessagesLanguageModel = class {
1823
1848
  } : void 0
1824
1849
  }))
1825
1850
  },
1851
+ // container with agent skills:
1852
+ ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
1853
+ container: {
1854
+ id: anthropicOptions.container.id,
1855
+ skills: (_d = anthropicOptions.container.skills) == null ? void 0 : _d.map((skill) => ({
1856
+ type: skill.type,
1857
+ skill_id: skill.skillId,
1858
+ version: skill.version
1859
+ }))
1860
+ }
1861
+ },
1826
1862
  // prompt:
1827
1863
  system: messagesPrompt.system,
1828
1864
  messages: messagesPrompt.messages
@@ -1872,6 +1908,19 @@ var AnthropicMessagesLanguageModel = class {
1872
1908
  if ((anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0) {
1873
1909
  betas.add("mcp-client-2025-04-04");
1874
1910
  }
1911
+ if ((anthropicOptions == null ? void 0 : anthropicOptions.container) && anthropicOptions.container.skills && anthropicOptions.container.skills.length > 0) {
1912
+ betas.add("code-execution-2025-08-25");
1913
+ betas.add("skills-2025-10-02");
1914
+ betas.add("files-api-2025-04-14");
1915
+ if (!(tools == null ? void 0 : tools.some(
1916
+ (tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
1917
+ ))) {
1918
+ warnings.push({
1919
+ type: "other",
1920
+ message: "code execution tool is required when using skills"
1921
+ });
1922
+ }
1923
+ }
1875
1924
  const {
1876
1925
  tools: anthropicTools2,
1877
1926
  toolChoice: anthropicToolChoice,