@ai-sdk/anthropic 2.0.77 → 2.0.79

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
@@ -1452,7 +1451,7 @@ async function convertToAnthropicMessagesPrompt({
1452
1451
  } : {
1453
1452
  type: "base64",
1454
1453
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
1455
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1454
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
1456
1455
  },
1457
1456
  cache_control: cacheControl
1458
1457
  });
@@ -1472,7 +1471,7 @@ async function convertToAnthropicMessagesPrompt({
1472
1471
  } : {
1473
1472
  type: "base64",
1474
1473
  media_type: "application/pdf",
1475
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1474
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
1476
1475
  },
1477
1476
  title: (_b = metadata.title) != null ? _b : part.filename,
1478
1477
  ...metadata.context && { context: metadata.context },
@@ -1637,7 +1636,7 @@ async function convertToAnthropicMessagesPrompt({
1637
1636
  }
1638
1637
  case "reasoning": {
1639
1638
  if (sendReasoning) {
1640
- const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1639
+ const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
1641
1640
  provider: "anthropic",
1642
1641
  providerOptions: part.providerOptions,
1643
1642
  schema: anthropicReasoningMetadataSchema
@@ -1737,7 +1736,7 @@ async function convertToAnthropicMessagesPrompt({
1737
1736
  break;
1738
1737
  }
1739
1738
  if (output.value.type === "code_execution_result") {
1740
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1739
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1741
1740
  value: output.value,
1742
1741
  schema: codeExecution_20250522OutputSchema
1743
1742
  });
@@ -1753,7 +1752,7 @@ async function convertToAnthropicMessagesPrompt({
1753
1752
  cache_control: cacheControl
1754
1753
  });
1755
1754
  } else {
1756
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1755
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1757
1756
  value: output.value,
1758
1757
  schema: codeExecution_20250825OutputSchema
1759
1758
  });
@@ -1782,7 +1781,7 @@ async function convertToAnthropicMessagesPrompt({
1782
1781
  });
1783
1782
  break;
1784
1783
  }
1785
- const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1784
+ const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1786
1785
  value: output.value,
1787
1786
  schema: webFetch_20250910OutputSchema
1788
1787
  });
@@ -1817,7 +1816,7 @@ async function convertToAnthropicMessagesPrompt({
1817
1816
  });
1818
1817
  break;
1819
1818
  }
1820
- const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1819
+ const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1821
1820
  value: output.value,
1822
1821
  schema: webSearch_20250305OutputSchema
1823
1822
  });
@@ -1928,6 +1927,152 @@ function mapAnthropicStopReason({
1928
1927
  }
1929
1928
  }
1930
1929
 
