@fairyhunter13/ai-anthropic 3.0.58-fork.19 → 3.0.58-fork.20
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 +14 -0
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +33 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +32 -11
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +32 -11
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +8 -2
- package/package.json +3 -3
- package/src/anthropic-messages-api.ts +12 -7
- package/src/anthropic-messages-language-model.ts +3 -0
- package/src/anthropic-messages-options.ts +17 -11
- package/src/convert-to-anthropic-messages-prompt.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [1f509d4]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
9
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
10
|
+
|
|
11
|
+
## 4.0.0-beta.11
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 0ee8aec: feat (provider/anthropic): support passing metadata.user_id
|
|
16
|
+
|
|
3
17
|
## 4.0.0-beta.10
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -157,6 +157,9 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
|
157
157
|
type: z.ZodLiteral<"ephemeral">;
|
|
158
158
|
ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
|
|
159
159
|
}, z.core.$strip>>;
|
|
160
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
161
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, z.core.$strip>>;
|
|
160
163
|
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
161
164
|
type: z.ZodLiteral<"url">;
|
|
162
165
|
name: z.ZodString;
|
|
@@ -188,9 +191,6 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
|
188
191
|
}>>;
|
|
189
192
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
193
|
prefill: z.ZodOptional<z.ZodString>;
|
|
191
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
192
|
-
userId: z.ZodOptional<z.ZodString>;
|
|
193
|
-
}, z.core.$strip>>;
|
|
194
194
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
195
195
|
auto: "auto";
|
|
196
196
|
}>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -157,6 +157,9 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
|
157
157
|
type: z.ZodLiteral<"ephemeral">;
|
|
158
158
|
ttl: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"5m">, z.ZodLiteral<"1h">]>>;
|
|
159
159
|
}, z.core.$strip>>;
|
|
160
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
161
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
162
|
+
}, z.core.$strip>>;
|
|
160
163
|
mcpServers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
161
164
|
type: z.ZodLiteral<"url">;
|
|
162
165
|
name: z.ZodString;
|
|
@@ -188,9 +191,6 @@ declare const anthropicLanguageModelOptions: z.ZodObject<{
|
|
|
188
191
|
}>>;
|
|
189
192
|
anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
193
|
prefill: z.ZodOptional<z.ZodString>;
|
|
191
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
192
|
-
userId: z.ZodOptional<z.ZodString>;
|
|
193
|
-
}, z.core.$strip>>;
|
|
194
194
|
serviceTier: z.ZodOptional<z.ZodEnum<{
|
|
195
195
|
auto: "auto";
|
|
196
196
|
}>>;
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var import_provider4 = require("@ai-sdk/provider");
|
|
|
32
32
|
var import_provider_utils27 = require("@ai-sdk/provider-utils");
|
|
33
33
|
|
|
34
34
|
// src/version.ts
|
|
35
|
-
var VERSION = true ? "4.0.0-beta.
|
|
35
|
+
var VERSION = true ? "4.0.0-beta.12" : "0.0.0-test";
|
|
36
36
|
|
|
37
37
|
// src/anthropic-messages-language-model.ts
|
|
38
38
|
var import_provider3 = require("@ai-sdk/provider");
|
|
@@ -881,6 +881,20 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
881
881
|
type: import_v43.z.literal("ephemeral"),
|
|
882
882
|
ttl: import_v43.z.union([import_v43.z.literal("5m"), import_v43.z.literal("1h")]).optional()
|
|
883
883
|
}).optional(),
|
|
884
|
+
/**
|
|
885
|
+
* Metadata to include with the request.
|
|
886
|
+
*
|
|
887
|
+
* See https://platform.claude.com/docs/en/api/messages/create for details.
|
|
888
|
+
*/
|
|
889
|
+
metadata: import_v43.z.object({
|
|
890
|
+
/**
|
|
891
|
+
* An external identifier for the user associated with the request.
|
|
892
|
+
*
|
|
893
|
+
* Should be a UUID, hash value, or other opaque identifier.
|
|
894
|
+
* Must not contain PII (name, email, phone number, etc.).
|
|
895
|
+
*/
|
|
896
|
+
userId: import_v43.z.string().optional()
|
|
897
|
+
}).optional(),
|
|
884
898
|
/**
|
|
885
899
|
* MCP servers to be utilized in this request.
|
|
886
900
|
*/
|
|
@@ -942,14 +956,6 @@ var anthropicLanguageModelOptions = import_v43.z.object({
|
|
|
942
956
|
* Example: Setting prefill to '{"' will make the model start its response with '{"'
|
|
943
957
|
*/
|
|
944
958
|
prefill: import_v43.z.string().optional(),
|
|
945
|
-
/**
|
|
946
|
-
* Request metadata. Use `user_id` to track per-user usage for abuse detection
|
|
947
|
-
* and rate limit apportioning. Should be a UUID or similar opaque identifier.
|
|
948
|
-
* See https://docs.anthropic.com/en/api/messages
|
|
949
|
-
*/
|
|
950
|
-
metadata: import_v43.z.object({
|
|
951
|
-
userId: import_v43.z.string().optional()
|
|
952
|
-
}).optional(),
|
|
953
959
|
/**
|
|
954
960
|
* Service tier selection.
|
|
955
961
|
* - 'auto': Allow Anthropic to pick standard or priority based on availability.
|
|
@@ -2819,6 +2825,18 @@ async function convertToAnthropicMessagesPrompt({
|
|
|
2819
2825
|
}
|
|
2820
2826
|
if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
|
|
2821
2827
|
const output = part.output;
|
|
2828
|
+
if (output.type === "error-text" || output.type === "error-json") {
|
|
2829
|
+
anthropicContent.push({
|
|
2830
|
+
type: "tool_search_tool_result",
|
|
2831
|
+
tool_use_id: part.toolCallId,
|
|
2832
|
+
content: {
|
|
2833
|
+
type: "tool_search_tool_result_error",
|
|
2834
|
+
error_code: "unavailable"
|
|
2835
|
+
},
|
|
2836
|
+
cache_control: cacheControl
|
|
2837
|
+
});
|
|
2838
|
+
break;
|
|
2839
|
+
}
|
|
2822
2840
|
if (output.type !== "json") {
|
|
2823
2841
|
warnings.push({
|
|
2824
2842
|
type: "other",
|
|
@@ -3084,7 +3102,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3084
3102
|
providerOptions,
|
|
3085
3103
|
stream
|
|
3086
3104
|
}) {
|
|
3087
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
3105
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
3088
3106
|
const warnings = [];
|
|
3089
3107
|
if (frequencyPenalty != null) {
|
|
3090
3108
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -3272,6 +3290,9 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3272
3290
|
...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
|
|
3273
3291
|
cache_control: anthropicOptions.cacheControl
|
|
3274
3292
|
},
|
|
3293
|
+
...((_i = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _i.userId) != null && {
|
|
3294
|
+
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
3295
|
+
},
|
|
3275
3296
|
// mcp servers:
|
|
3276
3297
|
...(anthropicOptions == null ? void 0 : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
3277
3298
|
mcp_servers: anthropicOptions.mcpServers.map((server) => ({
|
|
@@ -3441,7 +3462,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3441
3462
|
if ((anthropicOptions == null ? void 0 : anthropicOptions.speed) === "fast") {
|
|
3442
3463
|
betas.add("fast-mode-2026-02-01");
|
|
3443
3464
|
}
|
|
3444
|
-
if (stream && ((
|
|
3465
|
+
if (stream && ((_j = anthropicOptions == null ? void 0 : anthropicOptions.toolStreaming) != null ? _j : true)) {
|
|
3445
3466
|
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
3446
3467
|
}
|
|
3447
3468
|
const {
|
|
@@ -3480,7 +3501,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3480
3501
|
...betas,
|
|
3481
3502
|
...toolsBetas,
|
|
3482
3503
|
...userSuppliedBetas,
|
|
3483
|
-
...(
|
|
3504
|
+
...(_k = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _k : []
|
|
3484
3505
|
]),
|
|
3485
3506
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
3486
3507
|
toolNameMapping,
|