@ai-sdk/anthropic 2.0.3 → 2.0.5
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 +13 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +388 -229
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +362 -203
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +21 -0
- package/dist/internal/index.d.ts +21 -0
- package/dist/internal/index.js +384 -225
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +362 -203
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -37,12 +37,12 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
37
|
|
|
38
38
|
// src/anthropic-provider.ts
|
|
39
39
|
var import_provider4 = require("@ai-sdk/provider");
|
|
40
|
-
var
|
|
40
|
+
var import_provider_utils13 = require("@ai-sdk/provider-utils");
|
|
41
41
|
|
|
42
42
|
// src/anthropic-messages-language-model.ts
|
|
43
43
|
var import_provider3 = require("@ai-sdk/provider");
|
|
44
|
-
var
|
|
45
|
-
var
|
|
44
|
+
var import_provider_utils5 = require("@ai-sdk/provider-utils");
|
|
45
|
+
var import_v45 = require("zod/v4");
|
|
46
46
|
|
|
47
47
|
// src/anthropic-error.ts
|
|
48
48
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
@@ -256,6 +256,14 @@ function prepareTools({
|
|
|
256
256
|
});
|
|
257
257
|
break;
|
|
258
258
|
}
|
|
259
|
+
case "anthropic.code_execution_20250522": {
|
|
260
|
+
betas.add("code-execution-2025-05-22");
|
|
261
|
+
anthropicTools2.push({
|
|
262
|
+
type: "code_execution_20250522",
|
|
263
|
+
name: "code_execution"
|
|
264
|
+
});
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
259
267
|
default:
|
|
260
268
|
toolWarnings.push({ type: "unsupported-tool", tool });
|
|
261
269
|
break;
|
|
@@ -320,7 +328,30 @@ function prepareTools({
|
|
|
320
328
|
|
|
321
329
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
322
330
|
var import_provider2 = require("@ai-sdk/provider");
|
|
331
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
332
|
+
|
|
333
|
+
// src/tool/code-execution_20250522.ts
|
|
323
334
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
335
|
+
var import_v44 = require("zod/v4");
|
|
336
|
+
var codeExecution_20250522OutputSchema = import_v44.z.object({
|
|
337
|
+
type: import_v44.z.literal("code_execution_result"),
|
|
338
|
+
stdout: import_v44.z.string(),
|
|
339
|
+
stderr: import_v44.z.string(),
|
|
340
|
+
return_code: import_v44.z.number()
|
|
341
|
+
});
|
|
342
|
+
var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
|
|
343
|
+
id: "anthropic.code_execution_20250522",
|
|
344
|
+
name: "code_execution",
|
|
345
|
+
inputSchema: import_v44.z.object({
|
|
346
|
+
code: import_v44.z.string()
|
|
347
|
+
}),
|
|
348
|
+
outputSchema: codeExecution_20250522OutputSchema
|
|
349
|
+
});
|
|
350
|
+
var codeExecution_20250522 = (args = {}) => {
|
|
351
|
+
return factory2(args);
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
// src/convert-to-anthropic-messages-prompt.ts
|
|
324
355
|
function convertToString(data) {
|
|
325
356
|
if (typeof data === "string") {
|
|
326
357
|
return Buffer.from(data, "base64").toString("utf-8");
|
|
@@ -349,7 +380,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
349
380
|
const messages = [];
|
|
350
381
|
async function shouldEnableCitations(providerMetadata) {
|
|
351
382
|
var _a2, _b2;
|
|
352
|
-
const anthropicOptions = await (0,
|
|
383
|
+
const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
353
384
|
provider: "anthropic",
|
|
354
385
|
providerOptions: providerMetadata,
|
|
355
386
|
schema: anthropicFilePartProviderOptions
|
|
@@ -357,7 +388,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
357
388
|
return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
|
|
358
389
|
}
|
|
359
390
|
async function getDocumentMetadata(providerMetadata) {
|
|
360
|
-
const anthropicOptions = await (0,
|
|
391
|
+
const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
|
|
361
392
|
provider: "anthropic",
|
|
362
393
|
providerOptions: providerMetadata,
|
|
363
394
|
schema: anthropicFilePartProviderOptions
|
|
@@ -414,7 +445,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
414
445
|
} : {
|
|
415
446
|
type: "base64",
|
|
416
447
|
media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
|
|
417
|
-
data: (0,
|
|
448
|
+
data: (0, import_provider_utils4.convertToBase64)(part.data)
|
|
418
449
|
},
|
|
419
450
|
cache_control: cacheControl
|
|
420
451
|
});
|
|
@@ -434,7 +465,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
434
465
|
} : {
|
|
435
466
|
type: "base64",
|
|
436
467
|
media_type: "application/pdf",
|
|
437
|
-
data: (0,
|
|
468
|
+
data: (0, import_provider_utils4.convertToBase64)(part.data)
|
|
438
469
|
},
|
|
439
470
|
title: (_b = metadata.title) != null ? _b : part.filename,
|
|
440
471
|
...metadata.context && { context: metadata.context },
|
|
@@ -569,7 +600,7 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
569
600
|
}
|
|
570
601
|
case "reasoning": {
|
|
571
602
|
if (sendReasoning) {
|
|
572
|
-
const reasoningMetadata = await (0,
|
|
603
|
+
const reasoningMetadata = await (0, import_provider_utils4.parseProviderOptions)({
|
|
573
604
|
provider: "anthropic",
|
|
574
605
|
providerOptions: part.providerOptions,
|
|
575
606
|
schema: anthropicReasoningMetadataSchema
|
|
@@ -620,6 +651,16 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
620
651
|
});
|
|
621
652
|
break;
|
|
622
653
|
}
|
|
654
|
+
if (part.toolName === "code_execution") {
|
|
655
|
+
anthropicContent.push({
|
|
656
|
+
type: "server_tool_use",
|
|
657
|
+
id: part.toolCallId,
|
|
658
|
+
name: "code_execution",
|
|
659
|
+
input: part.input,
|
|
660
|
+
cache_control: cacheControl
|
|
661
|
+
});
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
623
664
|
warnings.push({
|
|
624
665
|
type: "other",
|
|
625
666
|
message: `provider executed tool call for tool ${part.toolName} is not supported`
|
|
@@ -662,6 +703,29 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
662
703
|
});
|
|
663
704
|
break;
|
|
664
705
|
}
|
|
706
|
+
if (part.toolName === "code_execution") {
|
|
707
|
+
const output = part.output;
|
|
708
|
+
if (output.type !== "json") {
|
|
709
|
+
warnings.push({
|
|
710
|
+
type: "other",
|
|
711
|
+
message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
|
|
712
|
+
});
|
|
713
|
+
break;
|
|
714
|
+
}
|
|
715
|
+
const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
|
|
716
|
+
anthropicContent.push({
|
|
717
|
+
type: "code_execution_tool_result",
|
|
718
|
+
tool_use_id: part.toolCallId,
|
|
719
|
+
content: {
|
|
720
|
+
type: codeExecutionOutput.type,
|
|
721
|
+
stdout: codeExecutionOutput.stdout,
|
|
722
|
+
stderr: codeExecutionOutput.stderr,
|
|
723
|
+
return_code: codeExecutionOutput.return_code
|
|
724
|
+
},
|
|
725
|
+
cache_control: cacheControl
|
|
726
|
+
});
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
665
729
|
warnings.push({
|
|
666
730
|
type: "other",
|
|
667
731
|
message: `provider executed tool result for tool ${part.toolName} is not supported`
|
|
@@ -752,36 +816,36 @@ function mapAnthropicStopReason({
|
|
|
752
816
|
|
|
753
817
|
// src/anthropic-messages-language-model.ts
|
|
754
818
|
var citationSchemas = {
|
|
755
|
-
webSearchResult:
|
|
756
|
-
type:
|
|
757
|
-
cited_text:
|
|
758
|
-
url:
|
|
759
|
-
title:
|
|
760
|
-
encrypted_index:
|
|
819
|
+
webSearchResult: import_v45.z.object({
|
|
820
|
+
type: import_v45.z.literal("web_search_result_location"),
|
|
821
|
+
cited_text: import_v45.z.string(),
|
|
822
|
+
url: import_v45.z.string(),
|
|
823
|
+
title: import_v45.z.string(),
|
|
824
|
+
encrypted_index: import_v45.z.string()
|
|
761
825
|
}),
|
|
762
|
-
pageLocation:
|
|
763
|
-
type:
|
|
764
|
-
cited_text:
|
|
765
|
-
document_index:
|
|
766
|
-
document_title:
|
|
767
|
-
start_page_number:
|
|
768
|
-
end_page_number:
|
|
826
|
+
pageLocation: import_v45.z.object({
|
|
827
|
+
type: import_v45.z.literal("page_location"),
|
|
828
|
+
cited_text: import_v45.z.string(),
|
|
829
|
+
document_index: import_v45.z.number(),
|
|
830
|
+
document_title: import_v45.z.string().nullable(),
|
|
831
|
+
start_page_number: import_v45.z.number(),
|
|
832
|
+
end_page_number: import_v45.z.number()
|
|
769
833
|
}),
|
|
770
|
-
charLocation:
|
|
771
|
-
type:
|
|
772
|
-
cited_text:
|
|
773
|
-
document_index:
|
|
774
|
-
document_title:
|
|
775
|
-
start_char_index:
|
|
776
|
-
end_char_index:
|
|
834
|
+
charLocation: import_v45.z.object({
|
|
835
|
+
type: import_v45.z.literal("char_location"),
|
|
836
|
+
cited_text: import_v45.z.string(),
|
|
837
|
+
document_index: import_v45.z.number(),
|
|
838
|
+
document_title: import_v45.z.string().nullable(),
|
|
839
|
+
start_char_index: import_v45.z.number(),
|
|
840
|
+
end_char_index: import_v45.z.number()
|
|
777
841
|
})
|
|
778
842
|
};
|
|
779
|
-
var citationSchema =
|
|
843
|
+
var citationSchema = import_v45.z.discriminatedUnion("type", [
|
|
780
844
|
citationSchemas.webSearchResult,
|
|
781
845
|
citationSchemas.pageLocation,
|
|
782
846
|
citationSchemas.charLocation
|
|
783
847
|
]);
|
|
784
|
-
var documentCitationSchema =
|
|
848
|
+
var documentCitationSchema = import_v45.z.discriminatedUnion("type", [
|
|
785
849
|
citationSchemas.pageLocation,
|
|
786
850
|
citationSchemas.charLocation
|
|
787
851
|
]);
|
|
@@ -830,7 +894,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
830
894
|
var _a;
|
|
831
895
|
this.modelId = modelId;
|
|
832
896
|
this.config = config;
|
|
833
|
-
this.generateId = (_a = config.generateId) != null ? _a :
|
|
897
|
+
this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils5.generateId;
|
|
834
898
|
}
|
|
835
899
|
supportsUrl(url) {
|
|
836
900
|
return url.protocol === "https:";
|
|
@@ -899,7 +963,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
899
963
|
description: "Respond with a JSON object.",
|
|
900
964
|
inputSchema: responseFormat.schema
|
|
901
965
|
} : void 0;
|
|
902
|
-
const anthropicOptions = await (0,
|
|
966
|
+
const anthropicOptions = await (0, import_provider_utils5.parseProviderOptions)({
|
|
903
967
|
provider: "anthropic",
|
|
904
968
|
providerOptions,
|
|
905
969
|
schema: anthropicProviderOptions
|
|
@@ -991,8 +1055,8 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
991
1055
|
betas,
|
|
992
1056
|
headers
|
|
993
1057
|
}) {
|
|
994
|
-
return (0,
|
|
995
|
-
await (0,
|
|
1058
|
+
return (0, import_provider_utils5.combineHeaders)(
|
|
1059
|
+
await (0, import_provider_utils5.resolve)(this.config.headers),
|
|
996
1060
|
betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
|
|
997
1061
|
headers
|
|
998
1062
|
);
|
|
@@ -1036,12 +1100,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1036
1100
|
responseHeaders,
|
|
1037
1101
|
value: response,
|
|
1038
1102
|
rawValue: rawResponse
|
|
1039
|
-
} = await (0,
|
|
1103
|
+
} = await (0, import_provider_utils5.postJsonToApi)({
|
|
1040
1104
|
url: this.buildRequestUrl(false),
|
|
1041
1105
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1042
1106
|
body: this.transformRequestBody(args),
|
|
1043
1107
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1044
|
-
successfulResponseHandler: (0,
|
|
1108
|
+
successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
|
|
1045
1109
|
anthropicMessagesResponseSchema
|
|
1046
1110
|
),
|
|
1047
1111
|
abortSignal: options.abortSignal,
|
|
@@ -1106,7 +1170,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1106
1170
|
break;
|
|
1107
1171
|
}
|
|
1108
1172
|
case "server_tool_use": {
|
|
1109
|
-
if (part.name === "web_search") {
|
|
1173
|
+
if (part.name === "web_search" || part.name === "code_execution") {
|
|
1110
1174
|
content.push({
|
|
1111
1175
|
type: "tool-call",
|
|
1112
1176
|
toolCallId: part.id,
|
|
@@ -1164,6 +1228,35 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1164
1228
|
}
|
|
1165
1229
|
break;
|
|
1166
1230
|
}
|
|
1231
|
+
case "code_execution_tool_result": {
|
|
1232
|
+
if (part.content.type === "code_execution_result") {
|
|
1233
|
+
content.push({
|
|
1234
|
+
type: "tool-result",
|
|
1235
|
+
toolCallId: part.tool_use_id,
|
|
1236
|
+
toolName: "code_execution",
|
|
1237
|
+
result: {
|
|
1238
|
+
type: part.content.type,
|
|
1239
|
+
stdout: part.content.stdout,
|
|
1240
|
+
stderr: part.content.stderr,
|
|
1241
|
+
return_code: part.content.return_code
|
|
1242
|
+
},
|
|
1243
|
+
providerExecuted: true
|
|
1244
|
+
});
|
|
1245
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
1246
|
+
content.push({
|
|
1247
|
+
type: "tool-result",
|
|
1248
|
+
toolCallId: part.tool_use_id,
|
|
1249
|
+
toolName: "code_execution",
|
|
1250
|
+
isError: true,
|
|
1251
|
+
result: {
|
|
1252
|
+
type: "code_execution_tool_result_error",
|
|
1253
|
+
errorCode: part.content.error_code
|
|
1254
|
+
},
|
|
1255
|
+
providerExecuted: true
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
break;
|
|
1259
|
+
}
|
|
1167
1260
|
}
|
|
1168
1261
|
}
|
|
1169
1262
|
return {
|
|
@@ -1198,12 +1291,12 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1198
1291
|
const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
|
|
1199
1292
|
const citationDocuments = this.extractCitationDocuments(options.prompt);
|
|
1200
1293
|
const body = { ...args, stream: true };
|
|
1201
|
-
const { responseHeaders, value: response } = await (0,
|
|
1294
|
+
const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
|
|
1202
1295
|
url: this.buildRequestUrl(true),
|
|
1203
1296
|
headers: await this.getHeaders({ betas, headers: options.headers }),
|
|
1204
1297
|
body: this.transformRequestBody(body),
|
|
1205
1298
|
failedResponseHandler: anthropicFailedResponseHandler,
|
|
1206
|
-
successfulResponseHandler: (0,
|
|
1299
|
+
successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
|
|
1207
1300
|
anthropicMessagesChunkSchema
|
|
1208
1301
|
),
|
|
1209
1302
|
abortSignal: options.abortSignal,
|
|
@@ -1289,7 +1382,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1289
1382
|
return;
|
|
1290
1383
|
}
|
|
1291
1384
|
case "server_tool_use": {
|
|
1292
|
-
if (value.content_block.name === "web_search") {
|
|
1385
|
+
if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
|
|
1293
1386
|
contentBlocks[value.index] = {
|
|
1294
1387
|
type: "tool-call",
|
|
1295
1388
|
toolCallId: value.content_block.id,
|
|
@@ -1354,6 +1447,36 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1354
1447
|
}
|
|
1355
1448
|
return;
|
|
1356
1449
|
}
|
|
1450
|
+
case "code_execution_tool_result": {
|
|
1451
|
+
const part = value.content_block;
|
|
1452
|
+
if (part.content.type === "code_execution_result") {
|
|
1453
|
+
controller.enqueue({
|
|
1454
|
+
type: "tool-result",
|
|
1455
|
+
toolCallId: part.tool_use_id,
|
|
1456
|
+
toolName: "code_execution",
|
|
1457
|
+
result: {
|
|
1458
|
+
type: part.content.type,
|
|
1459
|
+
stdout: part.content.stdout,
|
|
1460
|
+
stderr: part.content.stderr,
|
|
1461
|
+
return_code: part.content.return_code
|
|
1462
|
+
},
|
|
1463
|
+
providerExecuted: true
|
|
1464
|
+
});
|
|
1465
|
+
} else if (part.content.type === "code_execution_tool_result_error") {
|
|
1466
|
+
controller.enqueue({
|
|
1467
|
+
type: "tool-result",
|
|
1468
|
+
toolCallId: part.tool_use_id,
|
|
1469
|
+
toolName: "code_execution",
|
|
1470
|
+
isError: true,
|
|
1471
|
+
result: {
|
|
1472
|
+
type: "code_execution_tool_result_error",
|
|
1473
|
+
errorCode: part.content.error_code
|
|
1474
|
+
},
|
|
1475
|
+
providerExecuted: true
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1357
1480
|
default: {
|
|
1358
1481
|
const _exhaustiveCheck = contentBlockType;
|
|
1359
1482
|
throw new Error(
|
|
@@ -1526,215 +1649,247 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
1526
1649
|
};
|
|
1527
1650
|
}
|
|
1528
1651
|
};
|
|
1529
|
-
var anthropicMessagesResponseSchema =
|
|
1530
|
-
type:
|
|
1531
|
-
id:
|
|
1532
|
-
model:
|
|
1533
|
-
content:
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
type:
|
|
1537
|
-
text:
|
|
1538
|
-
citations:
|
|
1652
|
+
var anthropicMessagesResponseSchema = import_v45.z.object({
|
|
1653
|
+
type: import_v45.z.literal("message"),
|
|
1654
|
+
id: import_v45.z.string().nullish(),
|
|
1655
|
+
model: import_v45.z.string().nullish(),
|
|
1656
|
+
content: import_v45.z.array(
|
|
1657
|
+
import_v45.z.discriminatedUnion("type", [
|
|
1658
|
+
import_v45.z.object({
|
|
1659
|
+
type: import_v45.z.literal("text"),
|
|
1660
|
+
text: import_v45.z.string(),
|
|
1661
|
+
citations: import_v45.z.array(citationSchema).optional()
|
|
1539
1662
|
}),
|
|
1540
|
-
|
|
1541
|
-
type:
|
|
1542
|
-
thinking:
|
|
1543
|
-
signature:
|
|
1663
|
+
import_v45.z.object({
|
|
1664
|
+
type: import_v45.z.literal("thinking"),
|
|
1665
|
+
thinking: import_v45.z.string(),
|
|
1666
|
+
signature: import_v45.z.string()
|
|
1544
1667
|
}),
|
|
1545
|
-
|
|
1546
|
-
type:
|
|
1547
|
-
data:
|
|
1668
|
+
import_v45.z.object({
|
|
1669
|
+
type: import_v45.z.literal("redacted_thinking"),
|
|
1670
|
+
data: import_v45.z.string()
|
|
1548
1671
|
}),
|
|
1549
|
-
|
|
1550
|
-
type:
|
|
1551
|
-
id:
|
|
1552
|
-
name:
|
|
1553
|
-
input:
|
|
1672
|
+
import_v45.z.object({
|
|
1673
|
+
type: import_v45.z.literal("tool_use"),
|
|
1674
|
+
id: import_v45.z.string(),
|
|
1675
|
+
name: import_v45.z.string(),
|
|
1676
|
+
input: import_v45.z.unknown()
|
|
1554
1677
|
}),
|
|
1555
|
-
|
|
1556
|
-
type:
|
|
1557
|
-
id:
|
|
1558
|
-
name:
|
|
1559
|
-
input:
|
|
1678
|
+
import_v45.z.object({
|
|
1679
|
+
type: import_v45.z.literal("server_tool_use"),
|
|
1680
|
+
id: import_v45.z.string(),
|
|
1681
|
+
name: import_v45.z.string(),
|
|
1682
|
+
input: import_v45.z.record(import_v45.z.string(), import_v45.z.unknown()).nullish()
|
|
1560
1683
|
}),
|
|
1561
|
-
|
|
1562
|
-
type:
|
|
1563
|
-
tool_use_id:
|
|
1564
|
-
content:
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
type:
|
|
1568
|
-
url:
|
|
1569
|
-
title:
|
|
1570
|
-
encrypted_content:
|
|
1571
|
-
page_age:
|
|
1684
|
+
import_v45.z.object({
|
|
1685
|
+
type: import_v45.z.literal("web_search_tool_result"),
|
|
1686
|
+
tool_use_id: import_v45.z.string(),
|
|
1687
|
+
content: import_v45.z.union([
|
|
1688
|
+
import_v45.z.array(
|
|
1689
|
+
import_v45.z.object({
|
|
1690
|
+
type: import_v45.z.literal("web_search_result"),
|
|
1691
|
+
url: import_v45.z.string(),
|
|
1692
|
+
title: import_v45.z.string(),
|
|
1693
|
+
encrypted_content: import_v45.z.string(),
|
|
1694
|
+
page_age: import_v45.z.string().nullish()
|
|
1572
1695
|
})
|
|
1573
1696
|
),
|
|
1574
|
-
|
|
1575
|
-
type:
|
|
1576
|
-
error_code:
|
|
1697
|
+
import_v45.z.object({
|
|
1698
|
+
type: import_v45.z.literal("web_search_tool_result_error"),
|
|
1699
|
+
error_code: import_v45.z.string()
|
|
1700
|
+
})
|
|
1701
|
+
])
|
|
1702
|
+
}),
|
|
1703
|
+
import_v45.z.object({
|
|
1704
|
+
type: import_v45.z.literal("code_execution_tool_result"),
|
|
1705
|
+
tool_use_id: import_v45.z.string(),
|
|
1706
|
+
content: import_v45.z.union([
|
|
1707
|
+
import_v45.z.object({
|
|
1708
|
+
type: import_v45.z.literal("code_execution_result"),
|
|
1709
|
+
stdout: import_v45.z.string(),
|
|
1710
|
+
stderr: import_v45.z.string(),
|
|
1711
|
+
return_code: import_v45.z.number()
|
|
1712
|
+
}),
|
|
1713
|
+
import_v45.z.object({
|
|
1714
|
+
type: import_v45.z.literal("code_execution_tool_result_error"),
|
|
1715
|
+
error_code: import_v45.z.string()
|
|
1577
1716
|
})
|
|
1578
1717
|
])
|
|
1579
1718
|
})
|
|
1580
1719
|
])
|
|
1581
1720
|
),
|
|
1582
|
-
stop_reason:
|
|
1583
|
-
usage:
|
|
1584
|
-
input_tokens:
|
|
1585
|
-
output_tokens:
|
|
1586
|
-
cache_creation_input_tokens:
|
|
1587
|
-
cache_read_input_tokens:
|
|
1721
|
+
stop_reason: import_v45.z.string().nullish(),
|
|
1722
|
+
usage: import_v45.z.looseObject({
|
|
1723
|
+
input_tokens: import_v45.z.number(),
|
|
1724
|
+
output_tokens: import_v45.z.number(),
|
|
1725
|
+
cache_creation_input_tokens: import_v45.z.number().nullish(),
|
|
1726
|
+
cache_read_input_tokens: import_v45.z.number().nullish()
|
|
1588
1727
|
})
|
|
1589
1728
|
});
|
|
1590
|
-
var anthropicMessagesChunkSchema =
|
|
1591
|
-
|
|
1592
|
-
type:
|
|
1593
|
-
message:
|
|
1594
|
-
id:
|
|
1595
|
-
model:
|
|
1596
|
-
usage:
|
|
1597
|
-
input_tokens:
|
|
1598
|
-
output_tokens:
|
|
1599
|
-
cache_creation_input_tokens:
|
|
1600
|
-
cache_read_input_tokens:
|
|
1729
|
+
var anthropicMessagesChunkSchema = import_v45.z.discriminatedUnion("type", [
|
|
1730
|
+
import_v45.z.object({
|
|
1731
|
+
type: import_v45.z.literal("message_start"),
|
|
1732
|
+
message: import_v45.z.object({
|
|
1733
|
+
id: import_v45.z.string().nullish(),
|
|
1734
|
+
model: import_v45.z.string().nullish(),
|
|
1735
|
+
usage: import_v45.z.looseObject({
|
|
1736
|
+
input_tokens: import_v45.z.number(),
|
|
1737
|
+
output_tokens: import_v45.z.number(),
|
|
1738
|
+
cache_creation_input_tokens: import_v45.z.number().nullish(),
|
|
1739
|
+
cache_read_input_tokens: import_v45.z.number().nullish()
|
|
1601
1740
|
})
|
|
1602
1741
|
})
|
|
1603
1742
|
}),
|
|
1604
|
-
|
|
1605
|
-
type:
|
|
1606
|
-
index:
|
|
1607
|
-
content_block:
|
|
1608
|
-
|
|
1609
|
-
type:
|
|
1610
|
-
text:
|
|
1743
|
+
import_v45.z.object({
|
|
1744
|
+
type: import_v45.z.literal("content_block_start"),
|
|
1745
|
+
index: import_v45.z.number(),
|
|
1746
|
+
content_block: import_v45.z.discriminatedUnion("type", [
|
|
1747
|
+
import_v45.z.object({
|
|
1748
|
+
type: import_v45.z.literal("text"),
|
|
1749
|
+
text: import_v45.z.string()
|
|
1611
1750
|
}),
|
|
1612
|
-
|
|
1613
|
-
type:
|
|
1614
|
-
thinking:
|
|
1751
|
+
import_v45.z.object({
|
|
1752
|
+
type: import_v45.z.literal("thinking"),
|
|
1753
|
+
thinking: import_v45.z.string()
|
|
1615
1754
|
}),
|
|
1616
|
-
|
|
1617
|
-
type:
|
|
1618
|
-
id:
|
|
1619
|
-
name:
|
|
1755
|
+
import_v45.z.object({
|
|
1756
|
+
type: import_v45.z.literal("tool_use"),
|
|
1757
|
+
id: import_v45.z.string(),
|
|
1758
|
+
name: import_v45.z.string()
|
|
1620
1759
|
}),
|
|
1621
|
-
|
|
1622
|
-
type:
|
|
1623
|
-
data:
|
|
1760
|
+
import_v45.z.object({
|
|
1761
|
+
type: import_v45.z.literal("redacted_thinking"),
|
|
1762
|
+
data: import_v45.z.string()
|
|
1624
1763
|
}),
|
|
1625
|
-
|
|
1626
|
-
type:
|
|
1627
|
-
id:
|
|
1628
|
-
name:
|
|
1629
|
-
input:
|
|
1764
|
+
import_v45.z.object({
|
|
1765
|
+
type: import_v45.z.literal("server_tool_use"),
|
|
1766
|
+
id: import_v45.z.string(),
|
|
1767
|
+
name: import_v45.z.string(),
|
|
1768
|
+
input: import_v45.z.record(import_v45.z.string(), import_v45.z.unknown()).nullish()
|
|
1630
1769
|
}),
|
|
1631
|
-
|
|
1632
|
-
type:
|
|
1633
|
-
tool_use_id:
|
|
1634
|
-
content:
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
type:
|
|
1638
|
-
url:
|
|
1639
|
-
title:
|
|
1640
|
-
encrypted_content:
|
|
1641
|
-
page_age:
|
|
1770
|
+
import_v45.z.object({
|
|
1771
|
+
type: import_v45.z.literal("web_search_tool_result"),
|
|
1772
|
+
tool_use_id: import_v45.z.string(),
|
|
1773
|
+
content: import_v45.z.union([
|
|
1774
|
+
import_v45.z.array(
|
|
1775
|
+
import_v45.z.object({
|
|
1776
|
+
type: import_v45.z.literal("web_search_result"),
|
|
1777
|
+
url: import_v45.z.string(),
|
|
1778
|
+
title: import_v45.z.string(),
|
|
1779
|
+
encrypted_content: import_v45.z.string(),
|
|
1780
|
+
page_age: import_v45.z.string().nullish()
|
|
1642
1781
|
})
|
|
1643
1782
|
),
|
|
1644
|
-
|
|
1645
|
-
type:
|
|
1646
|
-
error_code:
|
|
1783
|
+
import_v45.z.object({
|
|
1784
|
+
type: import_v45.z.literal("web_search_tool_result_error"),
|
|
1785
|
+
error_code: import_v45.z.string()
|
|
1786
|
+
})
|
|
1787
|
+
])
|
|
1788
|
+
}),
|
|
1789
|
+
import_v45.z.object({
|
|
1790
|
+
type: import_v45.z.literal("code_execution_tool_result"),
|
|
1791
|
+
tool_use_id: import_v45.z.string(),
|
|
1792
|
+
content: import_v45.z.union([
|
|
1793
|
+
import_v45.z.object({
|
|
1794
|
+
type: import_v45.z.literal("code_execution_result"),
|
|
1795
|
+
stdout: import_v45.z.string(),
|
|
1796
|
+
stderr: import_v45.z.string(),
|
|
1797
|
+
return_code: import_v45.z.number()
|
|
1798
|
+
}),
|
|
1799
|
+
import_v45.z.object({
|
|
1800
|
+
type: import_v45.z.literal("code_execution_tool_result_error"),
|
|
1801
|
+
error_code: import_v45.z.string()
|
|
1647
1802
|
})
|
|
1648
1803
|
])
|
|
1649
1804
|
})
|
|
1650
1805
|
])
|
|
1651
1806
|
}),
|
|
1652
|
-
|
|
1653
|
-
type:
|
|
1654
|
-
index:
|
|
1655
|
-
delta:
|
|
1656
|
-
|
|
1657
|
-
type:
|
|
1658
|
-
partial_json:
|
|
1807
|
+
import_v45.z.object({
|
|
1808
|
+
type: import_v45.z.literal("content_block_delta"),
|
|
1809
|
+
index: import_v45.z.number(),
|
|
1810
|
+
delta: import_v45.z.discriminatedUnion("type", [
|
|
1811
|
+
import_v45.z.object({
|
|
1812
|
+
type: import_v45.z.literal("input_json_delta"),
|
|
1813
|
+
partial_json: import_v45.z.string()
|
|
1659
1814
|
}),
|
|
1660
|
-
|
|
1661
|
-
type:
|
|
1662
|
-
text:
|
|
1815
|
+
import_v45.z.object({
|
|
1816
|
+
type: import_v45.z.literal("text_delta"),
|
|
1817
|
+
text: import_v45.z.string()
|
|
1663
1818
|
}),
|
|
1664
|
-
|
|
1665
|
-
type:
|
|
1666
|
-
thinking:
|
|
1819
|
+
import_v45.z.object({
|
|
1820
|
+
type: import_v45.z.literal("thinking_delta"),
|
|
1821
|
+
thinking: import_v45.z.string()
|
|
1667
1822
|
}),
|
|
1668
|
-
|
|
1669
|
-
type:
|
|
1670
|
-
signature:
|
|
1823
|
+
import_v45.z.object({
|
|
1824
|
+
type: import_v45.z.literal("signature_delta"),
|
|
1825
|
+
signature: import_v45.z.string()
|
|
1671
1826
|
}),
|
|
1672
|
-
|
|
1673
|
-
type:
|
|
1827
|
+
import_v45.z.object({
|
|
1828
|
+
type: import_v45.z.literal("citations_delta"),
|
|
1674
1829
|
citation: citationSchema
|
|
1675
1830
|
})
|
|
1676
1831
|
])
|
|
1677
1832
|
}),
|
|
1678
|
-
|
|
1679
|
-
type:
|
|
1680
|
-
index:
|
|
1833
|
+
import_v45.z.object({
|
|
1834
|
+
type: import_v45.z.literal("content_block_stop"),
|
|
1835
|
+
index: import_v45.z.number()
|
|
1681
1836
|
}),
|
|
1682
|
-
|
|
1683
|
-
type:
|
|
1684
|
-
error:
|
|
1685
|
-
type:
|
|
1686
|
-
message:
|
|
1837
|
+
import_v45.z.object({
|
|
1838
|
+
type: import_v45.z.literal("error"),
|
|
1839
|
+
error: import_v45.z.object({
|
|
1840
|
+
type: import_v45.z.string(),
|
|
1841
|
+
message: import_v45.z.string()
|
|
1687
1842
|
})
|
|
1688
1843
|
}),
|
|
1689
|
-
|
|
1690
|
-
type:
|
|
1691
|
-
delta:
|
|
1692
|
-
usage:
|
|
1844
|
+
import_v45.z.object({
|
|
1845
|
+
type: import_v45.z.literal("message_delta"),
|
|
1846
|
+
delta: import_v45.z.object({ stop_reason: import_v45.z.string().nullish() }),
|
|
1847
|
+
usage: import_v45.z.object({ output_tokens: import_v45.z.number() })
|
|
1693
1848
|
}),
|
|
1694
|
-
|
|
1695
|
-
type:
|
|
1849
|
+
import_v45.z.object({
|
|
1850
|
+
type: import_v45.z.literal("message_stop")
|
|
1696
1851
|
}),
|
|
1697
|
-
|
|
1698
|
-
type:
|
|
1852
|
+
import_v45.z.object({
|
|
1853
|
+
type: import_v45.z.literal("ping")
|
|
1699
1854
|
})
|
|
1700
1855
|
]);
|
|
1701
|
-
var anthropicReasoningMetadataSchema =
|
|
1702
|
-
signature:
|
|
1703
|
-
redactedData:
|
|
1856
|
+
var anthropicReasoningMetadataSchema = import_v45.z.object({
|
|
1857
|
+
signature: import_v45.z.string().optional(),
|
|
1858
|
+
redactedData: import_v45.z.string().optional()
|
|
1704
1859
|
});
|
|
1705
1860
|
|
|
1706
1861
|
// src/tool/bash_20241022.ts
|
|
1707
|
-
var
|
|
1708
|
-
var
|
|
1709
|
-
var bash_20241022 = (0,
|
|
1862
|
+
var import_provider_utils6 = require("@ai-sdk/provider-utils");
|
|
1863
|
+
var import_v46 = __toESM(require("zod/v4"));
|
|
1864
|
+
var bash_20241022 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
|
|
1710
1865
|
id: "anthropic.bash_20241022",
|
|
1711
1866
|
name: "bash",
|
|
1712
|
-
inputSchema:
|
|
1713
|
-
command:
|
|
1714
|
-
restart:
|
|
1867
|
+
inputSchema: import_v46.default.object({
|
|
1868
|
+
command: import_v46.default.string(),
|
|
1869
|
+
restart: import_v46.default.boolean().optional()
|
|
1715
1870
|
})
|
|
1716
1871
|
});
|
|
1717
1872
|
|
|
1718
1873
|
// src/tool/bash_20250124.ts
|
|
1719
|
-
var
|
|
1720
|
-
var
|
|
1721
|
-
var bash_20250124 = (0,
|
|
1874
|
+
var import_provider_utils7 = require("@ai-sdk/provider-utils");
|
|
1875
|
+
var import_v47 = __toESM(require("zod/v4"));
|
|
1876
|
+
var bash_20250124 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
|
|
1722
1877
|
id: "anthropic.bash_20250124",
|
|
1723
1878
|
name: "bash",
|
|
1724
|
-
inputSchema:
|
|
1725
|
-
command:
|
|
1726
|
-
restart:
|
|
1879
|
+
inputSchema: import_v47.default.object({
|
|
1880
|
+
command: import_v47.default.string(),
|
|
1881
|
+
restart: import_v47.default.boolean().optional()
|
|
1727
1882
|
})
|
|
1728
1883
|
});
|
|
1729
1884
|
|
|
1730
1885
|
// src/tool/computer_20241022.ts
|
|
1731
|
-
var
|
|
1732
|
-
var
|
|
1733
|
-
var computer_20241022 = (0,
|
|
1886
|
+
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
|
1887
|
+
var import_v48 = require("zod/v4");
|
|
1888
|
+
var computer_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
|
|
1734
1889
|
id: "anthropic.computer_20241022",
|
|
1735
1890
|
name: "computer",
|
|
1736
|
-
inputSchema:
|
|
1737
|
-
action:
|
|
1891
|
+
inputSchema: import_v48.z.object({
|
|
1892
|
+
action: import_v48.z.enum([
|
|
1738
1893
|
"key",
|
|
1739
1894
|
"type",
|
|
1740
1895
|
"mouse_move",
|
|
@@ -1746,19 +1901,19 @@ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFact
|
|
|
1746
1901
|
"screenshot",
|
|
1747
1902
|
"cursor_position"
|
|
1748
1903
|
]),
|
|
1749
|
-
coordinate:
|
|
1750
|
-
text:
|
|
1904
|
+
coordinate: import_v48.z.array(import_v48.z.number().int()).optional(),
|
|
1905
|
+
text: import_v48.z.string().optional()
|
|
1751
1906
|
})
|
|
1752
1907
|
});
|
|
1753
1908
|
|
|
1754
1909
|
// src/tool/computer_20250124.ts
|
|
1755
|
-
var
|
|
1756
|
-
var
|
|
1757
|
-
var computer_20250124 = (0,
|
|
1910
|
+
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1911
|
+
var import_v49 = require("zod/v4");
|
|
1912
|
+
var computer_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1758
1913
|
id: "anthropic.computer_20250124",
|
|
1759
1914
|
name: "computer",
|
|
1760
|
-
inputSchema:
|
|
1761
|
-
action:
|
|
1915
|
+
inputSchema: import_v49.z.object({
|
|
1916
|
+
action: import_v49.z.enum([
|
|
1762
1917
|
"key",
|
|
1763
1918
|
"hold_key",
|
|
1764
1919
|
"type",
|
|
@@ -1776,37 +1931,20 @@ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFact
|
|
|
1776
1931
|
"wait",
|
|
1777
1932
|
"screenshot"
|
|
1778
1933
|
]),
|
|
1779
|
-
coordinate:
|
|
1780
|
-
duration:
|
|
1781
|
-
scroll_amount:
|
|
1782
|
-
scroll_direction:
|
|
1783
|
-
start_coordinate:
|
|
1784
|
-
text:
|
|
1934
|
+
coordinate: import_v49.z.tuple([import_v49.z.number().int(), import_v49.z.number().int()]).optional(),
|
|
1935
|
+
duration: import_v49.z.number().optional(),
|
|
1936
|
+
scroll_amount: import_v49.z.number().optional(),
|
|
1937
|
+
scroll_direction: import_v49.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1938
|
+
start_coordinate: import_v49.z.tuple([import_v49.z.number().int(), import_v49.z.number().int()]).optional(),
|
|
1939
|
+
text: import_v49.z.string().optional()
|
|
1785
1940
|
})
|
|
1786
1941
|
});
|
|
1787
1942
|
|
|
1788
1943
|
// src/tool/text-editor_20241022.ts
|
|
1789
|
-
var import_provider_utils9 = require("@ai-sdk/provider-utils");
|
|
1790
|
-
var import_v49 = require("zod/v4");
|
|
1791
|
-
var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
|
|
1792
|
-
id: "anthropic.text_editor_20241022",
|
|
1793
|
-
name: "str_replace_editor",
|
|
1794
|
-
inputSchema: import_v49.z.object({
|
|
1795
|
-
command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1796
|
-
path: import_v49.z.string(),
|
|
1797
|
-
file_text: import_v49.z.string().optional(),
|
|
1798
|
-
insert_line: import_v49.z.number().int().optional(),
|
|
1799
|
-
new_str: import_v49.z.string().optional(),
|
|
1800
|
-
old_str: import_v49.z.string().optional(),
|
|
1801
|
-
view_range: import_v49.z.array(import_v49.z.number().int()).optional()
|
|
1802
|
-
})
|
|
1803
|
-
});
|
|
1804
|
-
|
|
1805
|
-
// src/tool/text-editor_20250124.ts
|
|
1806
1944
|
var import_provider_utils10 = require("@ai-sdk/provider-utils");
|
|
1807
1945
|
var import_v410 = require("zod/v4");
|
|
1808
|
-
var
|
|
1809
|
-
id: "anthropic.
|
|
1946
|
+
var textEditor_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
|
|
1947
|
+
id: "anthropic.text_editor_20241022",
|
|
1810
1948
|
name: "str_replace_editor",
|
|
1811
1949
|
inputSchema: import_v410.z.object({
|
|
1812
1950
|
command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
@@ -1819,14 +1957,14 @@ var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolF
|
|
|
1819
1957
|
})
|
|
1820
1958
|
});
|
|
1821
1959
|
|
|
1822
|
-
// src/tool/text-
|
|
1960
|
+
// src/tool/text-editor_20250124.ts
|
|
1823
1961
|
var import_provider_utils11 = require("@ai-sdk/provider-utils");
|
|
1824
1962
|
var import_v411 = require("zod/v4");
|
|
1825
|
-
var
|
|
1826
|
-
id: "anthropic.
|
|
1827
|
-
name: "
|
|
1963
|
+
var textEditor_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
|
|
1964
|
+
id: "anthropic.text_editor_20250124",
|
|
1965
|
+
name: "str_replace_editor",
|
|
1828
1966
|
inputSchema: import_v411.z.object({
|
|
1829
|
-
command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
|
|
1967
|
+
command: import_v411.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1830
1968
|
path: import_v411.z.string(),
|
|
1831
1969
|
file_text: import_v411.z.string().optional(),
|
|
1832
1970
|
insert_line: import_v411.z.number().int().optional(),
|
|
@@ -1836,6 +1974,23 @@ var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolF
|
|
|
1836
1974
|
})
|
|
1837
1975
|
});
|
|
1838
1976
|
|
|
1977
|
+
// src/tool/text-editor_20250429.ts
|
|
1978
|
+
var import_provider_utils12 = require("@ai-sdk/provider-utils");
|
|
1979
|
+
var import_v412 = require("zod/v4");
|
|
1980
|
+
var textEditor_20250429 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
|
|
1981
|
+
id: "anthropic.text_editor_20250429",
|
|
1982
|
+
name: "str_replace_based_edit_tool",
|
|
1983
|
+
inputSchema: import_v412.z.object({
|
|
1984
|
+
command: import_v412.z.enum(["view", "create", "str_replace", "insert"]),
|
|
1985
|
+
path: import_v412.z.string(),
|
|
1986
|
+
file_text: import_v412.z.string().optional(),
|
|
1987
|
+
insert_line: import_v412.z.number().int().optional(),
|
|
1988
|
+
new_str: import_v412.z.string().optional(),
|
|
1989
|
+
old_str: import_v412.z.string().optional(),
|
|
1990
|
+
view_range: import_v412.z.array(import_v412.z.number().int()).optional()
|
|
1991
|
+
})
|
|
1992
|
+
});
|
|
1993
|
+
|
|
1839
1994
|
// src/anthropic-tools.ts
|
|
1840
1995
|
var anthropicTools = {
|
|
1841
1996
|
/**
|
|
@@ -1897,16 +2052,20 @@ var anthropicTools = {
|
|
|
1897
2052
|
* @param blockedDomains - Optional list of domains that Claude should avoid when searching.
|
|
1898
2053
|
* @param userLocation - Optional user location information to provide geographically relevant search results.
|
|
1899
2054
|
*/
|
|
1900
|
-
webSearch_20250305
|
|
2055
|
+
webSearch_20250305,
|
|
2056
|
+
/**
|
|
2057
|
+
* Creates a tool for executing Python code. Must have name "code_execution".
|
|
2058
|
+
*/
|
|
2059
|
+
codeExecution_20250522
|
|
1901
2060
|
};
|
|
1902
2061
|
|
|
1903
2062
|
// src/anthropic-provider.ts
|
|
1904
2063
|
function createAnthropic(options = {}) {
|
|
1905
2064
|
var _a;
|
|
1906
|
-
const baseURL = (_a = (0,
|
|
2065
|
+
const baseURL = (_a = (0, import_provider_utils13.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
|
|
1907
2066
|
const getHeaders = () => ({
|
|
1908
2067
|
"anthropic-version": "2023-06-01",
|
|
1909
|
-
"x-api-key": (0,
|
|
2068
|
+
"x-api-key": (0, import_provider_utils13.loadApiKey)({
|
|
1910
2069
|
apiKey: options.apiKey,
|
|
1911
2070
|
environmentVariableName: "ANTHROPIC_API_KEY",
|
|
1912
2071
|
description: "Anthropic"
|
|
@@ -1920,7 +2079,7 @@ function createAnthropic(options = {}) {
|
|
|
1920
2079
|
baseURL,
|
|
1921
2080
|
headers: getHeaders,
|
|
1922
2081
|
fetch: options.fetch,
|
|
1923
|
-
generateId: (_a2 = options.generateId) != null ? _a2 :
|
|
2082
|
+
generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils13.generateId,
|
|
1924
2083
|
supportedUrls: () => ({
|
|
1925
2084
|
"image/*": [/^https?:\/\/.*$/]
|
|
1926
2085
|
})
|