@ai-sdk/anthropic 2.0.78 → 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.
package/dist/index.js CHANGED
@@ -28,14 +28,14 @@ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/anthropic-provider.ts
30
30
  var import_provider4 = require("@ai-sdk/provider");
31
- var import_provider_utils21 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "2.0.78" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.79" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
38
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
38
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
39
39
 
40
40
  // src/anthropic-error.ts
41
41
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -845,16 +845,15 @@ var CacheControlValidator = class {
845
845
  // src/tool/text-editor_20250728.ts
846
846
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
847
847
  var import_v44 = require("zod/v4");
848
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
849
- var textEditor_20250728ArgsSchema = (0, import_provider_utils4.lazySchema)(
850
- () => (0, import_provider_utils4.zodSchema)(
848
+ var textEditor_20250728ArgsSchema = (0, import_provider_utils3.lazySchema)(
849
+ () => (0, import_provider_utils3.zodSchema)(
851
850
  import_v44.z.object({
852
851
  maxCharacters: import_v44.z.number().optional()
853
852
  })
854
853
  )
855
854
  );
856
- var textEditor_20250728InputSchema = (0, import_provider_utils4.lazySchema)(
857
- () => (0, import_provider_utils4.zodSchema)(
855
+ var textEditor_20250728InputSchema = (0, import_provider_utils3.lazySchema)(
856
+ () => (0, import_provider_utils3.zodSchema)(
858
857
  import_v44.z.object({
859
858
  command: import_v44.z.enum(["view", "create", "str_replace", "insert"]),
860
859
  path: import_v44.z.string(),
@@ -876,10 +875,10 @@ var textEditor_20250728 = (args = {}) => {
876
875
  };
877
876
 
878
877
  // src/tool/web-search_20250305.ts
879
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
878
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
880
879
  var import_v45 = require("zod/v4");
881
- var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
882
- () => (0, import_provider_utils5.zodSchema)(
880
+ var webSearch_20250305ArgsSchema = (0, import_provider_utils4.lazySchema)(
881
+ () => (0, import_provider_utils4.zodSchema)(
883
882
  import_v45.z.object({
884
883
  maxUses: import_v45.z.number().optional(),
885
884
  allowedDomains: import_v45.z.array(import_v45.z.string()).optional(),
@@ -894,8 +893,8 @@ var webSearch_20250305ArgsSchema = (0, import_provider_utils5.lazySchema)(
894
893
  })
895
894
  )
896
895
  );
897
- var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
898
- () => (0, import_provider_utils5.zodSchema)(
896
+ var webSearch_20250305OutputSchema = (0, import_provider_utils4.lazySchema)(
897
+ () => (0, import_provider_utils4.zodSchema)(
899
898
  import_v45.z.array(
900
899
  import_v45.z.object({
901
900
  url: import_v45.z.string(),
@@ -907,14 +906,14 @@ var webSearch_20250305OutputSchema = (0, import_provider_utils5.lazySchema)(
907
906
  )
908
907
  )
909
908
  );
910
- var webSearch_20250305InputSchema = (0, import_provider_utils5.lazySchema)(
911
- () => (0, import_provider_utils5.zodSchema)(
909
+ var webSearch_20250305InputSchema = (0, import_provider_utils4.lazySchema)(
910
+ () => (0, import_provider_utils4.zodSchema)(
912
911
  import_v45.z.object({
913
912
  query: import_v45.z.string()
914
913
  })
915
914
  )
916
915
  );
917
- var factory2 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
916
+ var factory2 = (0, import_provider_utils4.createProviderDefinedToolFactoryWithOutputSchema)({
918
917
  id: "anthropic.web_search_20250305",
919
918
  name: "web_search",
920
919
  inputSchema: webSearch_20250305InputSchema,
@@ -925,10 +924,10 @@ var webSearch_20250305 = (args = {}) => {
925
924
  };
926
925
 
927
926
  // src/tool/web-fetch-20250910.ts
928
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
927
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
929
928
  var import_v46 = require("zod/v4");
930
- var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
931
- () => (0, import_provider_utils6.zodSchema)(
929
+ var webFetch_20250910ArgsSchema = (0, import_provider_utils5.lazySchema)(
930
+ () => (0, import_provider_utils5.zodSchema)(
932
931
  import_v46.z.object({
933
932
  maxUses: import_v46.z.number().optional(),
934
933
  allowedDomains: import_v46.z.array(import_v46.z.string()).optional(),
@@ -938,8 +937,8 @@ var webFetch_20250910ArgsSchema = (0, import_provider_utils6.lazySchema)(
938
937
  })
939
938
  )
940
939
  );
941
- var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
942
- () => (0, import_provider_utils6.zodSchema)(
940
+ var webFetch_20250910OutputSchema = (0, import_provider_utils5.lazySchema)(
941
+ () => (0, import_provider_utils5.zodSchema)(
943
942
  import_v46.z.object({
944
943
  type: import_v46.z.literal("web_fetch_result"),
945
944
  url: import_v46.z.string(),
@@ -964,14 +963,14 @@ var webFetch_20250910OutputSchema = (0, import_provider_utils6.lazySchema)(
964
963
  })
965
964
  )
966
965
  );
967
- var webFetch_20250910InputSchema = (0, import_provider_utils6.lazySchema)(
968
- () => (0, import_provider_utils6.zodSchema)(
966
+ var webFetch_20250910InputSchema = (0, import_provider_utils5.lazySchema)(
967
+ () => (0, import_provider_utils5.zodSchema)(
969
968
  import_v46.z.object({
970
969
  url: import_v46.z.string()
971
970
  })
972
971
  )
973
972
  );
974
- var factory3 = (0, import_provider_utils6.createProviderDefinedToolFactoryWithOutputSchema)({
973
+ var factory3 = (0, import_provider_utils5.createProviderDefinedToolFactoryWithOutputSchema)({
975
974
  id: "anthropic.web_fetch_20250910",
976
975
  name: "web_fetch",
977
976
  inputSchema: webFetch_20250910InputSchema,
@@ -982,7 +981,7 @@ var webFetch_20250910 = (args = {}) => {
982
981
  };
983
982
 
984
983
  // src/anthropic-prepare-tools.ts
985
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
984
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
986
985
  async function prepareTools({
987
986
  tools,
988
987
  toolChoice,
@@ -1094,7 +1093,7 @@ async function prepareTools({
1094
1093
  break;
1095
1094
  }
1096
1095
  case "anthropic.text_editor_20250728": {
1097
- const args = await (0, import_provider_utils7.validateTypes)({
1096
+ const args = await (0, import_provider_utils6.validateTypes)({
1098
1097
  value: tool.args,
1099
1098
  schema: textEditor_20250728ArgsSchema
1100
1099
  });
@@ -1134,7 +1133,7 @@ async function prepareTools({
1134
1133
  }
1135
1134
  case "anthropic.web_fetch_20250910": {
1136
1135
  betas.add("web-fetch-2025-09-10");
1137
- const args = await (0, import_provider_utils7.validateTypes)({
1136
+ const args = await (0, import_provider_utils6.validateTypes)({
1138
1137
  value: tool.args,
1139
1138
  schema: webFetch_20250910ArgsSchema
1140
1139
  });
@@ -1151,7 +1150,7 @@ async function prepareTools({
1151
1150
  break;
1152
1151
  }
1153
1152
  case "anthropic.web_search_20250305": {
1154
- const args = await (0, import_provider_utils7.validateTypes)({
1153
+ const args = await (0, import_provider_utils6.validateTypes)({
1155
1154
  value: tool.args,
1156
1155
  schema: webSearch_20250305ArgsSchema
1157
1156
  });
@@ -1233,13 +1232,13 @@ async function prepareTools({
1233
1232
 
1234
1233
  // src/convert-to-anthropic-messages-prompt.ts
1235
1234
  var import_provider2 = require("@ai-sdk/provider");
1236
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1235
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1237
1236
 
1238
1237
  // src/tool/code-execution_20250522.ts
1239
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1238
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1240
1239
  var import_v47 = require("zod/v4");
1241
- var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
1242
- () => (0, import_provider_utils8.zodSchema)(
1240
+ var codeExecution_20250522OutputSchema = (0, import_provider_utils7.lazySchema)(
1241
+ () => (0, import_provider_utils7.zodSchema)(
1243
1242
  import_v47.z.object({
1244
1243
  type: import_v47.z.literal("code_execution_result"),
1245
1244
  stdout: import_v47.z.string(),
@@ -1248,14 +1247,14 @@ var codeExecution_20250522OutputSchema = (0, import_provider_utils8.lazySchema)(
1248
1247
  })
1249
1248
  )
1250
1249
  );
1251
- var codeExecution_20250522InputSchema = (0, import_provider_utils8.lazySchema)(
1252
- () => (0, import_provider_utils8.zodSchema)(
1250
+ var codeExecution_20250522InputSchema = (0, import_provider_utils7.lazySchema)(
1251
+ () => (0, import_provider_utils7.zodSchema)(
1253
1252
  import_v47.z.object({
1254
1253
  code: import_v47.z.string()
1255
1254
  })
1256
1255
  )
1257
1256
  );
1258
- var factory4 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
1257
+ var factory4 = (0, import_provider_utils7.createProviderDefinedToolFactoryWithOutputSchema)({
1259
1258
  id: "anthropic.code_execution_20250522",
1260
1259
  name: "code_execution",
1261
1260
  inputSchema: codeExecution_20250522InputSchema,
@@ -1266,10 +1265,10 @@ var codeExecution_20250522 = (args = {}) => {
1266
1265
  };
1267
1266
 
1268
1267
  // src/tool/code-execution_20250825.ts
1269
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1268
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1270
1269
  var import_v48 = require("zod/v4");
1271
- var codeExecution_20250825OutputSchema = (0, import_provider_utils9.lazySchema)(
1272
- () => (0, import_provider_utils9.zodSchema)(
1270
+ var codeExecution_20250825OutputSchema = (0, import_provider_utils8.lazySchema)(
1271
+ () => (0, import_provider_utils8.zodSchema)(
1273
1272
  import_v48.z.discriminatedUnion("type", [
1274
1273
  import_v48.z.object({
1275
1274
  type: import_v48.z.literal("bash_code_execution_result"),
@@ -1314,8 +1313,8 @@ var codeExecution_20250825OutputSchema = (0, import_provider_utils9.lazySchema)(
1314
1313
  ])
1315
1314
  )
1316
1315
  );
1317
- var codeExecution_20250825InputSchema = (0, import_provider_utils9.lazySchema)(
1318
- () => (0, import_provider_utils9.zodSchema)(
1316
+ var codeExecution_20250825InputSchema = (0, import_provider_utils8.lazySchema)(
1317
+ () => (0, import_provider_utils8.zodSchema)(
1319
1318
  import_v48.z.discriminatedUnion("type", [
1320
1319
  import_v48.z.object({
1321
1320
  type: import_v48.z.literal("bash_code_execution"),
@@ -1344,7 +1343,7 @@ var codeExecution_20250825InputSchema = (0, import_provider_utils9.lazySchema)(
1344
1343
  ])
1345
1344
  )
1346
1345
  );
1347
- var factory5 = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
1346
+ var factory5 = (0, import_provider_utils8.createProviderDefinedToolFactoryWithOutputSchema)({
1348
1347
  id: "anthropic.code_execution_20250825",
1349
1348
  name: "code_execution",
1350
1349
  inputSchema: codeExecution_20250825InputSchema,
@@ -1385,7 +1384,7 @@ async function convertToAnthropicMessagesPrompt({
1385
1384
  const messages = [];
1386
1385
  async function shouldEnableCitations(providerMetadata) {
1387
1386
  var _a2, _b2;
1388
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1387
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1389
1388
  provider: "anthropic",
1390
1389
  providerOptions: providerMetadata,
1391
1390
  schema: anthropicFilePartProviderOptions
@@ -1393,7 +1392,7 @@ async function convertToAnthropicMessagesPrompt({
1393
1392
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1394
1393
  }
1395
1394
  async function getDocumentMetadata(providerMetadata) {
1396
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1395
+ const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1397
1396
  provider: "anthropic",
1398
1397
  providerOptions: providerMetadata,
1399
1398
  schema: anthropicFilePartProviderOptions
@@ -1459,7 +1458,7 @@ async function convertToAnthropicMessagesPrompt({
1459
1458
  } : {
1460
1459
  type: "base64",
1461
1460
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
1462
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1461
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
1463
1462
  },
1464
1463
  cache_control: cacheControl
1465
1464
  });
@@ -1479,7 +1478,7 @@ async function convertToAnthropicMessagesPrompt({
1479
1478
  } : {
1480
1479
  type: "base64",
1481
1480
  media_type: "application/pdf",
1482
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1481
+ data: (0, import_provider_utils9.convertToBase64)(part.data)
1483
1482
  },
1484
1483
  title: (_b = metadata.title) != null ? _b : part.filename,
1485
1484
  ...metadata.context && { context: metadata.context },
@@ -1644,7 +1643,7 @@ async function convertToAnthropicMessagesPrompt({
1644
1643
  }
1645
1644
  case "reasoning": {
1646
1645
  if (sendReasoning) {
1647
- const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1646
+ const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
1648
1647
  provider: "anthropic",
1649
1648
  providerOptions: part.providerOptions,
1650
1649
  schema: anthropicReasoningMetadataSchema
@@ -1744,7 +1743,7 @@ async function convertToAnthropicMessagesPrompt({
1744
1743
  break;
1745
1744
  }
1746
1745
  if (output.value.type === "code_execution_result") {
1747
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1746
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1748
1747
  value: output.value,
1749
1748
  schema: codeExecution_20250522OutputSchema
1750
1749
  });
@@ -1760,7 +1759,7 @@ async function convertToAnthropicMessagesPrompt({
1760
1759
  cache_control: cacheControl
1761
1760
  });
1762
1761
  } else {
1763
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1762
+ const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1764
1763
  value: output.value,
1765
1764
  schema: codeExecution_20250825OutputSchema
1766
1765
  });
@@ -1789,7 +1788,7 @@ async function convertToAnthropicMessagesPrompt({
1789
1788
  });
1790
1789
  break;
1791
1790
  }
1792
- const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1791
+ const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1793
1792
  value: output.value,
1794
1793
  schema: webFetch_20250910OutputSchema
1795
1794
  });
@@ -1824,7 +1823,7 @@ async function convertToAnthropicMessagesPrompt({
1824
1823
  });
1825
1824
  break;
1826
1825
  }
1827
- const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1826
+ const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1828
1827
  value: output.value,
1829
1828
  schema: webSearch_20250305OutputSchema
1830
1829
  });
@@ -1935,6 +1934,152 @@ function mapAnthropicStopReason({
1935
1934
  }
1936
1935
  }
1937
1936
 
1937
+ // src/sanitize-json-schema.ts
1938
+ var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
1939
+ "date-time",
1940
+ "time",
1941
+ "date",
1942
+ "duration",
1943
+ "email",
1944
+ "hostname",
1945
+ "uri",
1946
+ "ipv4",
1947
+ "ipv6",
1948
+ "uuid"
1949
+ ]);
1950
+ var DESCRIPTION_CONSTRAINT_KEYS = [
1951
+ "minimum",
1952
+ "maximum",
1953
+ "exclusiveMinimum",
1954
+ "exclusiveMaximum",
1955
+ "multipleOf",
1956
+ "minLength",
1957
+ "maxLength",
1958
+ "pattern",
1959
+ "minItems",
1960
+ "maxItems",
1961
+ "uniqueItems",
1962
+ "minProperties",
1963
+ "maxProperties",
1964
+ "not"
1965
+ ];
1966
+ function sanitizeJsonSchema(schema) {
1967
+ return sanitizeSchema(schema);
1968
+ }
1969
+ function sanitizeDefinition(definition) {
1970
+ if (typeof definition === "boolean" || !isPlainObject(definition)) {
1971
+ return definition;
1972
+ }
1973
+ return sanitizeSchema(definition);
1974
+ }
1975
+ function sanitizeSchema(schema) {
1976
+ const result = {};
1977
+ const schemaWithDefs = schema;
1978
+ if (schema.$ref != null) {
1979
+ return { $ref: schema.$ref };
1980
+ }
1981
+ if (schema.$schema != null) {
1982
+ result.$schema = schema.$schema;
1983
+ }
1984
+ if (schema.$id != null) {
1985
+ result.$id = schema.$id;
1986
+ }
1987
+ if (schema.title != null) {
1988
+ result.title = schema.title;
1989
+ }
1990
+ if (schema.description != null) {
1991
+ result.description = schema.description;
1992
+ }
1993
+ if (schema.default !== void 0) {
1994
+ result.default = schema.default;
1995
+ }
1996
+ if (schema.const !== void 0) {
1997
+ result.const = schema.const;
1998
+ }
1999
+ if (schema.enum != null) {
2000
+ result.enum = schema.enum;
2001
+ }
2002
+ if (schema.type != null) {
2003
+ result.type = schema.type;
2004
+ }
2005
+ if (schema.anyOf != null) {
2006
+ result.anyOf = schema.anyOf.map(sanitizeDefinition);
2007
+ } else if (schema.oneOf != null) {
2008
+ result.anyOf = schema.oneOf.map(sanitizeDefinition);
2009
+ }
2010
+ if (schema.allOf != null) {
2011
+ result.allOf = schema.allOf.map(sanitizeDefinition);
2012
+ }
2013
+ if (schema.definitions != null) {
2014
+ result.definitions = Object.fromEntries(
2015
+ Object.entries(schema.definitions).map(([name, definition]) => [
2016
+ name,
2017
+ sanitizeDefinition(definition)
2018
+ ])
2019
+ );
2020
+ }
2021
+ if (schemaWithDefs.$defs != null) {
2022
+ const resultWithDefs = result;
2023
+ resultWithDefs.$defs = Object.fromEntries(
2024
+ Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
2025
+ name,
2026
+ sanitizeDefinition(definition)
2027
+ ])
2028
+ );
2029
+ }
2030
+ if (schema.type === "object" || schema.properties != null) {
2031
+ if (schema.properties != null) {
2032
+ result.properties = Object.fromEntries(
2033
+ Object.entries(schema.properties).map(([name, definition]) => [
2034
+ name,
2035
+ sanitizeDefinition(definition)
2036
+ ])
2037
+ );
2038
+ }
2039
+ result.additionalProperties = false;
2040
+ if (schema.required != null) {
2041
+ result.required = schema.required;
2042
+ }
2043
+ }
2044
+ if (schema.items != null) {
2045
+ result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
2046
+ }
2047
+ if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
2048
+ result.format = schema.format;
2049
+ }
2050
+ const constraintDescription = getConstraintDescription(schema);
2051
+ if (constraintDescription != null) {
2052
+ result.description = result.description == null ? constraintDescription : `${result.description}
2053
+ ${constraintDescription}`;
2054
+ }
2055
+ return result;
2056
+ }
2057
+ function getConstraintDescription(schema) {
2058
+ const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
2059
+ const value = schema[key];
2060
+ if (value == null || value === false) {
2061
+ return [];
2062
+ }
2063
+ return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
2064
+ });
2065
+ if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
2066
+ descriptions.push(`format: ${schema.format}`);
2067
+ }
2068
+ return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
2069
+ }
2070
+ function formatConstraintName(key) {
2071
+ return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
2072
+ }
2073
+ function formatConstraintValue(value) {
2074
+ if (typeof value === "string") {
2075
+ return value;
2076
+ }
2077
+ return JSON.stringify(value);
2078
+ }
2079
+ function isPlainObject(value) {
2080
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2081
+ }
2082
+
1938
2083
  // src/anthropic-messages-language-model.ts
1939
2084
  function createCitationSource(citation, citationDocuments, generateId3) {
1940
2085
  var _a;
@@ -1971,7 +2116,7 @@ var AnthropicMessagesLanguageModel = class {
1971
2116
  var _a;
1972
2117
  this.modelId = modelId;
1973
2118
  this.config = config;
1974
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
2119
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1975
2120
  }
1976
2121
  supportsUrl(url) {
1977
2122
  return url.protocol === "https:";
@@ -2049,7 +2194,7 @@ var AnthropicMessagesLanguageModel = class {
2049
2194
  });
2050
2195
  }
2051
2196
  }
2052
- const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
2197
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
2053
2198
  provider: "anthropic",
2054
2199
  providerOptions,
2055
2200
  schema: anthropicProviderOptions
@@ -2141,7 +2286,7 @@ var AnthropicMessagesLanguageModel = class {
2141
2286
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2142
2287
  format: {
2143
2288
  type: "json_schema",
2144
- schema: responseFormat.schema
2289
+ schema: sanitizeJsonSchema(responseFormat.schema)
2145
2290
  }
2146
2291
  }
2147
2292
  }
@@ -2158,13 +2303,6 @@ var AnthropicMessagesLanguageModel = class {
2158
2303
  ...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
2159
2304
  metadata: { user_id: anthropicOptions.metadata.userId }
2160
2305
  },
2161
- // structured output:
2162
- ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2163
- output_format: {
2164
- type: "json_schema",
2165
- schema: responseFormat.schema
2166
- }
2167
- },
2168
2306
  // container with agent skills:
2169
2307
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2170
2308
  container: {
@@ -2350,15 +2488,15 @@ var AnthropicMessagesLanguageModel = class {
2350
2488
  betas,
2351
2489
  headers
2352
2490
  }) {
2353
- return (0, import_provider_utils11.combineHeaders)(
2354
- await (0, import_provider_utils11.resolve)(this.config.headers),
2491
+ return (0, import_provider_utils10.combineHeaders)(
2492
+ await (0, import_provider_utils10.resolve)(this.config.headers),
2355
2493
  headers,
2356
2494
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
2357
2495
  );
2358
2496
  }
2359
2497
  async getBetasFromHeaders(requestHeaders) {
2360
2498
  var _a, _b;
2361
- const configHeaders = await (0, import_provider_utils11.resolve)(this.config.headers);
2499
+ const configHeaders = await (0, import_provider_utils10.resolve)(this.config.headers);
2362
2500
  const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
2363
2501
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
2364
2502
  return new Set(
@@ -2410,12 +2548,12 @@ var AnthropicMessagesLanguageModel = class {
2410
2548
  responseHeaders,
2411
2549
  value: response,
2412
2550
  rawValue: rawResponse
2413
- } = await (0, import_provider_utils11.postJsonToApi)({
2551
+ } = await (0, import_provider_utils10.postJsonToApi)({
2414
2552
  url: this.buildRequestUrl(false),
2415
2553
  headers: await this.getHeaders({ betas, headers: options.headers }),
2416
2554
  body: this.transformRequestBody(args, betas),
2417
2555
  failedResponseHandler: anthropicFailedResponseHandler,
2418
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2556
+ successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
2419
2557
  anthropicMessagesResponseSchema
2420
2558
  ),
2421
2559
  abortSignal: options.abortSignal,
@@ -2735,12 +2873,12 @@ var AnthropicMessagesLanguageModel = class {
2735
2873
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2736
2874
  const body = { ...args, stream: true };
2737
2875
  const url = this.buildRequestUrl(true);
2738
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2876
+ const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
2739
2877
  url,
2740
2878
  headers: await this.getHeaders({ betas, headers: options.headers }),
2741
2879
  body: this.transformRequestBody(body, betas),
2742
2880
  failedResponseHandler: anthropicFailedResponseHandler,
2743
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2881
+ successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
2744
2882
  anthropicMessagesChunkSchema
2745
2883
  ),
2746
2884
  abortSignal: options.abortSignal,
@@ -3372,44 +3510,44 @@ function getModelCapabilities(modelId) {
3372
3510
  }
3373
3511
 
3374
3512
  // src/tool/bash_20241022.ts
3375
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
3513
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
3376
3514
  var import_v49 = require("zod/v4");
3377
- var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
3378
- () => (0, import_provider_utils12.zodSchema)(
3515
+ var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
3516
+ () => (0, import_provider_utils11.zodSchema)(
3379
3517
  import_v49.z.object({
3380
3518
  command: import_v49.z.string(),
3381
3519
  restart: import_v49.z.boolean().optional()
3382
3520
  })
3383
3521
  )
3384
3522
  );
3385
- var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
3523
+ var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
3386
3524
  id: "anthropic.bash_20241022",
3387
3525
  name: "bash",
3388
3526
  inputSchema: bash_20241022InputSchema
3389
3527
  });
3390
3528
 
3391
3529
  // src/tool/bash_20250124.ts
3392
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
3530
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
3393
3531
  var import_v410 = require("zod/v4");
3394
- var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
3395
- () => (0, import_provider_utils13.zodSchema)(
3532
+ var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
3533
+ () => (0, import_provider_utils12.zodSchema)(
3396
3534
  import_v410.z.object({
3397
3535
  command: import_v410.z.string(),
3398
3536
  restart: import_v410.z.boolean().optional()
3399
3537
  })
3400
3538
  )
3401
3539
  );
3402
- var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
3540
+ var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
3403
3541
  id: "anthropic.bash_20250124",
3404
3542
  name: "bash",
3405
3543
  inputSchema: bash_20250124InputSchema
3406
3544
  });
3407
3545
 
3408
3546
  // src/tool/code-execution_20260120.ts
3409
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
3547
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
3410
3548
  var import_v411 = require("zod/v4");
3411
- var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)(
3412
- () => (0, import_provider_utils14.zodSchema)(
3549
+ var codeExecution_20260120OutputSchema = (0, import_provider_utils13.lazySchema)(
3550
+ () => (0, import_provider_utils13.zodSchema)(
3413
3551
  import_v411.z.discriminatedUnion("type", [
3414
3552
  import_v411.z.object({
3415
3553
  type: import_v411.z.literal("code_execution_result"),
@@ -3466,8 +3604,8 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)
3466
3604
  ])
3467
3605
  )
3468
3606
  );
3469
- var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3470
- () => (0, import_provider_utils14.zodSchema)(
3607
+ var codeExecution_20260120InputSchema = (0, import_provider_utils13.lazySchema)(
3608
+ () => (0, import_provider_utils13.zodSchema)(
3471
3609
  import_v411.z.discriminatedUnion("type", [
3472
3610
  import_v411.z.object({
3473
3611
  type: import_v411.z.literal("programmatic-tool-call"),
@@ -3500,7 +3638,7 @@ var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3500
3638
  ])
3501
3639
  )
3502
3640
  );
3503
- var factory6 = (0, import_provider_utils14.createProviderDefinedToolFactoryWithOutputSchema)({
3641
+ var factory6 = (0, import_provider_utils13.createProviderDefinedToolFactoryWithOutputSchema)({
3504
3642
  id: "anthropic.code_execution_20260120",
3505
3643
  name: "code_execution",
3506
3644
  inputSchema: codeExecution_20260120InputSchema,
@@ -3511,10 +3649,10 @@ var codeExecution_20260120 = (args = {}) => {
3511
3649
  };
3512
3650
 
3513
3651
  // src/tool/computer_20241022.ts
3514
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
3652
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
3515
3653
  var import_v412 = require("zod/v4");
3516
- var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3517
- () => (0, import_provider_utils15.zodSchema)(
3654
+ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3655
+ () => (0, import_provider_utils14.zodSchema)(
3518
3656
  import_v412.z.object({
3519
3657
  action: import_v412.z.enum([
3520
3658
  "key",
@@ -3533,17 +3671,17 @@ var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3533
3671
  })
3534
3672
  )
3535
3673
  );
3536
- var computer_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3674
+ var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
3537
3675
  id: "anthropic.computer_20241022",
3538
3676
  name: "computer",
3539
3677
  inputSchema: computer_20241022InputSchema
3540
3678
  });
3541
3679
 
3542
3680
  // src/tool/computer_20250124.ts
3543
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3681
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
3544
3682
  var import_v413 = require("zod/v4");
3545
- var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3546
- () => (0, import_provider_utils16.zodSchema)(
3683
+ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3684
+ () => (0, import_provider_utils15.zodSchema)(
3547
3685
  import_v413.z.object({
3548
3686
  action: import_v413.z.enum([
3549
3687
  "key",
@@ -3572,17 +3710,17 @@ var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3572
3710
  })
3573
3711
  )
3574
3712
  );
3575
- var computer_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3713
+ var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3576
3714
  id: "anthropic.computer_20250124",
3577
3715
  name: "computer",
3578
3716
  inputSchema: computer_20250124InputSchema
3579
3717
  });
3580
3718
 
3581
3719
  // src/tool/memory_20250818.ts
3582
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
3720
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
3583
3721
  var import_v414 = require("zod/v4");
3584
- var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3585
- () => (0, import_provider_utils17.zodSchema)(
3722
+ var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
3723
+ () => (0, import_provider_utils16.zodSchema)(
3586
3724
  import_v414.z.discriminatedUnion("command", [
3587
3725
  import_v414.z.object({
3588
3726
  command: import_v414.z.literal("view"),
@@ -3618,17 +3756,17 @@ var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3618
3756
  ])
3619
3757
  )
3620
3758
  );
3621
- var memory_20250818 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3759
+ var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3622
3760
  id: "anthropic.memory_20250818",
3623
3761
  name: "memory",
3624
3762
  inputSchema: memory_20250818InputSchema
3625
3763
  });
3626
3764
 
3627
3765
  // src/tool/text-editor_20241022.ts
3628
- var import_provider_utils18 = require("@ai-sdk/provider-utils");
3766
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
3629
3767
  var import_v415 = require("zod/v4");
3630
- var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3631
- () => (0, import_provider_utils18.zodSchema)(
3768
+ var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
3769
+ () => (0, import_provider_utils17.zodSchema)(
3632
3770
  import_v415.z.object({
3633
3771
  command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3634
3772
  path: import_v415.z.string(),
@@ -3640,17 +3778,17 @@ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3640
3778
  })
3641
3779
  )
3642
3780
  );
3643
- var textEditor_20241022 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3781
+ var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3644
3782
  id: "anthropic.text_editor_20241022",
3645
3783
  name: "str_replace_editor",
3646
3784
  inputSchema: textEditor_20241022InputSchema
3647
3785
  });
3648
3786
 
3649
3787
  // src/tool/text-editor_20250124.ts
3650
- var import_provider_utils19 = require("@ai-sdk/provider-utils");
3788
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
3651
3789
  var import_v416 = require("zod/v4");
3652
- var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3653
- () => (0, import_provider_utils19.zodSchema)(
3790
+ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3791
+ () => (0, import_provider_utils18.zodSchema)(
3654
3792
  import_v416.z.object({
3655
3793
  command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3656
3794
  path: import_v416.z.string(),
@@ -3662,17 +3800,17 @@ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3662
3800
  })
3663
3801
  )
3664
3802
  );
3665
- var textEditor_20250124 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3803
+ var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3666
3804
  id: "anthropic.text_editor_20250124",
3667
3805
  name: "str_replace_editor",
3668
3806
  inputSchema: textEditor_20250124InputSchema
3669
3807
  });
3670
3808
 
3671
3809
  // src/tool/text-editor_20250429.ts
3672
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
3810
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
3673
3811
  var import_v417 = require("zod/v4");
3674
- var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3675
- () => (0, import_provider_utils20.zodSchema)(
3812
+ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3813
+ () => (0, import_provider_utils19.zodSchema)(
3676
3814
  import_v417.z.object({
3677
3815
  command: import_v417.z.enum(["view", "create", "str_replace", "insert"]),
3678
3816
  path: import_v417.z.string(),
@@ -3684,7 +3822,7 @@ var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3684
3822
  })
3685
3823
  )
3686
3824
  );
3687
- var textEditor_20250429 = (0, import_provider_utils20.createProviderDefinedToolFactory)({
3825
+ var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3688
3826
  id: "anthropic.text_editor_20250429",
3689
3827
  name: "str_replace_based_edit_tool",
3690
3828
  inputSchema: textEditor_20250429InputSchema
@@ -3858,17 +3996,17 @@ var anthropicTools = {
3858
3996
  // src/anthropic-provider.ts
3859
3997
  function createAnthropic(options = {}) {
3860
3998
  var _a, _b;
3861
- const baseURL = (_a = (0, import_provider_utils21.withoutTrailingSlash)(
3862
- (0, import_provider_utils21.loadOptionalSetting)({
3999
+ const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(
4000
+ (0, import_provider_utils20.loadOptionalSetting)({
3863
4001
  settingValue: options.baseURL,
3864
4002
  environmentVariableName: "ANTHROPIC_BASE_URL"
3865
4003
  })
3866
4004
  )) != null ? _a : "https://api.anthropic.com/v1";
3867
4005
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
3868
- const getHeaders = () => (0, import_provider_utils21.withUserAgentSuffix)(
4006
+ const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
3869
4007
  {
3870
4008
  "anthropic-version": "2023-06-01",
3871
- "x-api-key": (0, import_provider_utils21.loadApiKey)({
4009
+ "x-api-key": (0, import_provider_utils20.loadApiKey)({
3872
4010
  apiKey: options.apiKey,
3873
4011
  environmentVariableName: "ANTHROPIC_API_KEY",
3874
4012
  description: "Anthropic"
@@ -3884,7 +4022,7 @@ function createAnthropic(options = {}) {
3884
4022
  baseURL,
3885
4023
  headers: getHeaders,
3886
4024
  fetch: options.fetch,
3887
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils21.generateId,
4025
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils20.generateId,
3888
4026
  supportedUrls: () => ({
3889
4027
  "image/*": [/^https?:\/\/.*$/]
3890
4028
  })