1930
+ // src/sanitize-json-schema.ts
1931
+ var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
1932
+ "date-time",
1933
+ "time",
1934
+ "date",
1935
+ "duration",
1936
+ "email",
1937
+ "hostname",
1938
+ "uri",
1939
+ "ipv4",
1940
+ "ipv6",
1941
+ "uuid"
1942
+ ]);
1943
+ var DESCRIPTION_CONSTRAINT_KEYS = [
1944
+ "minimum",
1945
+ "maximum",
1946
+ "exclusiveMinimum",
1947
+ "exclusiveMaximum",
1948
+ "multipleOf",
1949
+ "minLength",
1950
+ "maxLength",
1951
+ "pattern",
1952
+ "minItems",
1953
+ "maxItems",
1954
+ "uniqueItems",
1955
+ "minProperties",
1956
+ "maxProperties",
1957
+ "not"
1958
+ ];
1959
+ function sanitizeJsonSchema(schema) {
1960
+ return sanitizeSchema(schema);
1961
+ }
1962
+ function sanitizeDefinition(definition) {
1963
+ if (typeof definition === "boolean" || !isPlainObject(definition)) {
1964
+ return definition;
1965
+ }
1966
+ return sanitizeSchema(definition);
1967
+ }
1968
+ function sanitizeSchema(schema) {
1969
+ const result = {};
1970
+ const schemaWithDefs = schema;
1971
+ if (schema.$ref != null) {
1972
+ return { $ref: schema.$ref };
1973
+ }
1974
+ if (schema.$schema != null) {
1975
+ result.$schema = schema.$schema;
1976
+ }
1977
+ if (schema.$id != null) {
1978
+ result.$id = schema.$id;
1979
+ }
1980
+ if (schema.title != null) {
1981
+ result.title = schema.title;
1982
+ }
1983
+ if (schema.description != null) {
1984
+ result.description = schema.description;
1985
+ }
1986
+ if (schema.default !== void 0) {
1987
+ result.default = schema.default;
1988
+ }
1989
+ if (schema.const !== void 0) {
1990
+ result.const = schema.const;
1991
+ }
1992
+ if (schema.enum != null) {
1993
+ result.enum = schema.enum;
1994
+ }
1995
+ if (schema.type != null) {
1996
+ result.type = schema.type;
1997
+ }
1998
+ if (schema.anyOf != null) {
1999
+ result.anyOf = schema.anyOf.map(sanitizeDefinition);
2000
+ } else if (schema.oneOf != null) {
2001
+ result.anyOf = schema.oneOf.map(sanitizeDefinition);
2002
+ }
2003
+ if (schema.allOf != null) {
2004
+ result.allOf = schema.allOf.map(sanitizeDefinition);
2005
+ }
2006
+ if (schema.definitions != null) {
2007
+ result.definitions = Object.fromEntries(
2008
+ Object.entries(schema.definitions).map(([name, definition]) => [
2009
+ name,
2010
+ sanitizeDefinition(definition)
2011
+ ])
2012
+ );
2013
+ }
2014
+ if (schemaWithDefs.$defs != null) {
2015
+ const resultWithDefs = result;
2016
+ resultWithDefs.$defs = Object.fromEntries(
2017
+ Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
2018
+ name,
2019
+ sanitizeDefinition(definition)
2020
+ ])
2021
+ );
2022
+ }
2023
+ if (schema.type === "object" || schema.properties != null) {
2024
+ if (schema.properties != null) {
2025
+ result.properties = Object.fromEntries(
2026
+ Object.entries(schema.properties).map(([name, definition]) => [
2027
+ name,
2028
+ sanitizeDefinition(definition)
2029
+ ])
2030
+ );
2031
+ }
2032
+ result.additionalProperties = false;
2033
+ if (schema.required != null) {
2034
+ result.required = schema.required;
2035
+ }
2036
+ }
2037
+ if (schema.items != null) {
2038
+ result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
2039
+ }
2040
+ if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
2041
+ result.format = schema.format;
2042
+ }
2043
+ const constraintDescription = getConstraintDescription(schema);
2044
+ if (constraintDescription != null) {
2045
+ result.description = result.description == null ? constraintDescription : `${result.description}
2046
+ ${constraintDescription}`;
2047
+ }
2048
+ return result;
2049
+ }
2050
+ function getConstraintDescription(schema) {
2051
+ const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
2052
+ const value = schema[key];
2053
+ if (value == null || value === false) {
2054
+ return [];
2055
+ }
2056
+ return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
2057
+ });
2058
+ if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
2059
+ descriptions.push(`format: ${schema.format}`);
2060
+ }
2061
+ return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
2062
+ }
2063
+ function formatConstraintName(key) {
2064
+ return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
2065
+ }
2066
+ function formatConstraintValue(value) {
2067
+ if (typeof value === "string") {
2068
+ return value;
2069
+ }
2070
+ return JSON.stringify(value);
2071
+ }
2072
+ function isPlainObject(value) {
2073
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2074
+ }
2075
+
1931
2076
  // src/anthropic-messages-language-model.ts
1932
2077
  function createCitationSource(citation, citationDocuments, generateId2) {
1933
2078
  var _a;
@@ -1964,7 +2109,7 @@ var AnthropicMessagesLanguageModel = class {
1964
2109
  var _a;
1965
2110
  this.modelId = modelId;
1966
2111
  this.config = config;
1967
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
2112
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1968
2113
  }
1969
2114
  supportsUrl(url) {
1970
2115
  return url.protocol === "https:";
@@ -2042,7 +2187,7 @@ var AnthropicMessagesLanguageModel = class {
2042
2187
  });
2043
2188
  }
