@ai-sdk/anthropic 2.0.78 → 2.0.80

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.
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/anthropic-messages-language-model.ts
30
30
  var import_provider3 = require("@ai-sdk/provider");
31
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/anthropic-error.ts
34
34
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -838,16 +838,15 @@ var CacheControlValidator = class {
838
838
  // src/tool/text-editor_20250728.ts
839
839
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
840
840
  var import_v44 = require("zod/v4");
841
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
842
- var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
843
- () => (0, import_provider_utils4.zodSchema)(
841
+ var textEditor_20250728ArgsSchema = (0, import_provider_utils3.lazySchema)(
842
+ () => (0, import_provider_utils3.zodSchema)(
844
843
  import_v44.z.object({
845
844
  maxCharacters: import_v44.z.number().optional()
846
845
  })
847
846
  )
848
847
  );
849
- var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
850
- () => (0, import_provider_utils4.zodSchema)(
848
+ var textEditor_20250728InputSchema = (0, import_provider_utils3.lazySchema)(
849
+ () => (0, import_provider_utils3.zodSchema)(
851
850
  import_v44.z.object({
852
851
  command: import_v44.z.enum(["view", "create", "str_replace", "insert"]),
853
852
  path: import_v44.z.string(),
@@ -869,10 +868,10 @@ var textEditor_20250728 = (args = {}) => {
869
868
  };
870
869
 
871
870
  // src/tool/web-search_20250305.ts
872
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
871
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
873
872
  var import_v45 = require("zod/v4");
874
- var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
875
- () => (0, import_provider_utils5.zodSchema)(
873
+ var webSearch_20250305ArgsSchema = (0, import_provider_utils4.lazySchema)(
874
+ () => (0, import_provider_utils4.zodSchema)(
876
875
  import_v45.z.object({
877
876
  maxUses: import_v45.z.number().optional(),
878
877
  allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
@@ -887,8 +886,8 @@ var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
887
886
  })
888
887
  )
889
888
  );
890
- var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
891
- () => (0, import_provider_utils5.zodSchema)(
889
+ var webSearch_20250305OutputSchema = (0, import_provider_utils4.lazySchema)(
890
+ () => (0, import_provider_utils4.zodSchema)(
892
891
  import_v45.z.array(
893
892
  import_v45.z.object({
894
893
  url: import_v45.z.string(),
@@ -900,14 +899,14 @@ var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
900
899
  )
901
900
  )
902
901
  );
903
- var webSearch_20250305InputSchema = (0, import_provider_utils5.lazySchema)(
904
- () => (0, import_provider_utils5.zodSchema)(
902
+ var webSearch_20250305InputSchema = (0, import_provider_utils4.lazySchema)(
903
+ () => (0, import_provider_utils4.zodSchema)(
905
904
  import_v45.z.object({
906
905
  query: import_v45.z.string()
907
906
  })
908
907
  )
909
908
  );
910
- var factory2 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
909
+ var factory2 = (0, import_provider_utils4.createProviderDefinedToolFactoryWithOutputSchema)({
911
910
  id: "anthropic.web_search_20250305",
912
911
  name: "web_search",
913
912
  inputSchema: webSearch_20250305InputSchema,
@@ -918,10 +917,10 @@ var webSearch_20250305 = (args = {}) => {
918
917
  };
919
918
 
920
919
  // src/tool/web-fetch-20250910.ts
921
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
920
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
922
921
  var import_v46 = require("zod/v4");
923
- var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
924
- () => (0, import_provider_utils6.zodSchema)(
922
+ var webFetch_20250910ArgsSchema = (0, import_provider_utils5.lazySchema)(
923
+ () => (0, import_provider_utils5.zodSchema)(
925
924
  import_v46.z.object({
926
925
  maxUses: import_v46.z.number().optional(),
927
926
  allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
@@ -931,8 +930,8 @@ var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
931
930
  })
932
931
  )
933
932
  );
934
- var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
935
- () => (0, import_provider_utils6.zodSchema)(
933
+ var webFetch_20250910OutputSchema = (0, import_provider_utils5.lazySchema)(
934
+ () => (0, import_provider_utils5.zodSchema)(
936
935
  import_v46.z.object({
937
936
  type: import_v46.z.literal("web_fetch_result"),
938
937
  url: import_v46.z.string(),
@@ -957,14 +956,14 @@ var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
957
956
  })
958
957
  )
959
958
  );
960
- var webFetch_20250910InputSchema = (0, import_provider_utils6.lazySchema)(
961
- () => (0, import_provider_utils6.zodSchema)(
959
+ var webFetch_20250910InputSchema = (0, import_provider_utils5.lazySchema)(
960
+ () => (0, import_provider_utils5.zodSchema)(
962
961
  import_v46.z.object({
963
962
  url: import_v46.z.string()
964
963
  })
965
964
  )
966
965
  );
967
- var factory3 = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
966
+ var factory3 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
968
967
  id: "anthropic.web_fetch_20250910",
969
968
  name: "web_fetch",
970
969
  inputSchema: webFetch_20250910InputSchema,
@@ -975,7 +974,7 @@ var webFetch_20250910 = (args = {}) => {
975
974
  };
976
975
 
977
976
  // src/anthropic-prepare-tools.ts
978
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
977
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
979
978
  async function prepareTools({
980
979
  tools,
981
980
  toolChoice,
@@ -1087,7 +1086,7 @@ async function prepareTools({
1087
1086
  break;
1088
1087
  }
1089
1088
  case "anthropic.text_editor_20250728": {
1090
- const args = await (0, import_provider_utils7.validateTypes)({
1089
+ const args = await (0, import_provider_utils6.validateTypes)({
1091
1090
  value: tool.args,
1092
1091
  schema: textEditor_20250728ArgsSchema
1093
1092
  });
@@ -1127,7 +1126,7 @@ async function prepareTools({
1127
1126
  }
1128
1127
  case "anthropic.web_fetch_20250910": {
1129
1128
  betas.add("web-fetch-2025-09-10");
1130
- const args = await (0, import_provider_utils7.validateTypes)({
1129
+ const args = await (0, import_provider_utils6.validateTypes)({
1131
1130
  value: tool.args,
1132
1131
  schema: webFetch_20250910ArgsSchema
1133
1132
  });
@@ -1144,7 +1143,7 @@ async function prepareTools({
1144
1143
  break;
1145
1144
  }
1146
1145
  case "anthropic.web_search_20250305": {
1147
- const args = await (0, import_provider_utils7.validateTypes)({
1146
+ const args = await (0, import_provider_utils6.validateTypes)({
1148
1147
  value: tool.args,
1149
1148
  schema: webSearch_20250305ArgsSchema
1150
1149
  });
@@ -1226,13 +1225,13 @@ async function prepareTools({
1226
1225
 
1227
1226
  // src/convert-to-anthropic-messages-prompt.ts
1228
1227
  var import_provider2 = require("@ai-sdk/provider");
1229
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1228
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1230
1229
 
1231
1230
  // src/tool/code-execution_20250522.ts
1232
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1231
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1233
1232
  var import_v47 = require("zod/v4");
1234
- var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
1235
- () => (0, import_provider_utils8.zodSchema)(
1233
+ var codeExecution_20250522OutputSchema = (0, import_provider_utils7.lazySchema)(
1234
+ () => (0, import_provider_utils7.zodSchema)(
1236
1235
  import_v47.z.object({
1237
1236
  type: import_v47.z.literal("code_execution_result"),
1238
1237
  stdout: import_v47.z.string(),
@@ -1241,14 +1240,14 @@ var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
1241
1240
  })
1242
1241
  )
1243
1242
  );
1244
- var codeExecution_20250522InputSchema = (0, import_provider_utils8.lazySchema)(
1245
- () => (0, import_provider_utils8.zodSchema)(
1243
+ var codeExecution_20250522InputSchema = (0, import_provider_utils7.lazySchema)(
1244
+ () => (0, import_provider_utils7.zodSchema)(
1246
1245
  import_v47.z.object({
1247
1246
  code: import_v47.z.string()
1248
1247
  })
1249
1248
  )
1250
1249
  );
1251
- var factory4 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
1250
+ var factory4 = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1252
1251
  id: "anthropic.code_execution_20250522",
1253
1252
  name: "code_execution",
1254
1253
  inputSchema: codeExecution_20250522InputSchema,
@@ -1259,10 +1258,10 @@ var codeExecution_20250522 = (args = {}) => {
1259
1258
  };
1260
1259
 
1261
1260
  // src/tool/code-execution_20250825.ts
1262
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1261
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1263
1262
  var import_v48 = require("zod/v4");
1264
- var codeExecution_20250825OutputSchema = (0, import_provider_utils9.lazySchema)(
1265
- () => (0, import_provider_utils9.zodSchema)(
1263
+ var codeExecution_20250825OutputSchema = (0, import_provider_utils8.lazySchema)(
1264
+ () => (0, import_provider_utils8.zodSchema)(
1266
1265
  import_v48.z.discriminatedUnion("type", [
1267
1266
  import_v48.z.object({
1268
1267
  type: import_v48.z.literal("bash_code_execution_result"),
@@ -1307,8 +1306,8 @@ var codeExecution_20250825OutputSchema = (0, import_provider_utils9.lazySchema)(
1307
1306
  ])
1308
1307
  )
1309
1308
  );
1310
- var codeExecution_20250825InputSchema = (0, import_provider_utils9.lazySchema)(
1311
- () => (0, import_provider_utils9.zodSchema)(
1309
+ var codeExecution_20250825InputSchema = (0, import_provider_utils8.lazySchema)(
1310
+ () => (0, import_provider_utils8.zodSchema)(
1312
1311
  import_v48.z.discriminatedUnion("type", [
1313
1312
  import_v48.z.object({
1314
1313
  type: import_v48.z.literal("bash_code_execution"),
@@ -1337,7 +1336,7 @@ var codeExecution_20250825InputSchema = (0, import_provider_utils9.lazySchema)(
1337
1336
  ])
1338
1337
  )
1339
1338
  );
1340
- var factory5 = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
1339
+ var factory5 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
1341
1340
  id: "anthropic.code_execution_20250825",
1342
1341
  name: "code_execution",
1343
1342
  inputSchema: codeExecution_20250825InputSchema,
@@ -1378,7 +1377,7 @@ async function convertToAnthropicMessagesPrompt({
1378
1377
  const messages = [];
1379
1378
  async function shouldEnableCitations(providerMetadata) {
1380
1379
  var _a2, _b2;
1381
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1380
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1382
1381
  provider: "anthropic",
1383
1382
  providerOptions: providerMetadata,
1384
1383
  schema: anthropicFilePartProviderOptions
@@ -1386,7 +1385,7 @@ async function convertToAnthropicMessagesPrompt({
1386
1385
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1387
1386
  }
1388
1387
  async function getDocumentMetadata(providerMetadata) {
1389
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1388
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1390
1389
  provider: "anthropic",
1391
1390
  providerOptions: providerMetadata,
1392
1391
  schema: anthropicFilePartProviderOptions
@@ -1402,19 +1401,20 @@ async function convertToAnthropicMessagesPrompt({
1402
1401
  const type = block.type;
1403
1402
  switch (type) {
1404
1403
  case "system": {
1405
- if (system != null) {
1406
- throw new import_provider2.UnsupportedFunctionalityError({
1407
- functionality: "Multiple system messages that are separated by user/assistant messages"
1408
- });
1409
- }
1410
- system = block.messages.map(({ content, providerOptions }) => ({
1404
+ const content = block.messages.map(({ content: content2, providerOptions }) => ({
1411
1405
  type: "text",
1412
- text: content,
1406
+ text: content2,
1413
1407
  cache_control: validator.getCacheControl(providerOptions, {
1414
1408
  type: "system message",
1415
1409
  canCache: true
1416
1410
  })
1417
1411
  }));
1412
+ if (system == null) {
1413
+ system = content;
1414
+ } else {
1415
+ messages.push({ role: "system", content });
1416
+ betas.add("mid-conversation-system-2026-04-07");
1417
+ }
1418
1418
  break;
1419
1419
  }
1420
1420
  case "user": {
@@ -1452,7 +1452,7 @@ async function convertToAnthropicMessagesPrompt({
1452
1452
  } : {
1453
1453
  type: "base64",
1454
1454
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
1455
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1455
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
1456
1456
  },
1457
1457
  cache_control: cacheControl
1458
1458
  });
@@ -1472,7 +1472,7 @@ async function convertToAnthropicMessagesPrompt({
1472
1472
  } : {
1473
1473
  type: "base64",
1474
1474
  media_type: "application/pdf",
1475
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1475
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
1476
1476
  },
1477
1477
  title: (_b = metadata.title) != null ? _b : part.filename,
1478
1478
  ...metadata.context && { context: metadata.context },
@@ -1637,7 +1637,7 @@ async function convertToAnthropicMessagesPrompt({
1637
1637
  }
1638
1638
  case "reasoning": {
1639
1639
  if (sendReasoning) {
1640
- const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1640
+ const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
1641
1641
  provider: "anthropic",
1642
1642
  providerOptions: part.providerOptions,
1643
1643
  schema: anthropicReasoningMetadataSchema
@@ -1737,7 +1737,7 @@ async function convertToAnthropicMessagesPrompt({
1737
1737
  break;
1738
1738
  }
1739
1739
  if (output.value.type === "code_execution_result") {
1740
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1740
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1741
1741
  value: output.value,
1742
1742
  schema: codeExecution_20250522OutputSchema
1743
1743
  });
@@ -1753,7 +1753,7 @@ async function convertToAnthropicMessagesPrompt({
1753
1753
  cache_control: cacheControl
1754
1754
  });
1755
1755
  } else {
1756
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1756
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1757
1757
  value: output.value,
1758
1758
  schema: codeExecution_20250825OutputSchema
1759
1759
  });
@@ -1782,7 +1782,7 @@ async function convertToAnthropicMessagesPrompt({
1782
1782
  });
1783
1783
  break;
1784
1784
  }
1785
- const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1785
+ const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1786
1786
  value: output.value,
1787
1787
  schema: webFetch_20250910OutputSchema
1788
1788
  });
@@ -1817,7 +1817,7 @@ async function convertToAnthropicMessagesPrompt({
1817
1817
  });
1818
1818
  break;
1819
1819
  }
1820
- const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1820
+ const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1821
1821
  value: output.value,
1822
1822
  schema: webSearch_20250305OutputSchema
1823
1823
  });
@@ -1928,6 +1928,152 @@ function mapAnthropicStopReason({
1928
1928
  }
1929
1929
  }
1930
1930
 
1931
+ // src/sanitize-json-schema.ts
1932
+ var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
1933
+ "date-time",
1934
+ "time",
1935
+ "date",
1936
+ "duration",
1937
+ "email",
1938
+ "hostname",
1939
+ "uri",
1940
+ "ipv4",
1941
+ "ipv6",
1942
+ "uuid"
1943
+ ]);
1944
+ var DESCRIPTION_CONSTRAINT_KEYS = [
1945
+ "minimum",
1946
+ "maximum",
1947
+ "exclusiveMinimum",
1948
+ "exclusiveMaximum",
1949
+ "multipleOf",
1950
+ "minLength",
1951
+ "maxLength",
1952
+ "pattern",
1953
+ "minItems",
1954
+ "maxItems",
1955
+ "uniqueItems",
1956
+ "minProperties",
1957
+ "maxProperties",
1958
+ "not"
1959
+ ];
1960
+ function sanitizeJsonSchema(schema) {
1961
+ return sanitizeSchema(schema);
1962
+ }
1963
+ function sanitizeDefinition(definition) {
1964
+ if (typeof definition === "boolean" || !isPlainObject(definition)) {
1965
+ return definition;
1966
+ }
1967
+ return sanitizeSchema(definition);
1968
+ }
1969
+ function sanitizeSchema(schema) {
1970
+ const result = {};
1971
+ const schemaWithDefs = schema;
1972
+ if (schema.$ref != null) {
1973
+ return { $ref: schema.$ref };
1974
+ }
1975
+ if (schema.$schema != null) {
1976
+ result.$schema = schema.$schema;
1977
+ }
1978
+ if (schema.$id != null) {
1979
+ result.$id = schema.$id;
1980
+ }
1981
+ if (schema.title != null) {
1982
+ result.title = schema.title;
1983
+ }
1984
+ if (schema.description != null) {
1985
+ result.description = schema.description;
1986
+ }
1987
+ if (schema.default !== void 0) {
1988
+ result.default = schema.default;
1989
+ }
1990
+ if (schema.const !== void 0) {
1991
+ result.const = schema.const;
1992
+ }
1993
+ if (schema.enum != null) {
1994
+ result.enum = schema.enum;
1995
+ }
1996
+ if (schema.type != null) {
1997
+ result.type = schema.type;
1998
+ }
1999
+ if (schema.anyOf != null) {
2000
+ result.anyOf = schema.anyOf.map(sanitizeDefinition);
2001
+ } else if (schema.oneOf != null) {
2002
+ result.anyOf = schema.oneOf.map(sanitizeDefinition);
2003
+ }
2004
+ if (schema.allOf != null) {
2005
+ result.allOf = schema.allOf.map(sanitizeDefinition);
2006
+ }
2007
+ if (schema.definitions != null) {
2008
+ result.definitions = Object.fromEntries(
2009
+ Object.entries(schema.definitions).map(([name, definition]) => [
2010
+ name,
2011
+ sanitizeDefinition(definition)
2012
+ ])
2013
+ );
2014
+ }
2015
+ if (schemaWithDefs.$defs != null) {
2016
+ const resultWithDefs = result;
2017
+ resultWithDefs.$defs = Object.fromEntries(
2018
+ Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
2019
+ name,
2020
+ sanitizeDefinition(definition)
2021
+ ])
2022
+ );
2023
+ }
2024
+ if (schema.type === "object" || schema.properties != null) {
2025
+ if (schema.properties != null) {
2026
+ result.properties = Object.fromEntries(
2027
+ Object.entries(schema.properties).map(([name, definition]) => [
2028
+ name,
2029
+ sanitizeDefinition(definition)
2030
+ ])
2031
+ );
2032
+ }
2033
+ result.additionalProperties = false;
2034
+ if (schema.required != null) {
2035
+ result.required = schema.required;
2036
+ }
2037
+ }
2038
+ if (schema.items != null) {
2039
+ result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
2040
+ }
2041
+ if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
2042
+ result.format = schema.format;
2043
+ }
2044
+ const constraintDescription = getConstraintDescription(schema);
2045
+ if (constraintDescription != null) {
2046
+ result.description = result.description == null ? constraintDescription : `${result.description}
2047
+ ${constraintDescription}`;
2048
+ }
2049
+ return result;
2050
+ }
2051
+ function getConstraintDescription(schema) {
2052
+ const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
2053
+ const value = schema[key];
2054
+ if (value == null || value === false) {
2055
+ return [];
2056
+ }
2057
+ return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
2058
+ });
2059
+ if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
2060
+ descriptions.push(`format: ${schema.format}`);
2061
+ }
2062
+ return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
2063
+ }
2064
+ function formatConstraintName(key) {
2065
+ return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
2066
+ }
2067
+ function formatConstraintValue(value) {
2068
+ if (typeof value === "string") {
2069
+ return value;
2070
+ }
2071
+ return JSON.stringify(value);
2072
+ }
2073
+ function isPlainObject(value) {
2074
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2075
+ }
2076
+
1931
2077
  // src/anthropic-messages-language-model.ts
1932
2078
  function createCitationSource(citation, citationDocuments, generateId2) {
1933
2079
  var _a;
@@ -1964,7 +2110,7 @@ var AnthropicMessagesLanguageModel = class {
1964
2110
  var _a;
1965
2111
  this.modelId = modelId;
1966
2112
  this.config = config;
1967
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
2113
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1968
2114
  }
1969
2115
  supportsUrl(url) {
1970
2116
  return url.protocol === "https:";
@@ -2042,7 +2188,7 @@ var AnthropicMessagesLanguageModel = class {
2042
2188
  });
2043
2189
  }
2044
2190
  }
2045
- const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
2191
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
2046
2192
  provider: "anthropic",
2047
2193
  providerOptions,
2048
2194
  schema: anthropicProviderOptions
@@ -2134,7 +2280,7 @@ var AnthropicMessagesLanguageModel = class {
2134
2280
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2135
2281
  format: {
2136
2282
  type: "json_schema",
2137
- schema: responseFormat.schema
2283
+ schema: sanitizeJsonSchema(responseFormat.schema)
2138
2284
  }
2139
2285
  }
2140
2286
  }
@@ -2151,13 +2297,6 @@ var AnthropicMessagesLanguageModel = class {
2151
2297
  ...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
2152
2298
  metadata: { user_id: anthropicOptions.metadata.userId }
2153
2299
  },
2154
- // structured output:
2155
- ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2156
- output_format: {
2157
- type: "json_schema",
2158
- schema: responseFormat.schema
2159
- }
2160
- },
2161
2300
  // container with agent skills:
2162
2301
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2163
2302
  container: {
@@ -2343,15 +2482,15 @@ var AnthropicMessagesLanguageModel = class {
2343
2482
  betas,
2344
2483
  headers
2345
2484
  }) {
2346
- return (0, import_provider_utils11.combineHeaders)(
2347
- await (0, import_provider_utils11.resolve)(this.config.headers),
2485
+ return (0, import_provider_utils10.combineHeaders)(
2486
+ await (0, import_provider_utils10.resolve)(this.config.headers),
2348
2487
  headers,
2349
2488
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
2350
2489
  );
2351
2490
  }
2352
2491
  async getBetasFromHeaders(requestHeaders) {
2353
2492
  var _a, _b;
2354
- const configHeaders = await (0, import_provider_utils11.resolve)(this.config.headers);
2493
+ const configHeaders = await (0, import_provider_utils10.resolve)(this.config.headers);
2355
2494
  const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
2356
2495
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
2357
2496
  return new Set(
@@ -2403,12 +2542,12 @@ var AnthropicMessagesLanguageModel = class {
2403
2542
  responseHeaders,
2404
2543
  value: response,
2405
2544
  rawValue: rawResponse
2406
- } = await (0, import_provider_utils11.postJsonToApi)({
2545
+ } = await (0, import_provider_utils10.postJsonToApi)({
2407
2546
  url: this.buildRequestUrl(false),
2408
2547
  headers: await this.getHeaders({ betas, headers: options.headers }),
2409
2548
  body: this.transformRequestBody(args, betas),
2410
2549
  failedResponseHandler: anthropicFailedResponseHandler,
2411
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2550
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
2412
2551
  anthropicMessagesResponseSchema
2413
2552
  ),
2414
2553
  abortSignal: options.abortSignal,
@@ -2728,12 +2867,12 @@ var AnthropicMessagesLanguageModel = class {
2728
2867
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2729
2868
  const body = { ...args, stream: true };
2730
2869
  const url = this.buildRequestUrl(true);
2731
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2870
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
2732
2871
  url,
2733
2872
  headers: await this.getHeaders({ betas, headers: options.headers }),
2734
2873
  body: this.transformRequestBody(body, betas),
2735
2874
  failedResponseHandler: anthropicFailedResponseHandler,
2736
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2875
+ successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
2737
2876
  anthropicMessagesChunkSchema
2738
2877
  ),
2739
2878
  abortSignal: options.abortSignal,
@@ -3298,7 +3437,7 @@ var AnthropicMessagesLanguageModel = class {
3298
3437
  }
3299
3438
  };
3300
3439
  function getModelCapabilities(modelId) {
3301
- if (modelId.includes("claude-opus-4-7")) {
3440
+ if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7")) {
3302
3441
  return {
3303
3442
  maxOutputTokens: 128e3,
3304
3443
  supportsStructuredOutput: true,
@@ -3365,44 +3504,44 @@ function getModelCapabilities(modelId) {
3365
3504
  }
3366
3505
 
3367
3506
  // src/tool/bash_20241022.ts
3368
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
3507
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
3369
3508
  var import_v49 = require("zod/v4");
3370
- var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
3371
- () => (0, import_provider_utils12.zodSchema)(
3509
+ var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
3510
+ () => (0, import_provider_utils11.zodSchema)(
3372
3511
  import_v49.z.object({
3373
3512
  command: import_v49.z.string(),
3374
3513
  restart: import_v49.z.boolean().optional()
3375
3514
  })
3376
3515
  )
3377
3516
  );
3378
- var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
3517
+ var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
3379
3518
  id: "anthropic.bash_20241022",
3380
3519
  name: "bash",
3381
3520
  inputSchema: bash_20241022InputSchema
3382
3521
  });
3383
3522
 
3384
3523
  // src/tool/bash_20250124.ts
3385
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
3524
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
3386
3525
  var import_v410 = require("zod/v4");
3387
- var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
3388
- () => (0, import_provider_utils13.zodSchema)(
3526
+ var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
3527
+ () => (0, import_provider_utils12.zodSchema)(
3389
3528
  import_v410.z.object({
3390
3529
  command: import_v410.z.string(),
3391
3530
  restart: import_v410.z.boolean().optional()
3392
3531
  })
3393
3532
  )
3394
3533
  );
3395
- var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
3534
+ var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
3396
3535
  id: "anthropic.bash_20250124",
3397
3536
  name: "bash",
3398
3537
  inputSchema: bash_20250124InputSchema
3399
3538
  });
3400
3539
 
3401
3540
  // src/tool/code-execution_20260120.ts
3402
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
3541
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
3403
3542
  var import_v411 = require("zod/v4");
3404
- var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)(
3405
- () => (0, import_provider_utils14.zodSchema)(
3543
+ var codeExecution_20260120OutputSchema = (0, import_provider_utils13.lazySchema)(
3544
+ () => (0, import_provider_utils13.zodSchema)(
3406
3545
  import_v411.z.discriminatedUnion("type", [
3407
3546
  import_v411.z.object({
3408
3547
  type: import_v411.z.literal("code_execution_result"),
@@ -3459,8 +3598,8 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)
3459
3598
  ])
3460
3599
  )
3461
3600
  );
3462
- var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3463
- () => (0, import_provider_utils14.zodSchema)(
3601
+ var codeExecution_20260120InputSchema = (0, import_provider_utils13.lazySchema)(
3602
+ () => (0, import_provider_utils13.zodSchema)(
3464
3603
  import_v411.z.discriminatedUnion("type", [
3465
3604
  import_v411.z.object({
3466
3605
  type: import_v411.z.literal("programmatic-tool-call"),
@@ -3493,7 +3632,7 @@ var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3493
3632
  ])
3494
3633
  )
3495
3634
  );
3496
- var factory6 = (0, import_provider_utils14.createProviderDefinedToolFactoryWithOutputSchema)({
3635
+ var factory6 = (0, import_provider_utils13.createProviderDefinedToolFactoryWithOutputSchema)({
3497
3636
  id: "anthropic.code_execution_20260120",
3498
3637
  name: "code_execution",
3499
3638
  inputSchema: codeExecution_20260120InputSchema,
@@ -3504,10 +3643,10 @@ var codeExecution_20260120 = (args = {}) => {
3504
3643
  };
3505
3644
 
3506
3645
  // src/tool/computer_20241022.ts
3507
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
3646
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
3508
3647
  var import_v412 = require("zod/v4");
3509
- var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3510
- () => (0, import_provider_utils15.zodSchema)(
3648
+ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3649
+ () => (0, import_provider_utils14.zodSchema)(
3511
3650
  import_v412.z.object({
3512
3651
  action: import_v412.z.enum([
3513
3652
  "key",
@@ -3526,17 +3665,17 @@ var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3526
3665
  })
3527
3666
  )
3528
3667
  );
3529
- var computer_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3668
+ var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
3530
3669
  id: "anthropic.computer_20241022",
3531
3670
  name: "computer",
3532
3671
  inputSchema: computer_20241022InputSchema
3533
3672
  });
3534
3673
 
3535
3674
  // src/tool/computer_20250124.ts
3536
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3675
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
3537
3676
  var import_v413 = require("zod/v4");
3538
- var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3539
- () => (0, import_provider_utils16.zodSchema)(
3677
+ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3678
+ () => (0, import_provider_utils15.zodSchema)(
3540
3679
  import_v413.z.object({
3541
3680
  action: import_v413.z.enum([
3542
3681
  "key",
@@ -3565,17 +3704,17 @@ var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3565
3704
  })
3566
3705
  )
3567
3706
  );
3568
- var computer_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3707
+ var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3569
3708
  id: "anthropic.computer_20250124",
3570
3709
  name: "computer",
3571
3710
  inputSchema: computer_20250124InputSchema
3572
3711
  });
3573
3712
 
3574
3713
  // src/tool/memory_20250818.ts
3575
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
3714
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
3576
3715
  var import_v414 = require("zod/v4");
3577
- var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3578
- () => (0, import_provider_utils17.zodSchema)(
3716
+ var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
3717
+ () => (0, import_provider_utils16.zodSchema)(
3579
3718
  import_v414.z.discriminatedUnion("command", [
3580
3719
  import_v414.z.object({
3581
3720
  command: import_v414.z.literal("view"),
@@ -3611,17 +3750,17 @@ var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3611
3750
  ])
3612
3751
  )
3613
3752
  );
3614
- var memory_20250818 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3753
+ var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3615
3754
  id: "anthropic.memory_20250818",
3616
3755
  name: "memory",
3617
3756
  inputSchema: memory_20250818InputSchema
3618
3757
  });
3619
3758
 
3620
3759
  // src/tool/text-editor_20241022.ts
3621
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
3760
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
3622
3761
  var import_v415 = require("zod/v4");
3623
- var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3624
- () => (0, import_provider_utils18.zodSchema)(
3762
+ var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
3763
+ () => (0, import_provider_utils17.zodSchema)(
3625
3764
  import_v415.z.object({
3626
3765
  command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3627
3766
  path: import_v415.z.string(),
@@ -3633,17 +3772,17 @@ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3633
3772
  })
3634
3773
  )
3635
3774
  );
3636
- var textEditor_20241022 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3775
+ var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3637
3776
  id: "anthropic.text_editor_20241022",
3638
3777
  name: "str_replace_editor",
3639
3778
  inputSchema: textEditor_20241022InputSchema
3640
3779
  });
3641
3780
 
3642
3781
  // src/tool/text-editor_20250124.ts
3643
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
3782
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
3644
3783
  var import_v416 = require("zod/v4");
3645
- var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3646
- () => (0, import_provider_utils19.zodSchema)(
3784
+ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3785
+ () => (0, import_provider_utils18.zodSchema)(
3647
3786
  import_v416.z.object({
3648
3787
  command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3649
3788
  path: import_v416.z.string(),
@@ -3655,17 +3794,17 @@ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3655
3794
  })
3656
3795
  )
3657
3796
  );
3658
- var textEditor_20250124 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3797
+ var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3659
3798
  id: "anthropic.text_editor_20250124",
3660
3799
  name: "str_replace_editor",
3661
3800
  inputSchema: textEditor_20250124InputSchema
3662
3801
  });
3663
3802
 
3664
3803
  // src/tool/text-editor_20250429.ts
3665
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
3804
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
3666
3805
  var import_v417 = require("zod/v4");
3667
- var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3668
- () => (0, import_provider_utils20.zodSchema)(
3806
+ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3807
+ () => (0, import_provider_utils19.zodSchema)(
3669
3808
  import_v417.z.object({
3670
3809
  command: import_v417.z.enum(["view", "create", "str_replace", "insert"]),
3671
3810
  path: import_v417.z.string(),
@@ -3677,7 +3816,7 @@ var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3677
3816
  })
3678
3817
  )
3679
3818
  );
3680
- var textEditor_20250429 = (0, import_provider_utils20.createProviderDefinedToolFactory)({
3819
+ var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3681
3820
  id: "anthropic.text_editor_20250429",
3682
3821
  name: "str_replace_based_edit_tool",
3683
3822
  inputSchema: textEditor_20250429InputSchema