@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.
- package/CHANGELOG.md +16 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +257 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +166 -20
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +1 -1
- package/dist/internal/index.d.ts +1 -1
- package/dist/internal/index.js +250 -111
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +165 -19
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +4 -4
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
|
|
31
|
+
var import_provider_utils20 = require("@ai-sdk/provider-utils");
|
|
32
32
|
|
|
33
33
|
// src/version.ts
|
|
34
|
-
var VERSION = true ? "2.0.
|
|
34
|
+
var VERSION = true ? "2.0.80" : "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
|
|
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
|
|
849
|
-
|
|
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,
|
|
857
|
-
() => (0,
|
|
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
|
|
878
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
880
879
|
var import_v45 = require("zod/v4");
|
|
881
|
-
var webSearch_20250305ArgsSchema = (0,
|
|
882
|
-
() => (0,
|
|
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,
|
|
898
|
-
() => (0,
|
|
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,
|
|
911
|
-
() => (0,
|
|
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,
|
|
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
|
|
927
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
929
928
|
var import_v46 = require("zod/v4");
|
|
930
|
-
var webFetch_20250910ArgsSchema = (0,
|
|
931
|
-
() => (0,
|
|
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,
|
|
942
|
-
() => (0,
|
|
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,
|
|
968
|
-
() => (0,
|
|
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,
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
|
1235
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1237
1236
|
|
|
1238
1237
|
// src/tool/code-execution_20250522.ts
|
|
1239
|
-
var
|
|
1238
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1240
1239
|
var import_v47 = require("zod/v4");
|
|
1241
|
-
var codeExecution_20250522OutputSchema = (0,
|
|
1242
|
-
() => (0,
|
|
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,
|
|
1252
|
-
() => (0,
|
|
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,
|
|
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
|
|
1268
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1270
1269
|
var import_v48 = require("zod/v4");
|
|
1271
|
-
var codeExecution_20250825OutputSchema = (0,
|
|
1272
|
-
() => (0,
|
|
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,
|
|
1318
|
-
() => (0,
|
|
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,
|
|
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,
|
|
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,
|
|
1395
|
+
const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
|
|
1397
1396
|
provider: "anthropic",
|
|
1398
1397
|
providerOptions: providerMetadata,
|
|
1399
1398
|
schema: anthropicFilePartProviderOptions
|
|
@@ -1409,19 +1408,20 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1409
1408
|
const type = block.type;
|
|
1410
1409
|
switch (type) {
|
|
1411
1410
|
case "system": {
|
|
1412
|
-
|
|
1413
|
-
throw new import_provider2.UnsupportedFunctionalityError({
|
|
1414
|
-
functionality: "Multiple system messages that are separated by user/assistant messages"
|
|
1415
|
-
});
|
|
1416
|
-
}
|
|
1417
|
-
system = block.messages.map(({ content, providerOptions }) => ({
|
|
1411
|
+
const content = block.messages.map(({ content: content2, providerOptions }) => ({
|
|
1418
1412
|
type: "text",
|
|
1419
|
-
text:
|
|
1413
|
+
text: content2,
|
|
1420
1414
|
cache_control: validator.getCacheControl(providerOptions, {
|
|
1421
1415
|
type: "system message",
|
|
1422
1416
|
canCache: true
|
|
1423
1417
|
})
|
|
1424
1418
|
}));
|
|
1419
|
+
if (system == null) {
|
|
1420
|
+
system = content;
|
|
1421
|
+
} else {
|
|
1422
|
+
messages.push({ role: "system", content });
|
|
1423
|
+
betas.add("mid-conversation-system-2026-04-07");
|
|
1424
|
+
}
|
|
1425
1425
|
break;
|
|
1426
1426
|
}
|
|
1427
1427
|
case "user": {
|
|
@@ -1459,7 +1459,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1459
1459
|
} : {
|
|
1460
1460
|
type: "base64",
|
|
1461
1461
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
1462
|
-
data: (0,
|
|
1462
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
1463
1463
|
},
|
|
1464
1464
|
cache_control: cacheControl
|
|
1465
1465
|
});
|
|
@@ -1479,7 +1479,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1479
1479
|
} : {
|
|
1480
1480
|
type: "base64",
|
|
1481
1481
|
media_type: "application/pdf",
|
|
1482
|
-
data: (0,
|
|
1482
|
+
data: (0, import_provider_utils9.convertToBase64)(part.data)
|
|
1483
1483
|
},
|
|
1484
1484
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
1485
1485
|
...metadata.context && { context: metadata.context },
|
|
@@ -1644,7 +1644,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1644
1644
|
}
|
|
1645
1645
|
case "reasoning": {
|
|
1646
1646
|
if (sendReasoning) {
|
|
1647
|
-
const reasoningMetadata = await (0,
|
|
1647
|
+
const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
|
|
1648
1648
|
provider: "anthropic",
|
|
1649
1649
|
providerOptions: part.providerOptions,
|
|
1650
1650
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -1744,7 +1744,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1744
1744
|
break;
|
|
1745
1745
|
}
|
|
1746
1746
|
if (output.value.type === "code_execution_result") {
|
|
1747
|
-
const codeExecutionOutput = await (0,
|
|
1747
|
+
const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1748
1748
|
value: output.value,
|
|
1749
1749
|
schema: codeExecution_20250522OutputSchema
|
|
1750
1750
|
});
|
|
@@ -1760,7 +1760,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1760
1760
|
cache_control: cacheControl
|
|
1761
1761
|
});
|
|
1762
1762
|
} else {
|
|
1763
|
-
const codeExecutionOutput = await (0,
|
|
1763
|
+
const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1764
1764
|
value: output.value,
|
|
1765
1765
|
schema: codeExecution_20250825OutputSchema
|
|
1766
1766
|
});
|
|
@@ -1789,7 +1789,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1789
1789
|
});
|
|
1790
1790
|
break;
|
|
1791
1791
|
}
|
|
1792
|
-
const webFetchOutput = await (0,
|
|
1792
|
+
const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1793
1793
|
value: output.value,
|
|
1794
1794
|
schema: webFetch_20250910OutputSchema
|
|
1795
1795
|
});
|
|
@@ -1824,7 +1824,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
1824
1824
|
});
|
|
1825
1825
|
break;
|
|
1826
1826
|
}
|
|
1827
|
-
const webSearchOutput = await (0,
|
|
1827
|
+
const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
|
|
1828
1828
|
value: output.value,
|
|
1829
1829
|
schema: webSearch_20250305OutputSchema
|
|
1830
1830
|
});
|
|
@@ -1935,6 +1935,152 @@ function mapAnthropicStopReason({
|
|
|
1935
1935
|
}
|
|
1936
1936
|
}
|
|
1937
1937
|
|
|
1938
|
+
// src/sanitize-json-schema.ts
|
|
1939
|
+
var SUPPORTED_STRING_FORMATS = /* @__PURE__ */ new Set([
|
|
1940
|
+
"date-time",
|
|
1941
|
+
"time",
|
|
1942
|
+
"date",
|
|
1943
|
+
"duration",
|
|
1944
|
+
"email",
|
|
1945
|
+
"hostname",
|
|
1946
|
+
"uri",
|
|
1947
|
+
"ipv4",
|
|
1948
|
+
"ipv6",
|
|
1949
|
+
"uuid"
|
|
1950
|
+
]);
|
|
1951
|
+
var DESCRIPTION_CONSTRAINT_KEYS = [
|
|
1952
|
+
"minimum",
|
|
1953
|
+
"maximum",
|
|
1954
|
+
"exclusiveMinimum",
|
|
1955
|
+
"exclusiveMaximum",
|
|
1956
|
+
"multipleOf",
|
|
1957
|
+
"minLength",
|
|
1958
|
+
"maxLength",
|
|
1959
|
+
"pattern",
|
|
1960
|
+
"minItems",
|
|
1961
|
+
"maxItems",
|
|
1962
|
+
"uniqueItems",
|
|
1963
|
+
"minProperties",
|
|
1964
|
+
"maxProperties",
|
|
1965
|
+
"not"
|
|
1966
|
+
];
|
|
1967
|
+
function sanitizeJsonSchema(schema) {
|
|
1968
|
+
return sanitizeSchema(schema);
|
|
1969
|
+
}
|
|
1970
|
+
function sanitizeDefinition(definition) {
|
|
1971
|
+
if (typeof definition === "boolean" || !isPlainObject(definition)) {
|
|
1972
|
+
return definition;
|
|
1973
|
+
}
|
|
1974
|
+
return sanitizeSchema(definition);
|
|
1975
|
+
}
|
|
1976
|
+
function sanitizeSchema(schema) {
|
|
1977
|
+
const result = {};
|
|
1978
|
+
const schemaWithDefs = schema;
|
|
1979
|
+
if (schema.$ref != null) {
|
|
1980
|
+
return { $ref: schema.$ref };
|
|
1981
|
+
}
|
|
1982
|
+
if (schema.$schema != null) {
|
|
1983
|
+
result.$schema = schema.$schema;
|
|
1984
|
+
}
|
|
1985
|
+
if (schema.$id != null) {
|
|
1986
|
+
result.$id = schema.$id;
|
|
1987
|
+
}
|
|
1988
|
+
if (schema.title != null) {
|
|
1989
|
+
result.title = schema.title;
|
|
1990
|
+
}
|
|
1991
|
+
if (schema.description != null) {
|
|
1992
|
+
result.description = schema.description;
|
|
1993
|
+
}
|
|
1994
|
+
if (schema.default !== void 0) {
|
|
1995
|
+
result.default = schema.default;
|
|
1996
|
+
}
|
|
1997
|
+
if (schema.const !== void 0) {
|
|
1998
|
+
result.const = schema.const;
|
|
1999
|
+
}
|
|
2000
|
+
if (schema.enum != null) {
|
|
2001
|
+
result.enum = schema.enum;
|
|
2002
|
+
}
|
|
2003
|
+
if (schema.type != null) {
|
|
2004
|
+
result.type = schema.type;
|
|
2005
|
+
}
|
|
2006
|
+
if (schema.anyOf != null) {
|
|
2007
|
+
result.anyOf = schema.anyOf.map(sanitizeDefinition);
|
|
2008
|
+
} else if (schema.oneOf != null) {
|
|
2009
|
+
result.anyOf = schema.oneOf.map(sanitizeDefinition);
|
|
2010
|
+
}
|
|
2011
|
+
if (schema.allOf != null) {
|
|
2012
|
+
result.allOf = schema.allOf.map(sanitizeDefinition);
|
|
2013
|
+
}
|
|
2014
|
+
if (schema.definitions != null) {
|
|
2015
|
+
result.definitions = Object.fromEntries(
|
|
2016
|
+
Object.entries(schema.definitions).map(([name, definition]) => [
|
|
2017
|
+
name,
|
|
2018
|
+
sanitizeDefinition(definition)
|
|
2019
|
+
])
|
|
2020
|
+
);
|
|
2021
|
+
}
|
|
2022
|
+
if (schemaWithDefs.$defs != null) {
|
|
2023
|
+
const resultWithDefs = result;
|
|
2024
|
+
resultWithDefs.$defs = Object.fromEntries(
|
|
2025
|
+
Object.entries(schemaWithDefs.$defs).map(([name, definition]) => [
|
|
2026
|
+
name,
|
|
2027
|
+
sanitizeDefinition(definition)
|
|
2028
|
+
])
|
|
2029
|
+
);
|
|
2030
|
+
}
|
|
2031
|
+
if (schema.type === "object" || schema.properties != null) {
|
|
2032
|
+
if (schema.properties != null) {
|
|
2033
|
+
result.properties = Object.fromEntries(
|
|
2034
|
+
Object.entries(schema.properties).map(([name, definition]) => [
|
|
2035
|
+
name,
|
|
2036
|
+
sanitizeDefinition(definition)
|
|
2037
|
+
])
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
2040
|
+
result.additionalProperties = false;
|
|
2041
|
+
if (schema.required != null) {
|
|
2042
|
+
result.required = schema.required;
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
if (schema.items != null) {
|
|
2046
|
+
result.items = Array.isArray(schema.items) ? schema.items.map(sanitizeDefinition) : sanitizeDefinition(schema.items);
|
|
2047
|
+
}
|
|
2048
|
+
if (typeof schema.format === "string" && SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
2049
|
+
result.format = schema.format;
|
|
2050
|
+
}
|
|
2051
|
+
const constraintDescription = getConstraintDescription(schema);
|
|
2052
|
+
if (constraintDescription != null) {
|
|
2053
|
+
result.description = result.description == null ? constraintDescription : `${result.description}
|
|
2054
|
+
${constraintDescription}`;
|
|
2055
|
+
}
|
|
2056
|
+
return result;
|
|
2057
|
+
}
|
|
2058
|
+
function getConstraintDescription(schema) {
|
|
2059
|
+
const descriptions = DESCRIPTION_CONSTRAINT_KEYS.flatMap((key) => {
|
|
2060
|
+
const value = schema[key];
|
|
2061
|
+
if (value == null || value === false) {
|
|
2062
|
+
return [];
|
|
2063
|
+
}
|
|
2064
|
+
return `${formatConstraintName(key)}: ${formatConstraintValue(value)}`;
|
|
2065
|
+
});
|
|
2066
|
+
if (typeof schema.format === "string" && !SUPPORTED_STRING_FORMATS.has(schema.format)) {
|
|
2067
|
+
descriptions.push(`format: ${schema.format}`);
|
|
2068
|
+
}
|
|
2069
|
+
return descriptions.length === 0 ? void 0 : `${descriptions.join("; ")}.`;
|
|
2070
|
+
}
|
|
2071
|
+
function formatConstraintName(key) {
|
|
2072
|
+
return key.replace(/[A-Z]/g, (match) => ` ${match.toLowerCase()}`);
|
|
2073
|
+
}
|
|
2074
|
+
function formatConstraintValue(value) {
|
|
2075
|
+
if (typeof value === "string") {
|
|
2076
|
+
return value;
|
|
2077
|
+
}
|
|
2078
|
+
return JSON.stringify(value);
|
|
2079
|
+
}
|
|
2080
|
+
function isPlainObject(value) {
|
|
2081
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1938
2084
|
// src/anthropic-messages-language-model.ts
|
|
1939
2085
|
function createCitationSource(citation, citationDocuments, generateId3) {
|
|
1940
2086
|
var _a;
|
|
@@ -1971,7 +2117,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1971
2117
|
var _a;
|
|
1972
2118
|
this.modelId = modelId;
|
|
1973
2119
|
this.config = config;
|
|
1974
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
2120
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
|
|
1975
2121
|
}
|
|
1976
2122
|
supportsUrl(url) {
|
|
1977
2123
|
return url.protocol === "https:";
|
|
@@ -2049,7 +2195,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2049
2195
|
});
|
|
2050
2196
|
}
|
|
2051
2197
|
}
|
|
2052
|
-
const anthropicOptions = await (0,
|
|
2198
|
+
const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
|
|
2053
2199
|
provider: "anthropic",
|
|
2054
2200
|
providerOptions,
|
|
2055
2201
|
schema: anthropicProviderOptions
|
|
@@ -2141,7 +2287,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2141
2287
|
...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
2142
2288
|
format: {
|
|
2143
2289
|
type: "json_schema",
|
|
2144
|
-
schema: responseFormat.schema
|
|
2290
|
+
schema: sanitizeJsonSchema(responseFormat.schema)
|
|
2145
2291
|
}
|
|
2146
2292
|
}
|
|
2147
2293
|
}
|
|
@@ -2158,13 +2304,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2158
2304
|
...((_f = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _f.userId) != null && {
|
|
2159
2305
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
2160
2306
|
},
|
|
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
2307
|
// container with agent skills:
|
|
2169
2308
|
...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
|
|
2170
2309
|
container: {
|
|
@@ -2350,15 +2489,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2350
2489
|
betas,
|
|
2351
2490
|
headers
|
|
2352
2491
|
}) {
|
|
2353
|
-
return (0,
|
|
2354
|
-
await (0,
|
|
2492
|
+
return (0, import_provider_utils10.combineHeaders)(
|
|
2493
|
+
await (0, import_provider_utils10.resolve)(this.config.headers),
|
|
2355
2494
|
headers,
|
|
2356
2495
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
|
|
2357
2496
|
);
|
|
2358
2497
|
}
|
|
2359
2498
|
async getBetasFromHeaders(requestHeaders) {
|
|
2360
2499
|
var _a, _b;
|
|
2361
|
-
const configHeaders = await (0,
|
|
2500
|
+
const configHeaders = await (0, import_provider_utils10.resolve)(this.config.headers);
|
|
2362
2501
|
const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
|
|
2363
2502
|
const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
|
|
2364
2503
|
return new Set(
|
|
@@ -2410,12 +2549,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2410
2549
|
responseHeaders,
|
|
2411
2550
|
value: response,
|
|
2412
2551
|
rawValue: rawResponse
|
|
2413
|
-
} = await (0,
|
|
2552
|
+
} = await (0, import_provider_utils10.postJsonToApi)({
|
|
2414
2553
|
url: this.buildRequestUrl(false),
|
|
2415
2554
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
2416
2555
|
body: this.transformRequestBody(args, betas),
|
|
2417
2556
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
2418
|
-
successfulResponseHandler: (0,
|
|
2557
|
+
successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
|
|
2419
2558
|
anthropicMessagesResponseSchema
|
|
2420
2559
|
),
|
|
2421
2560
|
abortSignal: options.abortSignal,
|
|
@@ -2735,12 +2874,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2735
2874
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
2736
2875
|
const body = { ...args, stream: true };
|
|
2737
2876
|
const url = this.buildRequestUrl(true);
|
|
2738
|
-
const { responseHeaders, value: response } = await (0,
|
|
2877
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
|
|
2739
2878
|
url,
|
|
2740
2879
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
2741
2880
|
body: this.transformRequestBody(body, betas),
|
|
2742
2881
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
2743
|
-
successfulResponseHandler: (0,
|
|
2882
|
+
successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
|
|
2744
2883
|
anthropicMessagesChunkSchema
|
|
2745
2884
|
),
|
|
2746
2885
|
abortSignal: options.abortSignal,
|
|
@@ -3305,7 +3444,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3305
3444
|
}
|
|
3306
3445
|
};
|
|
3307
3446
|
function getModelCapabilities(modelId) {
|
|
3308
|
-
if (modelId.includes("claude-opus-4-7")) {
|
|
3447
|
+
if (modelId.includes("claude-opus-4-8") || modelId.includes("claude-opus-4-7")) {
|
|
3309
3448
|
return {
|
|
3310
3449
|
maxOutputTokens: 128e3,
|
|
3311
3450
|
supportsStructuredOutput: true,
|
|
@@ -3372,44 +3511,44 @@ function getModelCapabilities(modelId) {
|
|
|
3372
3511
|
}
|
|
3373
3512
|
|
|
3374
3513
|
// src/tool/bash_20241022.ts
|
|
3375
|
-
var
|
|
3514
|
+
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
3376
3515
|
var import_v49 = require("zod/v4");
|
|
3377
|
-
var bash_20241022InputSchema = (0,
|
|
3378
|
-
() => (0,
|
|
3516
|
+
var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
|
|
3517
|
+
() => (0, import_provider_utils11.zodSchema)(
|
|
3379
3518
|
import_v49.z.object({
|
|
3380
3519
|
command: import_v49.z.string(),
|
|
3381
3520
|
restart: import_v49.z.boolean().optional()
|
|
3382
3521
|
})
|
|
3383
3522
|
)
|
|
3384
3523
|
);
|
|
3385
|
-
var bash_20241022 = (0,
|
|
3524
|
+
var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
3386
3525
|
id: "anthropic.bash_20241022",
|
|
3387
3526
|
name: "bash",
|
|
3388
3527
|
inputSchema: bash_20241022InputSchema
|
|
3389
3528
|
});
|
|
3390
3529
|
|
|
3391
3530
|
// src/tool/bash_20250124.ts
|
|
3392
|
-
var
|
|
3531
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
3393
3532
|
var import_v410 = require("zod/v4");
|
|
3394
|
-
var bash_20250124InputSchema = (0,
|
|
3395
|
-
() => (0,
|
|
3533
|
+
var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
|
|
3534
|
+
() => (0, import_provider_utils12.zodSchema)(
|
|
3396
3535
|
import_v410.z.object({
|
|
3397
3536
|
command: import_v410.z.string(),
|
|
3398
3537
|
restart: import_v410.z.boolean().optional()
|
|
3399
3538
|
})
|
|
3400
3539
|
)
|
|
3401
3540
|
);
|
|
3402
|
-
var bash_20250124 = (0,
|
|
3541
|
+
var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
3403
3542
|
id: "anthropic.bash_20250124",
|
|
3404
3543
|
name: "bash",
|
|
3405
3544
|
inputSchema: bash_20250124InputSchema
|
|
3406
3545
|
});
|
|
3407
3546
|
|
|
3408
3547
|
// src/tool/code-execution_20260120.ts
|
|
3409
|
-
var
|
|
3548
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
3410
3549
|
var import_v411 = require("zod/v4");
|
|
3411
|
-
var codeExecution_20260120OutputSchema = (0,
|
|
3412
|
-
() => (0,
|
|
3550
|
+
var codeExecution_20260120OutputSchema = (0, import_provider_utils13.lazySchema)(
|
|
3551
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
3413
3552
|
import_v411.z.discriminatedUnion("type", [
|
|
3414
3553
|
import_v411.z.object({
|
|
3415
3554
|
type: import_v411.z.literal("code_execution_result"),
|
|
@@ -3466,8 +3605,8 @@ var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)
|
|
|
3466
3605
|
])
|
|
3467
3606
|
)
|
|
3468
3607
|
);
|
|
3469
|
-
var codeExecution_20260120InputSchema = (0,
|
|
3470
|
-
() => (0,
|
|
3608
|
+
var codeExecution_20260120InputSchema = (0, import_provider_utils13.lazySchema)(
|
|
3609
|
+
() => (0, import_provider_utils13.zodSchema)(
|
|
3471
3610
|
import_v411.z.discriminatedUnion("type", [
|
|
3472
3611
|
import_v411.z.object({
|
|
3473
3612
|
type: import_v411.z.literal("programmatic-tool-call"),
|
|
@@ -3500,7 +3639,7 @@ var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
|
3500
3639
|
])
|
|
3501
3640
|
)
|
|
3502
3641
|
);
|
|
3503
|
-
var factory6 = (0,
|
|
3642
|
+
var factory6 = (0, import_provider_utils13.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
3504
3643
|
id: "anthropic.code_execution_20260120",
|
|
3505
3644
|
name: "code_execution",
|
|
3506
3645
|
inputSchema: codeExecution_20260120InputSchema,
|
|
@@ -3511,10 +3650,10 @@ var codeExecution_20260120 = (args = {}) => {
|
|
|
3511
3650
|
};
|
|
3512
3651
|
|
|
3513
3652
|
// src/tool/computer_20241022.ts
|
|
3514
|
-
var
|
|
3653
|
+
var import_provider_utils14 = require("@ai-sdk/provider-utils");
|
|
3515
3654
|
var import_v412 = require("zod/v4");
|
|
3516
|
-
var computer_20241022InputSchema = (0,
|
|
3517
|
-
() => (0,
|
|
3655
|
+
var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
|
|
3656
|
+
() => (0, import_provider_utils14.zodSchema)(
|
|
3518
3657
|
import_v412.z.object({
|
|
3519
3658
|
action: import_v412.z.enum([
|
|
3520
3659
|
"key",
|
|
@@ -3533,17 +3672,17 @@ var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
|
3533
3672
|
})
|
|
3534
3673
|
)
|
|
3535
3674
|
);
|
|
3536
|
-
var computer_20241022 = (0,
|
|
3675
|
+
var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
|
|
3537
3676
|
id: "anthropic.computer_20241022",
|
|
3538
3677
|
name: "computer",
|
|
3539
3678
|
inputSchema: computer_20241022InputSchema
|
|
3540
3679
|
});
|
|
3541
3680
|
|
|
3542
3681
|
// src/tool/computer_20250124.ts
|
|
3543
|
-
var
|
|
3682
|
+
var import_provider_utils15 = require("@ai-sdk/provider-utils");
|
|
3544
3683
|
var import_v413 = require("zod/v4");
|
|
3545
|
-
var computer_20250124InputSchema = (0,
|
|
3546
|
-
() => (0,
|
|
3684
|
+
var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
|
|
3685
|
+
() => (0, import_provider_utils15.zodSchema)(
|
|
3547
3686
|
import_v413.z.object({
|
|
3548
3687
|
action: import_v413.z.enum([
|
|
3549
3688
|
"key",
|
|
@@ -3572,17 +3711,17 @@ var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
|
3572
3711
|
})
|
|
3573
3712
|
)
|
|
3574
3713
|
);
|
|
3575
|
-
var computer_20250124 = (0,
|
|
3714
|
+
var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
|
|
3576
3715
|
id: "anthropic.computer_20250124",
|
|
3577
3716
|
name: "computer",
|
|
3578
3717
|
inputSchema: computer_20250124InputSchema
|
|
3579
3718
|
});
|
|
3580
3719
|
|
|
3581
3720
|
// src/tool/memory_20250818.ts
|
|
3582
|
-
var
|
|
3721
|
+
var import_provider_utils16 = require("@ai-sdk/provider-utils");
|
|
3583
3722
|
var import_v414 = require("zod/v4");
|
|
3584
|
-
var memory_20250818InputSchema = (0,
|
|
3585
|
-
() => (0,
|
|
3723
|
+
var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
|
|
3724
|
+
() => (0, import_provider_utils16.zodSchema)(
|
|
3586
3725
|
import_v414.z.discriminatedUnion("command", [
|
|
3587
3726
|
import_v414.z.object({
|
|
3588
3727
|
command: import_v414.z.literal("view"),
|
|
@@ -3618,17 +3757,17 @@ var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
|
3618
3757
|
])
|
|
3619
3758
|
)
|
|
3620
3759
|
);
|
|
3621
|
-
var memory_20250818 = (0,
|
|
3760
|
+
var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
|
|
3622
3761
|
id: "anthropic.memory_20250818",
|
|
3623
3762
|
name: "memory",
|
|
3624
3763
|
inputSchema: memory_20250818InputSchema
|
|
3625
3764
|
});
|
|
3626
3765
|
|
|
3627
3766
|
// src/tool/text-editor_20241022.ts
|
|
3628
|
-
var
|
|
3767
|
+
var import_provider_utils17 = require("@ai-sdk/provider-utils");
|
|
3629
3768
|
var import_v415 = require("zod/v4");
|
|
3630
|
-
var textEditor_20241022InputSchema = (0,
|
|
3631
|
-
() => (0,
|
|
3769
|
+
var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
|
|
3770
|
+
() => (0, import_provider_utils17.zodSchema)(
|
|
3632
3771
|
import_v415.z.object({
|
|
3633
3772
|
command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
3634
3773
|
path: import_v415.z.string(),
|
|
@@ -3640,17 +3779,17 @@ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
|
3640
3779
|
})
|
|
3641
3780
|
)
|
|
3642
3781
|
);
|
|
3643
|
-
var textEditor_20241022 = (0,
|
|
3782
|
+
var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
|
|
3644
3783
|
id: "anthropic.text_editor_20241022",
|
|
3645
3784
|
name: "str_replace_editor",
|
|
3646
3785
|
inputSchema: textEditor_20241022InputSchema
|
|
3647
3786
|
});
|
|
3648
3787
|
|
|
3649
3788
|
// src/tool/text-editor_20250124.ts
|
|
3650
|
-
var
|
|
3789
|
+
var import_provider_utils18 = require("@ai-sdk/provider-utils");
|
|
3651
3790
|
var import_v416 = require("zod/v4");
|
|
3652
|
-
var textEditor_20250124InputSchema = (0,
|
|
3653
|
-
() => (0,
|
|
3791
|
+
var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
|
|
3792
|
+
() => (0, import_provider_utils18.zodSchema)(
|
|
3654
3793
|
import_v416.z.object({
|
|
3655
3794
|
command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
3656
3795
|
path: import_v416.z.string(),
|
|
@@ -3662,17 +3801,17 @@ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
3662
3801
|
})
|
|
3663
3802
|
)
|
|
3664
3803
|
);
|
|
3665
|
-
var textEditor_20250124 = (0,
|
|
3804
|
+
var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
|
|
3666
3805
|
id: "anthropic.text_editor_20250124",
|
|
3667
3806
|
name: "str_replace_editor",
|
|
3668
3807
|
inputSchema: textEditor_20250124InputSchema
|
|
3669
3808
|
});
|
|
3670
3809
|
|
|
3671
3810
|
// src/tool/text-editor_20250429.ts
|
|
3672
|
-
var
|
|
3811
|
+
var import_provider_utils19 = require("@ai-sdk/provider-utils");
|
|
3673
3812
|
var import_v417 = require("zod/v4");
|
|
3674
|
-
var textEditor_20250429InputSchema = (0,
|
|
3675
|
-
() => (0,
|
|
3813
|
+
var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
|
|
3814
|
+
() => (0, import_provider_utils19.zodSchema)(
|
|
3676
3815
|
import_v417.z.object({
|
|
3677
3816
|
command: import_v417.z.enum(["view", "create", "str_replace", "insert"]),
|
|
3678
3817
|
path: import_v417.z.string(),
|
|
@@ -3684,7 +3823,7 @@ var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
|
|
|
3684
3823
|
})
|
|
3685
3824
|
)
|
|
3686
3825
|
);
|
|
3687
|
-
var textEditor_20250429 = (0,
|
|
3826
|
+
var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
|
|
3688
3827
|
id: "anthropic.text_editor_20250429",
|
|
3689
3828
|
name: "str_replace_based_edit_tool",
|
|
3690
3829
|
inputSchema: textEditor_20250429InputSchema
|
|
@@ -3858,17 +3997,17 @@ var anthropicTools = {
|
|
|
3858
3997
|
// src/anthropic-provider.ts
|
|
3859
3998
|
function createAnthropic(options = {}) {
|
|
3860
3999
|
var _a, _b;
|
|
3861
|
-
const baseURL = (_a = (0,
|
|
3862
|
-
(0,
|
|
4000
|
+
const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(
|
|
4001
|
+
(0, import_provider_utils20.loadOptionalSetting)({
|
|
3863
4002
|
settingValue: options.baseURL,
|
|
3864
4003
|
environmentVariableName: "ANTHROPIC_BASE_URL"
|
|
3865
4004
|
})
|
|
3866
4005
|
)) != null ? _a : "https://api.anthropic.com/v1";
|
|
3867
4006
|
const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
|
|
3868
|
-
const getHeaders = () => (0,
|
|
4007
|
+
const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
|
|
3869
4008
|
{
|
|
3870
4009
|
"anthropic-version": "2023-06-01",
|
|
3871
|
-
"x-api-key": (0,
|
|
4010
|
+
"x-api-key": (0, import_provider_utils20.loadApiKey)({
|
|
3872
4011
|
apiKey: options.apiKey,
|
|
3873
4012
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
3874
4013
|
description: "Anthropic"
|
|
@@ -3884,7 +4023,7 @@ function createAnthropic(options = {}) {
|
|
|
3884
4023
|
baseURL,
|
|
3885
4024
|
headers: getHeaders,
|
|
3886
4025
|
fetch: options.fetch,
|
|
3887
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
4026
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils20.generateId,
|
|
3888
4027
|
supportedUrls: () => ({
|
|
3889
4028
|
"image/*": [/^https?:\/\/.*$/]
|
|
3890
4029
|
})
|