2044
2189
  }
2045
- const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
2190
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
2046
2191
  provider: "anthropic",
2047
2192
  providerOptions,
2048
2193
  schema: anthropicProviderOptions
@@ -2134,7 +2279,7 @@ var AnthropicMessagesLanguageModel = class {
2134
2279
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2135
2280
  format: {
2136
2281
  type: "json_schema",
2137
- schema: responseFormat.schema
2282
+ schema: sanitizeJsonSchema(responseFormat.schema)
2138
2283
  }
2139
2284
  }
2140
2285
  }
@@ -2151,13 +2296,6 @@ var AnthropicMessagesLanguageModel = class {
2151
2296
  ...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
2152
2297
  metadata: { user_id: anthropicOptions.metadata.userId }
2153
2298
  },
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
2299
  // container with agent skills:
2162
2300
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2163
2301
  container: {
@@ -2343,15 +2481,15 @@ var AnthropicMessagesLanguageModel = class {
2343
2481
  betas,
2344
2482
  headers
2345
2483
  }) {
2346
- return (0, import_provider_utils11.combineHeaders)(
2347
- await (0, import_provider_utils11.resolve)(this.config.headers),
2484
+ return (0, import_provider_utils10.combineHeaders)(
2485
+ await (0, import_provider_utils10.resolve)(this.config.headers),
2348
2486
  headers,
2349
2487
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
2350
2488
  );
2351
2489
  }
2352
2490
  async getBetasFromHeaders(requestHeaders) {
2353
2491
  var _a, _b;
2354
- const configHeaders = await (0, import_provider_utils11.resolve)(this.config.headers);
2492
+ const configHeaders = await (0, import_provider_utils10.resolve)(this.config.headers);
2355
2493
  const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
2356
2494
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
2357
2495
  return new Set(
@@ -2403,12 +2541,12 @@ var AnthropicMessagesLanguageModel = class {
2403
2541
  responseHeaders,
2404
2542
  value: response,
2405
2543
  rawValue: rawResponse
2406
- } = await (0, import_provider_utils11.postJsonToApi)({
2544
+ } = await (0, import_provider_utils10.postJsonToApi)({
2407
2545
  url: this.buildRequestUrl(false),
2408
2546
  headers: await this.getHeaders({ betas, headers: options.headers }),
2409
2547
  body: this.transformRequestBody(args, betas),
2410
2548
  failedResponseHandler: anthropicFailedResponseHandler,
2411
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2549
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
2412
2550
  anthropicMessagesResponseSchema
2413
2551
  ),
2414
2552
  abortSignal: options.abortSignal,
@@ -2728,12 +2866,12 @@ var AnthropicMessagesLanguageModel = class {
2728
2866
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2729
2867
  const body = { ...args, stream: true };
2730
2868
  const url = this.buildRequestUrl(true);
2731
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2869
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
2732
2870
  url,
2733
2871
  headers: await this.getHeaders({ betas, headers: options.headers }),
2734
2872
  body: this.transformRequestBody(body, betas),
2735
2873
  failedResponseHandler: anthropicFailedResponseHandler,
2736
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2874
+ successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
2737
2875
  anthropicMessagesChunkSchema
2738
2876
  ),
2739
2877
  abortSignal: options.abortSignal,
@@ -3365,44 +3503,44 @@ function getModelCapabilities(modelId) {
3365
3503
  }
3366
3504
 
3367
3505
  // src/tool/bash_20241022.ts
3368
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
3506
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
3369
3507
  var import_v49 = require("zod/v4");
3370
- var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
3371
- () => (0, import_provider_utils12.zodSchema)(
3508
+ var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
3509
+ () => (0, import_provider_utils11.zodSchema)(
3372
3510
  import_v49.z.object({
3373
3511
  command: import_v49.z.string(),
3374
3512
  restart: import_v49.z.boolean().optional()
3375
3513
  })
3376
3514
  )
3377
3515
  );
3378
- var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
3516
+ var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
3379
3517
  id: "anthropic.bash_20241022",
3380
3518
  name: "bash",
3381
3519
  inputSchema: bash_20241022InputSchema
3382
3520
  });
3383
3521
 
3384
3522
  // src/tool/bash_20250124.ts
3385
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
3523
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
3386
3524
  var import_v410 = require("zod/v4");
3387
- var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
3388
- () => (0, import_provider_utils13.zodSchema)(
3525
+ var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
3526
+ () => (0, import_provider_utils12.zodSchema)(
3389
3527
  import_v410.z.object({
3390
3528
  command: import_v410.z.string(),
3391
3529
  restart: import_v410.z.boolean().optional()
3392
3530
  })
3393
3531
  )
3394
3532
  );
3395
- var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
3533
+ var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
3396
3534
  id: "anthropic.bash_20250124",
3397
3535
  name: "bash",
3398
3536
  inputSchema: bash_20250124InputSchema
3399
3537
  });
3400
3538
 
3401
3539
  // src/tool/code-execution_20260120.ts
3402
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
3540
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
3403
3541
  var import_v411 = require("zod/v4");
3404
- var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)(
3405
- () => (0, import_provider_utils14.zodSchema)(
3542
+ var codeExecution_20260120OutputSchema = (0, import_provider_utils13.lazySchema)(
3543
+ () => (0, import_provider_utils13.zodSchema)(
3406
3544
  import_v411.z.discriminatedUnion("type", [
3407
3545
  import_v411.z.object({
3408
3546
  type: import_v411.z.literal("code_execution_result"),
@@ -3459,8 +3597,8 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)
3459
3597
  ])
3460
3598
  )
3461
3599
  );
3462
- var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3463
- () => (0, import_provider_utils14.zodSchema)(
3600
+ var codeExecution_20260120InputSchema = (0, import_provider_utils13.lazySchema)(
3601
+ () => (0, import_provider_utils13.zodSchema)(
3464
3602
  import_v411.z.discriminatedUnion("type", [
3465
3603
  import_v411.z.object({
3466
3604
  type: import_v411.z.literal("programmatic-tool-call"),
@@ -3493,7 +3631,7 @@ var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3493
3631
  ])
3494
3632
  )
3495
3633
  );
3496
- var factory6 = (0, import_provider_utils14.createProviderDefinedToolFactoryWithOutputSchema)({
3634
+ var factory6 = (0, import_provider_utils13.createProviderDefinedToolFactoryWithOutputSchema)({
3497
3635
  id: "anthropic.code_execution_20260120",
3498
3636
  name: "code_execution",
3499
3637
  inputSchema: codeExecution_20260120InputSchema,
@@ -3504,10 +3642,10 @@ var codeExecution_20260120 = (args = {}) => {
3504
3642
  };
3505
3643
 
3506
3644
  // src/tool/computer_20241022.ts
3507
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
3645
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
3508
3646
  var import_v412 = require("zod/v4");
3509
- var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3510
- () => (0, import_provider_utils15.zodSchema)(
3647
+ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3648
+ () => (0, import_provider_utils14.zodSchema)(
3511
3649
  import_v412.z.object({
3512
3650
  action: import_v412.z.enum([
3513
3651
  "key",
@@ -3526,17 +3664,17 @@ var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3526
3664
  })
3527
3665
  )
3528
3666
  );
3529
- var computer_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3667
+ var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
3530
3668
  id: "anthropic.computer_20241022",
3531
3669
  name: "computer",
3532
3670
  inputSchema: computer_20241022InputSchema
3533
3671
  });
3534
3672
 
3535
3673
  // src/tool/computer_20250124.ts
3536
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3674
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
3537
3675
  var import_v413 = require("zod/v4");
3538
- var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3539
- () => (0, import_provider_utils16.zodSchema)(
3676
+ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3677
+ () => (0, import_provider_utils15.zodSchema)(
3540
3678
  import_v413.z.object({
3541
3679
  action: import_v413.z.enum([
3542
3680
  "key",
@@ -3565,17 +3703,17 @@ var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3565
3703
  })
3566
3704
  )
3567
3705
  );
3568
- var computer_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3706
+ var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3569
3707
  id: "anthropic.computer_20250124",
3570
3708
  name: "computer",
3571
3709
  inputSchema: computer_20250124InputSchema
3572
3710
  });
3573
3711
 
3574
3712
  // src/tool/memory_20250818.ts
3575
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
3713
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
3576
3714
  var import_v414 = require("zod/v4");
3577
- var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3578
- () => (0, import_provider_utils17.zodSchema)(
3715
+ var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
3716
+ () => (0, import_provider_utils16.zodSchema)(
3579
3717
  import_v414.z.discriminatedUnion("command", [
3580
3718
  import_v414.z.object({
3581
3719
  command: import_v414.z.literal("view"),
@@ -3611,17 +3749,17 @@ var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3611
3749
  ])
3612
3750
  )
3613
3751
  );
3614
- var memory_20250818 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3752
+ var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3615
3753
  id: "anthropic.memory_20250818",
3616
3754
  name: "memory",
3617
3755
  inputSchema: memory_20250818InputSchema
3618
3756
  });
3619
3757
 
3620
3758
  // src/tool/text-editor_20241022.ts
3621
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
3759
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
3622
3760
  var import_v415 = require("zod/v4");
3623
- var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3624
- () => (0, import_provider_utils18.zodSchema)(
3761
+ var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
3762
+ () => (0, import_provider_utils17.zodSchema)(
3625
3763
  import_v415.z.object({
3626
3764
  command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3627
3765
  path: import_v415.z.string(),
@@ -3633,17 +3771,17 @@ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3633
3771
  })
3634
3772
  )
3635
3773
  );
3636
- var textEditor_20241022 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3774
+ var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3637
3775
  id: "anthropic.text_editor_20241022",
3638
3776
  name: "str_replace_editor",
3639
3777
  inputSchema: textEditor_20241022InputSchema
3640
3778
  });
3641
3779
 
3642
3780
  // src/tool/text-editor_20250124.ts
3643
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
3781
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
3644
3782
  var import_v416 = require("zod/v4");
3645
- var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3646
- () => (0, import_provider_utils19.zodSchema)(
3783
+ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3784
+ () => (0, import_provider_utils18.zodSchema)(
3647
3785
  import_v416.z.object({
3648
3786
  command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3649
3787
  path: import_v416.z.string(),
@@ -3655,17 +3793,17 @@ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3655
3793
  })
3656
3794
  )
3657
3795
  );
3658
- var textEditor_20250124 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3796
+ var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3659
3797
  id: "anthropic.text_editor_20250124",
3660
3798
  name: "str_replace_editor",
3661
3799
  inputSchema: textEditor_20250124InputSchema
3662
3800
  });
3663
3801
 
3664
3802
  // src/tool/text-editor_20250429.ts
3665
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
3803
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
3666
3804
  var import_v417 = require("zod/v4");
3667
- var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3668
- () => (0, import_provider_utils20.zodSchema)(
3805
+ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3806
+ () => (0, import_provider_utils19.zodSchema)(
3669
3807
  import_v417.z.object({
3670
3808
  command: import_v417.z.enum(["view", "create", "str_replace", "insert"]),
3671
3809
  path: import_v417.z.string(),
@@ -3677,7 +3815,7 @@ var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3677
3815
  })
3678
3816
  )
3679
3817
  );
3680
- var textEditor_20250429 = (0, import_provider_utils20.createProviderDefinedToolFactory)({
3818
+ var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3681
3819
  id: "anthropic.text_editor_20250429",
3682
3820
  name: "str_replace_based_edit_tool",
3683
3821
  inputSchema: textEditor_20250429InputSchema