@ai-sdk/anthropic 2.0.0-canary.11 → 2.0.0-canary.12
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 +11 -0
- package/dist/index.d.mts +9 -19
- package/dist/index.d.ts +9 -19
- package/dist/index.js +151 -143
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -143
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +2 -20
- package/dist/internal/index.d.ts +2 -20
- package/dist/internal/index.js +148 -140
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +148 -140
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 2.0.0-canary.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5c9eec4: chore(providers/anthropic): switch to providerOptions
|
|
8
|
+
- Updated dependencies [9bf7291]
|
|
9
|
+
- Updated dependencies [4617fab]
|
|
10
|
+
- Updated dependencies [e030615]
|
|
11
|
+
- @ai-sdk/provider@2.0.0-canary.11
|
|
12
|
+
- @ai-sdk/provider-utils@3.0.0-canary.12
|
|
13
|
+
|
|
3
14
|
## 2.0.0-canary.11
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -3,25 +3,13 @@ import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
|
3
3
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
5
|
type AnthropicMessagesModelId = 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
Enable Anthropic cache control. This will allow you to use provider-specific
|
|
9
|
-
`cacheControl` metadata.
|
|
10
|
-
|
|
11
|
-
@deprecated cache control is now enabled by default (meaning you are able to
|
|
12
|
-
optionally mark content for caching) and this setting is no longer needed.
|
|
13
|
-
*/
|
|
14
|
-
cacheControl?: boolean;
|
|
6
|
+
declare const anthropicProviderOptions: z.ZodObject<{
|
|
15
7
|
/**
|
|
16
8
|
Include reasoning content in requests sent to the model. Defaults to `true`.
|
|
17
9
|
|
|
18
10
|
If you are experiencing issues with the model handling requests involving
|
|
19
|
-
reasoning content, you can set this to `false` to omit them from the request.
|
|
20
11
|
*/
|
|
21
|
-
sendReasoning
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const anthropicProviderOptionsSchema: z.ZodObject<{
|
|
12
|
+
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
25
13
|
thinking: z.ZodOptional<z.ZodObject<{
|
|
26
14
|
type: z.ZodUnion<[z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
|
|
27
15
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
@@ -33,17 +21,19 @@ declare const anthropicProviderOptionsSchema: z.ZodObject<{
|
|
|
33
21
|
budgetTokens?: number | undefined;
|
|
34
22
|
}>>;
|
|
35
23
|
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
sendReasoning?: boolean | undefined;
|
|
36
25
|
thinking?: {
|
|
37
26
|
type: "enabled" | "disabled";
|
|
38
27
|
budgetTokens?: number | undefined;
|
|
39
28
|
} | undefined;
|
|
40
29
|
}, {
|
|
30
|
+
sendReasoning?: boolean | undefined;
|
|
41
31
|
thinking?: {
|
|
42
32
|
type: "enabled" | "disabled";
|
|
43
33
|
budgetTokens?: number | undefined;
|
|
44
34
|
} | undefined;
|
|
45
35
|
}>;
|
|
46
|
-
type AnthropicProviderOptions = z.infer<typeof
|
|
36
|
+
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
47
37
|
|
|
48
38
|
type ExecuteFunction<PARAMETERS, RESULT> = undefined | ((args: PARAMETERS, options: {
|
|
49
39
|
abortSignal?: AbortSignal;
|
|
@@ -444,19 +434,19 @@ interface AnthropicProvider extends ProviderV2 {
|
|
|
444
434
|
/**
|
|
445
435
|
Creates a model for text generation.
|
|
446
436
|
*/
|
|
447
|
-
(modelId: AnthropicMessagesModelId
|
|
437
|
+
(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
448
438
|
/**
|
|
449
439
|
Creates a model for text generation.
|
|
450
440
|
*/
|
|
451
|
-
languageModel(modelId: AnthropicMessagesModelId
|
|
441
|
+
languageModel(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
452
442
|
/**
|
|
453
443
|
@deprecated Use `.languageModel()` instead.
|
|
454
444
|
*/
|
|
455
|
-
chat(modelId: AnthropicMessagesModelId
|
|
445
|
+
chat(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
456
446
|
/**
|
|
457
447
|
@deprecated Use `.languageModel()` instead.
|
|
458
448
|
*/
|
|
459
|
-
messages(modelId: AnthropicMessagesModelId
|
|
449
|
+
messages(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
460
450
|
/**
|
|
461
451
|
Anthropic-specific computer use tool.
|
|
462
452
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3,25 +3,13 @@ import { ProviderV2, LanguageModelV2 } from '@ai-sdk/provider';
|
|
|
3
3
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
5
|
type AnthropicMessagesModelId = 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
Enable Anthropic cache control. This will allow you to use provider-specific
|
|
9
|
-
`cacheControl` metadata.
|
|
10
|
-
|
|
11
|
-
@deprecated cache control is now enabled by default (meaning you are able to
|
|
12
|
-
optionally mark content for caching) and this setting is no longer needed.
|
|
13
|
-
*/
|
|
14
|
-
cacheControl?: boolean;
|
|
6
|
+
declare const anthropicProviderOptions: z.ZodObject<{
|
|
15
7
|
/**
|
|
16
8
|
Include reasoning content in requests sent to the model. Defaults to `true`.
|
|
17
9
|
|
|
18
10
|
If you are experiencing issues with the model handling requests involving
|
|
19
|
-
reasoning content, you can set this to `false` to omit them from the request.
|
|
20
11
|
*/
|
|
21
|
-
sendReasoning
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare const anthropicProviderOptionsSchema: z.ZodObject<{
|
|
12
|
+
sendReasoning: z.ZodOptional<z.ZodBoolean>;
|
|
25
13
|
thinking: z.ZodOptional<z.ZodObject<{
|
|
26
14
|
type: z.ZodUnion<[z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
|
|
27
15
|
budgetTokens: z.ZodOptional<z.ZodNumber>;
|
|
@@ -33,17 +21,19 @@ declare const anthropicProviderOptionsSchema: z.ZodObject<{
|
|
|
33
21
|
budgetTokens?: number | undefined;
|
|
34
22
|
}>>;
|
|
35
23
|
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
sendReasoning?: boolean | undefined;
|
|
36
25
|
thinking?: {
|
|
37
26
|
type: "enabled" | "disabled";
|
|
38
27
|
budgetTokens?: number | undefined;
|
|
39
28
|
} | undefined;
|
|
40
29
|
}, {
|
|
30
|
+
sendReasoning?: boolean | undefined;
|
|
41
31
|
thinking?: {
|
|
42
32
|
type: "enabled" | "disabled";
|
|
43
33
|
budgetTokens?: number | undefined;
|
|
44
34
|
} | undefined;
|
|
45
35
|
}>;
|
|
46
|
-
type AnthropicProviderOptions = z.infer<typeof
|
|
36
|
+
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
47
37
|
|
|
48
38
|
type ExecuteFunction<PARAMETERS, RESULT> = undefined | ((args: PARAMETERS, options: {
|
|
49
39
|
abortSignal?: AbortSignal;
|
|
@@ -444,19 +434,19 @@ interface AnthropicProvider extends ProviderV2 {
|
|
|
444
434
|
/**
|
|
445
435
|
Creates a model for text generation.
|
|
446
436
|
*/
|
|
447
|
-
(modelId: AnthropicMessagesModelId
|
|
437
|
+
(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
448
438
|
/**
|
|
449
439
|
Creates a model for text generation.
|
|
450
440
|
*/
|
|
451
|
-
languageModel(modelId: AnthropicMessagesModelId
|
|
441
|
+
languageModel(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
452
442
|
/**
|
|
453
443
|
@deprecated Use `.languageModel()` instead.
|
|
454
444
|
*/
|
|
455
|
-
chat(modelId: AnthropicMessagesModelId
|
|
445
|
+
chat(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
456
446
|
/**
|
|
457
447
|
@deprecated Use `.languageModel()` instead.
|
|
458
448
|
*/
|
|
459
|
-
messages(modelId: AnthropicMessagesModelId
|
|
449
|
+
messages(modelId: AnthropicMessagesModelId): LanguageModelV2;
|
|
460
450
|
/**
|
|
461
451
|
Anthropic-specific computer use tool.
|
|
462
452
|
*/
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
|
|
32
32
|
// src/anthropic-messages-language-model.ts
|
|
33
33
|
var import_provider3 = require("@ai-sdk/provider");
|
|
34
34
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
35
|
-
var
|
|
35
|
+
var import_zod3 = require("zod");
|
|
36
36
|
|
|
37
37
|
// src/anthropic-error.ts
|
|
38
38
|
var import_provider_utils = require("@ai-sdk/provider-utils");
|
|
@@ -49,6 +49,21 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
|
|
|
49
49
|
errorToMessage: (data) => data.error.message
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
// src/anthropic-messages-options.ts
|
|
53
|
+
var import_zod2 = require("zod");
|
|
54
|
+
var anthropicProviderOptions = import_zod2.z.object({
|
|
55
|
+
/**
|
|
56
|
+
Include reasoning content in requests sent to the model. Defaults to `true`.
|
|
57
|
+
|
|
58
|
+
If you are experiencing issues with the model handling requests involving
|
|
59
|
+
*/
|
|
60
|
+
sendReasoning: import_zod2.z.boolean().optional(),
|
|
61
|
+
thinking: import_zod2.z.object({
|
|
62
|
+
type: import_zod2.z.union([import_zod2.z.literal("enabled"), import_zod2.z.literal("disabled")]),
|
|
63
|
+
budgetTokens: import_zod2.z.number().optional()
|
|
64
|
+
}).optional()
|
|
65
|
+
});
|
|
66
|
+
|
|
52
67
|
// src/anthropic-prepare-tools.ts
|
|
53
68
|
var import_provider = require("@ai-sdk/provider");
|
|
54
69
|
function prepareTools({
|
|
@@ -469,10 +484,9 @@ function mapAnthropicStopReason(finishReason) {
|
|
|
469
484
|
|
|
470
485
|
// src/anthropic-messages-language-model.ts
|
|
471
486
|
var AnthropicMessagesLanguageModel = class {
|
|
472
|
-
constructor(modelId,
|
|
487
|
+
constructor(modelId, config) {
|
|
473
488
|
this.specificationVersion = "v2";
|
|
474
489
|
this.modelId = modelId;
|
|
475
|
-
this.settings = settings;
|
|
476
490
|
this.config = config;
|
|
477
491
|
}
|
|
478
492
|
supportsUrl(url) {
|
|
@@ -528,15 +542,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
528
542
|
details: "JSON response format is not supported."
|
|
529
543
|
});
|
|
530
544
|
}
|
|
531
|
-
const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
|
|
532
|
-
prompt,
|
|
533
|
-
sendReasoning: (_a = this.settings.sendReasoning) != null ? _a : true,
|
|
534
|
-
warnings
|
|
535
|
-
});
|
|
536
545
|
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
537
546
|
provider: "anthropic",
|
|
538
547
|
providerOptions,
|
|
539
|
-
schema:
|
|
548
|
+
schema: anthropicProviderOptions
|
|
549
|
+
});
|
|
550
|
+
const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
|
|
551
|
+
prompt,
|
|
552
|
+
sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
|
|
553
|
+
warnings
|
|
540
554
|
});
|
|
541
555
|
const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
|
|
542
556
|
const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
|
|
@@ -897,139 +911,133 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
897
911
|
};
|
|
898
912
|
}
|
|
899
913
|
};
|
|
900
|
-
var anthropicMessagesResponseSchema =
|
|
901
|
-
type:
|
|
902
|
-
id:
|
|
903
|
-
model:
|
|
904
|
-
content:
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
type:
|
|
908
|
-
text:
|
|
914
|
+
var anthropicMessagesResponseSchema = import_zod3.z.object({
|
|
915
|
+
type: import_zod3.z.literal("message"),
|
|
916
|
+
id: import_zod3.z.string().nullish(),
|
|
917
|
+
model: import_zod3.z.string().nullish(),
|
|
918
|
+
content: import_zod3.z.array(
|
|
919
|
+
import_zod3.z.discriminatedUnion("type", [
|
|
920
|
+
import_zod3.z.object({
|
|
921
|
+
type: import_zod3.z.literal("text"),
|
|
922
|
+
text: import_zod3.z.string()
|
|
909
923
|
}),
|
|
910
|
-
|
|
911
|
-
type:
|
|
912
|
-
thinking:
|
|
913
|
-
signature:
|
|
924
|
+
import_zod3.z.object({
|
|
925
|
+
type: import_zod3.z.literal("thinking"),
|
|
926
|
+
thinking: import_zod3.z.string(),
|
|
927
|
+
signature: import_zod3.z.string()
|
|
914
928
|
}),
|
|
915
|
-
|
|
916
|
-
type:
|
|
917
|
-
data:
|
|
929
|
+
import_zod3.z.object({
|
|
930
|
+
type: import_zod3.z.literal("redacted_thinking"),
|
|
931
|
+
data: import_zod3.z.string()
|
|
918
932
|
}),
|
|
919
|
-
|
|
920
|
-
type:
|
|
921
|
-
id:
|
|
922
|
-
name:
|
|
923
|
-
input:
|
|
933
|
+
import_zod3.z.object({
|
|
934
|
+
type: import_zod3.z.literal("tool_use"),
|
|
935
|
+
id: import_zod3.z.string(),
|
|
936
|
+
name: import_zod3.z.string(),
|
|
937
|
+
input: import_zod3.z.unknown()
|
|
924
938
|
})
|
|
925
939
|
])
|
|
926
940
|
),
|
|
927
|
-
stop_reason:
|
|
928
|
-
usage:
|
|
929
|
-
input_tokens:
|
|
930
|
-
output_tokens:
|
|
931
|
-
cache_creation_input_tokens:
|
|
932
|
-
cache_read_input_tokens:
|
|
941
|
+
stop_reason: import_zod3.z.string().nullish(),
|
|
942
|
+
usage: import_zod3.z.object({
|
|
943
|
+
input_tokens: import_zod3.z.number(),
|
|
944
|
+
output_tokens: import_zod3.z.number(),
|
|
945
|
+
cache_creation_input_tokens: import_zod3.z.number().nullish(),
|
|
946
|
+
cache_read_input_tokens: import_zod3.z.number().nullish()
|
|
933
947
|
})
|
|
934
948
|
});
|
|
935
|
-
var anthropicMessagesChunkSchema =
|
|
936
|
-
|
|
937
|
-
type:
|
|
938
|
-
message:
|
|
939
|
-
id:
|
|
940
|
-
model:
|
|
941
|
-
usage:
|
|
942
|
-
input_tokens:
|
|
943
|
-
output_tokens:
|
|
944
|
-
cache_creation_input_tokens:
|
|
945
|
-
cache_read_input_tokens:
|
|
949
|
+
var anthropicMessagesChunkSchema = import_zod3.z.discriminatedUnion("type", [
|
|
950
|
+
import_zod3.z.object({
|
|
951
|
+
type: import_zod3.z.literal("message_start"),
|
|
952
|
+
message: import_zod3.z.object({
|
|
953
|
+
id: import_zod3.z.string().nullish(),
|
|
954
|
+
model: import_zod3.z.string().nullish(),
|
|
955
|
+
usage: import_zod3.z.object({
|
|
956
|
+
input_tokens: import_zod3.z.number(),
|
|
957
|
+
output_tokens: import_zod3.z.number(),
|
|
958
|
+
cache_creation_input_tokens: import_zod3.z.number().nullish(),
|
|
959
|
+
cache_read_input_tokens: import_zod3.z.number().nullish()
|
|
946
960
|
})
|
|
947
961
|
})
|
|
948
962
|
}),
|
|
949
|
-
|
|
950
|
-
type:
|
|
951
|
-
index:
|
|
952
|
-
content_block:
|
|
953
|
-
|
|
954
|
-
type:
|
|
955
|
-
text:
|
|
963
|
+
import_zod3.z.object({
|
|
964
|
+
type: import_zod3.z.literal("content_block_start"),
|
|
965
|
+
index: import_zod3.z.number(),
|
|
966
|
+
content_block: import_zod3.z.discriminatedUnion("type", [
|
|
967
|
+
import_zod3.z.object({
|
|
968
|
+
type: import_zod3.z.literal("text"),
|
|
969
|
+
text: import_zod3.z.string()
|
|
956
970
|
}),
|
|
957
|
-
|
|
958
|
-
type:
|
|
959
|
-
thinking:
|
|
971
|
+
import_zod3.z.object({
|
|
972
|
+
type: import_zod3.z.literal("thinking"),
|
|
973
|
+
thinking: import_zod3.z.string()
|
|
960
974
|
}),
|
|
961
|
-
|
|
962
|
-
type:
|
|
963
|
-
id:
|
|
964
|
-
name:
|
|
975
|
+
import_zod3.z.object({
|
|
976
|
+
type: import_zod3.z.literal("tool_use"),
|
|
977
|
+
id: import_zod3.z.string(),
|
|
978
|
+
name: import_zod3.z.string()
|
|
965
979
|
}),
|
|
966
|
-
|
|
967
|
-
type:
|
|
968
|
-
data:
|
|
980
|
+
import_zod3.z.object({
|
|
981
|
+
type: import_zod3.z.literal("redacted_thinking"),
|
|
982
|
+
data: import_zod3.z.string()
|
|
969
983
|
})
|
|
970
984
|
])
|
|
971
985
|
}),
|
|
972
|
-
|
|
973
|
-
type:
|
|
974
|
-
index:
|
|
975
|
-
delta:
|
|
976
|
-
|
|
977
|
-
type:
|
|
978
|
-
partial_json:
|
|
986
|
+
import_zod3.z.object({
|
|
987
|
+
type: import_zod3.z.literal("content_block_delta"),
|
|
988
|
+
index: import_zod3.z.number(),
|
|
989
|
+
delta: import_zod3.z.discriminatedUnion("type", [
|
|
990
|
+
import_zod3.z.object({
|
|
991
|
+
type: import_zod3.z.literal("input_json_delta"),
|
|
992
|
+
partial_json: import_zod3.z.string()
|
|
979
993
|
}),
|
|
980
|
-
|
|
981
|
-
type:
|
|
982
|
-
text:
|
|
994
|
+
import_zod3.z.object({
|
|
995
|
+
type: import_zod3.z.literal("text_delta"),
|
|
996
|
+
text: import_zod3.z.string()
|
|
983
997
|
}),
|
|
984
|
-
|
|
985
|
-
type:
|
|
986
|
-
thinking:
|
|
998
|
+
import_zod3.z.object({
|
|
999
|
+
type: import_zod3.z.literal("thinking_delta"),
|
|
1000
|
+
thinking: import_zod3.z.string()
|
|
987
1001
|
}),
|
|
988
|
-
|
|
989
|
-
type:
|
|
990
|
-
signature:
|
|
1002
|
+
import_zod3.z.object({
|
|
1003
|
+
type: import_zod3.z.literal("signature_delta"),
|
|
1004
|
+
signature: import_zod3.z.string()
|
|
991
1005
|
})
|
|
992
1006
|
])
|
|
993
1007
|
}),
|
|
994
|
-
|
|
995
|
-
type:
|
|
996
|
-
index:
|
|
1008
|
+
import_zod3.z.object({
|
|
1009
|
+
type: import_zod3.z.literal("content_block_stop"),
|
|
1010
|
+
index: import_zod3.z.number()
|
|
997
1011
|
}),
|
|
998
|
-
|
|
999
|
-
type:
|
|
1000
|
-
error:
|
|
1001
|
-
type:
|
|
1002
|
-
message:
|
|
1012
|
+
import_zod3.z.object({
|
|
1013
|
+
type: import_zod3.z.literal("error"),
|
|
1014
|
+
error: import_zod3.z.object({
|
|
1015
|
+
type: import_zod3.z.string(),
|
|
1016
|
+
message: import_zod3.z.string()
|
|
1003
1017
|
})
|
|
1004
1018
|
}),
|
|
1005
|
-
|
|
1006
|
-
type:
|
|
1007
|
-
delta:
|
|
1008
|
-
usage:
|
|
1019
|
+
import_zod3.z.object({
|
|
1020
|
+
type: import_zod3.z.literal("message_delta"),
|
|
1021
|
+
delta: import_zod3.z.object({ stop_reason: import_zod3.z.string().nullish() }),
|
|
1022
|
+
usage: import_zod3.z.object({ output_tokens: import_zod3.z.number() })
|
|
1009
1023
|
}),
|
|
1010
|
-
|
|
1011
|
-
type:
|
|
1024
|
+
import_zod3.z.object({
|
|
1025
|
+
type: import_zod3.z.literal("message_stop")
|
|
1012
1026
|
}),
|
|
1013
|
-
|
|
1014
|
-
type:
|
|
1027
|
+
import_zod3.z.object({
|
|
1028
|
+
type: import_zod3.z.literal("ping")
|
|
1015
1029
|
})
|
|
1016
1030
|
]);
|
|
1017
|
-
var
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
budgetTokens: import_zod2.z.number().optional()
|
|
1021
|
-
}).optional()
|
|
1022
|
-
});
|
|
1023
|
-
var anthropicReasoningMetadataSchema = import_zod2.z.object({
|
|
1024
|
-
signature: import_zod2.z.string().optional(),
|
|
1025
|
-
redactedData: import_zod2.z.string().optional()
|
|
1031
|
+
var anthropicReasoningMetadataSchema = import_zod3.z.object({
|
|
1032
|
+
signature: import_zod3.z.string().optional(),
|
|
1033
|
+
redactedData: import_zod3.z.string().optional()
|
|
1026
1034
|
});
|
|
1027
1035
|
|
|
1028
1036
|
// src/anthropic-tools.ts
|
|
1029
|
-
var
|
|
1030
|
-
var Bash20241022Parameters =
|
|
1031
|
-
command:
|
|
1032
|
-
restart:
|
|
1037
|
+
var import_zod4 = require("zod");
|
|
1038
|
+
var Bash20241022Parameters = import_zod4.z.object({
|
|
1039
|
+
command: import_zod4.z.string(),
|
|
1040
|
+
restart: import_zod4.z.boolean().optional()
|
|
1033
1041
|
});
|
|
1034
1042
|
function bashTool_20241022(options = {}) {
|
|
1035
1043
|
return {
|
|
@@ -1041,9 +1049,9 @@ function bashTool_20241022(options = {}) {
|
|
|
1041
1049
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1042
1050
|
};
|
|
1043
1051
|
}
|
|
1044
|
-
var Bash20250124Parameters =
|
|
1045
|
-
command:
|
|
1046
|
-
restart:
|
|
1052
|
+
var Bash20250124Parameters = import_zod4.z.object({
|
|
1053
|
+
command: import_zod4.z.string(),
|
|
1054
|
+
restart: import_zod4.z.boolean().optional()
|
|
1047
1055
|
});
|
|
1048
1056
|
function bashTool_20250124(options = {}) {
|
|
1049
1057
|
return {
|
|
@@ -1055,14 +1063,14 @@ function bashTool_20250124(options = {}) {
|
|
|
1055
1063
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1056
1064
|
};
|
|
1057
1065
|
}
|
|
1058
|
-
var TextEditor20241022Parameters =
|
|
1059
|
-
command:
|
|
1060
|
-
path:
|
|
1061
|
-
file_text:
|
|
1062
|
-
insert_line:
|
|
1063
|
-
new_str:
|
|
1064
|
-
old_str:
|
|
1065
|
-
view_range:
|
|
1066
|
+
var TextEditor20241022Parameters = import_zod4.z.object({
|
|
1067
|
+
command: import_zod4.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1068
|
+
path: import_zod4.z.string(),
|
|
1069
|
+
file_text: import_zod4.z.string().optional(),
|
|
1070
|
+
insert_line: import_zod4.z.number().int().optional(),
|
|
1071
|
+
new_str: import_zod4.z.string().optional(),
|
|
1072
|
+
old_str: import_zod4.z.string().optional(),
|
|
1073
|
+
view_range: import_zod4.z.array(import_zod4.z.number().int()).optional()
|
|
1066
1074
|
});
|
|
1067
1075
|
function textEditorTool_20241022(options = {}) {
|
|
1068
1076
|
return {
|
|
@@ -1074,14 +1082,14 @@ function textEditorTool_20241022(options = {}) {
|
|
|
1074
1082
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1075
1083
|
};
|
|
1076
1084
|
}
|
|
1077
|
-
var TextEditor20250124Parameters =
|
|
1078
|
-
command:
|
|
1079
|
-
path:
|
|
1080
|
-
file_text:
|
|
1081
|
-
insert_line:
|
|
1082
|
-
new_str:
|
|
1083
|
-
old_str:
|
|
1084
|
-
view_range:
|
|
1085
|
+
var TextEditor20250124Parameters = import_zod4.z.object({
|
|
1086
|
+
command: import_zod4.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1087
|
+
path: import_zod4.z.string(),
|
|
1088
|
+
file_text: import_zod4.z.string().optional(),
|
|
1089
|
+
insert_line: import_zod4.z.number().int().optional(),
|
|
1090
|
+
new_str: import_zod4.z.string().optional(),
|
|
1091
|
+
old_str: import_zod4.z.string().optional(),
|
|
1092
|
+
view_range: import_zod4.z.array(import_zod4.z.number().int()).optional()
|
|
1085
1093
|
});
|
|
1086
1094
|
function textEditorTool_20250124(options = {}) {
|
|
1087
1095
|
return {
|
|
@@ -1093,8 +1101,8 @@ function textEditorTool_20250124(options = {}) {
|
|
|
1093
1101
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1094
1102
|
};
|
|
1095
1103
|
}
|
|
1096
|
-
var Computer20241022Parameters =
|
|
1097
|
-
action:
|
|
1104
|
+
var Computer20241022Parameters = import_zod4.z.object({
|
|
1105
|
+
action: import_zod4.z.enum([
|
|
1098
1106
|
"key",
|
|
1099
1107
|
"type",
|
|
1100
1108
|
"mouse_move",
|
|
@@ -1106,8 +1114,8 @@ var Computer20241022Parameters = import_zod3.z.object({
|
|
|
1106
1114
|
"screenshot",
|
|
1107
1115
|
"cursor_position"
|
|
1108
1116
|
]),
|
|
1109
|
-
coordinate:
|
|
1110
|
-
text:
|
|
1117
|
+
coordinate: import_zod4.z.array(import_zod4.z.number().int()).optional(),
|
|
1118
|
+
text: import_zod4.z.string().optional()
|
|
1111
1119
|
});
|
|
1112
1120
|
function computerTool_20241022(options) {
|
|
1113
1121
|
return {
|
|
@@ -1123,8 +1131,8 @@ function computerTool_20241022(options) {
|
|
|
1123
1131
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1124
1132
|
};
|
|
1125
1133
|
}
|
|
1126
|
-
var Computer20250124Parameters =
|
|
1127
|
-
action:
|
|
1134
|
+
var Computer20250124Parameters = import_zod4.z.object({
|
|
1135
|
+
action: import_zod4.z.enum([
|
|
1128
1136
|
"key",
|
|
1129
1137
|
"hold_key",
|
|
1130
1138
|
"type",
|
|
@@ -1142,12 +1150,12 @@ var Computer20250124Parameters = import_zod3.z.object({
|
|
|
1142
1150
|
"wait",
|
|
1143
1151
|
"screenshot"
|
|
1144
1152
|
]),
|
|
1145
|
-
coordinate:
|
|
1146
|
-
duration:
|
|
1147
|
-
scroll_amount:
|
|
1148
|
-
scroll_direction:
|
|
1149
|
-
start_coordinate:
|
|
1150
|
-
text:
|
|
1153
|
+
coordinate: import_zod4.z.tuple([import_zod4.z.number().int(), import_zod4.z.number().int()]).optional(),
|
|
1154
|
+
duration: import_zod4.z.number().optional(),
|
|
1155
|
+
scroll_amount: import_zod4.z.number().optional(),
|
|
1156
|
+
scroll_direction: import_zod4.z.enum(["up", "down", "left", "right"]).optional(),
|
|
1157
|
+
start_coordinate: import_zod4.z.tuple([import_zod4.z.number().int(), import_zod4.z.number().int()]).optional(),
|
|
1158
|
+
text: import_zod4.z.string().optional()
|
|
1151
1159
|
});
|
|
1152
1160
|
function computerTool_20250124(options) {
|
|
1153
1161
|
return {
|
|
@@ -1185,7 +1193,7 @@ function createAnthropic(options = {}) {
|
|
|
1185
1193
|
}),
|
|
1186
1194
|
...options.headers
|
|
1187
1195
|
});
|
|
1188
|
-
const createChatModel = (modelId
|
|
1196
|
+
const createChatModel = (modelId) => new AnthropicMessagesLanguageModel(modelId, {
|
|
1189
1197
|
provider: "anthropic.messages",
|
|
1190
1198
|
baseURL,
|
|
1191
1199
|
headers: getHeaders,
|
|
@@ -1194,13 +1202,13 @@ function createAnthropic(options = {}) {
|
|
|
1194
1202
|
"image/*": [/^https?:\/\/.*$/]
|
|
1195
1203
|
})
|
|
1196
1204
|
});
|
|
1197
|
-
const provider = function(modelId
|
|
1205
|
+
const provider = function(modelId) {
|
|
1198
1206
|
if (new.target) {
|
|
1199
1207
|
throw new Error(
|
|
1200
1208
|
"The Anthropic model function cannot be called with the new keyword."
|
|
1201
1209
|
);
|
|
1202
1210
|
}
|
|
1203
|
-
return createChatModel(modelId
|
|
1211
|
+
return createChatModel(modelId);
|
|
1204
1212
|
};
|
|
1205
1213
|
provider.languageModel = createChatModel;
|
|
1206
1214
|
provider.chat = createChatModel;
|