@ai-sdk/anthropic 2.0.0-canary.10 → 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 +22 -0
- package/dist/index.d.mts +9 -19
- package/dist/index.d.ts +9 -19
- package/dist/index.js +209 -168
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +211 -170
- 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 +206 -165
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +208 -167
- package/dist/internal/index.mjs.map +1 -1
- package/internal.d.ts +1 -0
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
combineHeaders,
|
|
16
16
|
createEventSourceResponseHandler,
|
|
17
17
|
createJsonResponseHandler,
|
|
18
|
-
parseProviderOptions,
|
|
18
|
+
parseProviderOptions as parseProviderOptions2,
|
|
19
19
|
postJsonToApi,
|
|
20
20
|
resolve
|
|
21
21
|
} from "@ai-sdk/provider-utils";
|
|
22
|
-
import { z as
|
|
22
|
+
import { z as z3 } from "zod";
|
|
23
23
|
|
|
24
24
|
// src/anthropic-error.ts
|
|
25
25
|
import { createJsonErrorResponseHandler } from "@ai-sdk/provider-utils";
|
|
@@ -36,6 +36,21 @@ var anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
|
36
36
|
errorToMessage: (data) => data.error.message
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
// src/anthropic-messages-options.ts
|
|
40
|
+
import { z as z2 } from "zod";
|
|
41
|
+
var anthropicProviderOptions = z2.object({
|
|
42
|
+
/**
|
|
43
|
+
Include reasoning content in requests sent to the model. Defaults to `true`.
|
|
44
|
+
|
|
45
|
+
If you are experiencing issues with the model handling requests involving
|
|
46
|
+
*/
|
|
47
|
+
sendReasoning: z2.boolean().optional(),
|
|
48
|
+
thinking: z2.object({
|
|
49
|
+
type: z2.union([z2.literal("enabled"), z2.literal("disabled")]),
|
|
50
|
+
budgetTokens: z2.number().optional()
|
|
51
|
+
}).optional()
|
|
52
|
+
});
|
|
53
|
+
|
|
39
54
|
// src/anthropic-prepare-tools.ts
|
|
40
55
|
import {
|
|
41
56
|
UnsupportedFunctionalityError
|
|
@@ -166,8 +181,8 @@ function prepareTools({
|
|
|
166
181
|
import {
|
|
167
182
|
UnsupportedFunctionalityError as UnsupportedFunctionalityError2
|
|
168
183
|
} from "@ai-sdk/provider";
|
|
169
|
-
import { convertToBase64 } from "@ai-sdk/provider-utils";
|
|
170
|
-
function convertToAnthropicMessagesPrompt({
|
|
184
|
+
import { convertToBase64, parseProviderOptions } from "@ai-sdk/provider-utils";
|
|
185
|
+
async function convertToAnthropicMessagesPrompt({
|
|
171
186
|
prompt,
|
|
172
187
|
sendReasoning,
|
|
173
188
|
warnings
|
|
@@ -330,12 +345,37 @@ function convertToAnthropicMessagesPrompt({
|
|
|
330
345
|
}
|
|
331
346
|
case "reasoning": {
|
|
332
347
|
if (sendReasoning) {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
cache_control: cacheControl
|
|
348
|
+
const reasoningMetadata = await parseProviderOptions({
|
|
349
|
+
provider: "anthropic",
|
|
350
|
+
providerOptions: part.providerOptions,
|
|
351
|
+
schema: anthropicReasoningMetadataSchema
|
|
338
352
|
});
|
|
353
|
+
if (reasoningMetadata != null) {
|
|
354
|
+
if (reasoningMetadata.signature != null) {
|
|
355
|
+
anthropicContent.push({
|
|
356
|
+
type: "thinking",
|
|
357
|
+
thinking: part.text,
|
|
358
|
+
signature: reasoningMetadata.signature,
|
|
359
|
+
cache_control: cacheControl
|
|
360
|
+
});
|
|
361
|
+
} else if (reasoningMetadata.redactedData != null) {
|
|
362
|
+
anthropicContent.push({
|
|
363
|
+
type: "redacted_thinking",
|
|
364
|
+
data: reasoningMetadata.redactedData,
|
|
365
|
+
cache_control: cacheControl
|
|
366
|
+
});
|
|
367
|
+
} else {
|
|
368
|
+
warnings.push({
|
|
369
|
+
type: "other",
|
|
370
|
+
message: "unsupported reasoning metadata"
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
warnings.push({
|
|
375
|
+
type: "other",
|
|
376
|
+
message: "unsupported reasoning metadata"
|
|
377
|
+
});
|
|
378
|
+
}
|
|
339
379
|
} else {
|
|
340
380
|
warnings.push({
|
|
341
381
|
type: "other",
|
|
@@ -344,14 +384,6 @@ function convertToAnthropicMessagesPrompt({
|
|
|
344
384
|
}
|
|
345
385
|
break;
|
|
346
386
|
}
|
|
347
|
-
case "redacted-reasoning": {
|
|
348
|
-
anthropicContent.push({
|
|
349
|
-
type: "redacted_thinking",
|
|
350
|
-
data: part.data,
|
|
351
|
-
cache_control: cacheControl
|
|
352
|
-
});
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
355
387
|
case "tool-call": {
|
|
356
388
|
anthropicContent.push({
|
|
357
389
|
type: "tool_use",
|
|
@@ -443,10 +475,9 @@ function mapAnthropicStopReason(finishReason) {
|
|
|
443
475
|
|
|
444
476
|
// src/anthropic-messages-language-model.ts
|
|
445
477
|
var AnthropicMessagesLanguageModel = class {
|
|
446
|
-
constructor(modelId,
|
|
478
|
+
constructor(modelId, config) {
|
|
447
479
|
this.specificationVersion = "v2";
|
|
448
480
|
this.modelId = modelId;
|
|
449
|
-
this.settings = settings;
|
|
450
481
|
this.config = config;
|
|
451
482
|
}
|
|
452
483
|
supportsUrl(url) {
|
|
@@ -502,15 +533,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
502
533
|
details: "JSON response format is not supported."
|
|
503
534
|
});
|
|
504
535
|
}
|
|
505
|
-
const
|
|
506
|
-
prompt,
|
|
507
|
-
sendReasoning: (_a = this.settings.sendReasoning) != null ? _a : true,
|
|
508
|
-
warnings
|
|
509
|
-
});
|
|
510
|
-
const anthropicOptions = parseProviderOptions({
|
|
536
|
+
const anthropicOptions = await parseProviderOptions2({
|
|
511
537
|
provider: "anthropic",
|
|
512
538
|
providerOptions,
|
|
513
|
-
schema:
|
|
539
|
+
schema: anthropicProviderOptions
|
|
540
|
+
});
|
|
541
|
+
const { prompt: messagesPrompt, betas: messagesBetas } = await convertToAnthropicMessagesPrompt({
|
|
542
|
+
prompt,
|
|
543
|
+
sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
|
|
544
|
+
warnings
|
|
514
545
|
});
|
|
515
546
|
const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
|
|
516
547
|
const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
|
|
@@ -625,21 +656,24 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
625
656
|
case "thinking": {
|
|
626
657
|
content.push({
|
|
627
658
|
type: "reasoning",
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
signature: part.signature
|
|
659
|
+
text: part.thinking,
|
|
660
|
+
providerMetadata: {
|
|
661
|
+
anthropic: {
|
|
662
|
+
signature: part.signature
|
|
663
|
+
}
|
|
664
|
+
}
|
|
635
665
|
});
|
|
636
666
|
break;
|
|
637
667
|
}
|
|
638
668
|
case "redacted_thinking": {
|
|
639
669
|
content.push({
|
|
640
670
|
type: "reasoning",
|
|
641
|
-
|
|
642
|
-
|
|
671
|
+
text: "",
|
|
672
|
+
providerMetadata: {
|
|
673
|
+
anthropic: {
|
|
674
|
+
redactedData: part.data
|
|
675
|
+
}
|
|
676
|
+
}
|
|
643
677
|
});
|
|
644
678
|
break;
|
|
645
679
|
}
|
|
@@ -728,9 +762,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
728
762
|
case "redacted_thinking": {
|
|
729
763
|
controller.enqueue({
|
|
730
764
|
type: "reasoning",
|
|
731
|
-
|
|
732
|
-
|
|
765
|
+
text: "",
|
|
766
|
+
providerMetadata: {
|
|
767
|
+
anthropic: {
|
|
768
|
+
redactedData: value.content_block.data
|
|
769
|
+
}
|
|
770
|
+
}
|
|
733
771
|
});
|
|
772
|
+
controller.enqueue({ type: "reasoning-part-finish" });
|
|
734
773
|
return;
|
|
735
774
|
}
|
|
736
775
|
case "tool_use": {
|
|
@@ -777,7 +816,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
777
816
|
case "thinking_delta": {
|
|
778
817
|
controller.enqueue({
|
|
779
818
|
type: "reasoning",
|
|
780
|
-
reasoningType: "text",
|
|
781
819
|
text: value.delta.thinking
|
|
782
820
|
});
|
|
783
821
|
return;
|
|
@@ -786,9 +824,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
786
824
|
if (blockType === "thinking") {
|
|
787
825
|
controller.enqueue({
|
|
788
826
|
type: "reasoning",
|
|
789
|
-
|
|
790
|
-
|
|
827
|
+
text: "",
|
|
828
|
+
providerMetadata: {
|
|
829
|
+
anthropic: {
|
|
830
|
+
signature: value.delta.signature
|
|
831
|
+
}
|
|
832
|
+
}
|
|
791
833
|
});
|
|
834
|
+
controller.enqueue({ type: "reasoning-part-finish" });
|
|
792
835
|
}
|
|
793
836
|
return;
|
|
794
837
|
}
|
|
@@ -859,135 +902,133 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
859
902
|
};
|
|
860
903
|
}
|
|
861
904
|
};
|
|
862
|
-
var anthropicMessagesResponseSchema =
|
|
863
|
-
type:
|
|
864
|
-
id:
|
|
865
|
-
model:
|
|
866
|
-
content:
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
type:
|
|
870
|
-
text:
|
|
905
|
+
var anthropicMessagesResponseSchema = z3.object({
|
|
906
|
+
type: z3.literal("message"),
|
|
907
|
+
id: z3.string().nullish(),
|
|
908
|
+
model: z3.string().nullish(),
|
|
909
|
+
content: z3.array(
|
|
910
|
+
z3.discriminatedUnion("type", [
|
|
911
|
+
z3.object({
|
|
912
|
+
type: z3.literal("text"),
|
|
913
|
+
text: z3.string()
|
|
871
914
|
}),
|
|
872
|
-
|
|
873
|
-
type:
|
|
874
|
-
thinking:
|
|
875
|
-
signature:
|
|
915
|
+
z3.object({
|
|
916
|
+
type: z3.literal("thinking"),
|
|
917
|
+
thinking: z3.string(),
|
|
918
|
+
signature: z3.string()
|
|
876
919
|
}),
|
|
877
|
-
|
|
878
|
-
type:
|
|
879
|
-
data:
|
|
920
|
+
z3.object({
|
|
921
|
+
type: z3.literal("redacted_thinking"),
|
|
922
|
+
data: z3.string()
|
|
880
923
|
}),
|
|
881
|
-
|
|
882
|
-
type:
|
|
883
|
-
id:
|
|
884
|
-
name:
|
|
885
|
-
input:
|
|
924
|
+
z3.object({
|
|
925
|
+
type: z3.literal("tool_use"),
|
|
926
|
+
id: z3.string(),
|
|
927
|
+
name: z3.string(),
|
|
928
|
+
input: z3.unknown()
|
|
886
929
|
})
|
|
887
930
|
])
|
|
888
931
|
),
|
|
889
|
-
stop_reason:
|
|
890
|
-
usage:
|
|
891
|
-
input_tokens:
|
|
892
|
-
output_tokens:
|
|
893
|
-
cache_creation_input_tokens:
|
|
894
|
-
cache_read_input_tokens:
|
|
932
|
+
stop_reason: z3.string().nullish(),
|
|
933
|
+
usage: z3.object({
|
|
934
|
+
input_tokens: z3.number(),
|
|
935
|
+
output_tokens: z3.number(),
|
|
936
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
937
|
+
cache_read_input_tokens: z3.number().nullish()
|
|
895
938
|
})
|
|
896
939
|
});
|
|
897
|
-
var anthropicMessagesChunkSchema =
|
|
898
|
-
|
|
899
|
-
type:
|
|
900
|
-
message:
|
|
901
|
-
id:
|
|
902
|
-
model:
|
|
903
|
-
usage:
|
|
904
|
-
input_tokens:
|
|
905
|
-
output_tokens:
|
|
906
|
-
cache_creation_input_tokens:
|
|
907
|
-
cache_read_input_tokens:
|
|
940
|
+
var anthropicMessagesChunkSchema = z3.discriminatedUnion("type", [
|
|
941
|
+
z3.object({
|
|
942
|
+
type: z3.literal("message_start"),
|
|
943
|
+
message: z3.object({
|
|
944
|
+
id: z3.string().nullish(),
|
|
945
|
+
model: z3.string().nullish(),
|
|
946
|
+
usage: z3.object({
|
|
947
|
+
input_tokens: z3.number(),
|
|
948
|
+
output_tokens: z3.number(),
|
|
949
|
+
cache_creation_input_tokens: z3.number().nullish(),
|
|
950
|
+
cache_read_input_tokens: z3.number().nullish()
|
|
908
951
|
})
|
|
909
952
|
})
|
|
910
953
|
}),
|
|
911
|
-
|
|
912
|
-
type:
|
|
913
|
-
index:
|
|
914
|
-
content_block:
|
|
915
|
-
|
|
916
|
-
type:
|
|
917
|
-
text:
|
|
954
|
+
z3.object({
|
|
955
|
+
type: z3.literal("content_block_start"),
|
|
956
|
+
index: z3.number(),
|
|
957
|
+
content_block: z3.discriminatedUnion("type", [
|
|
958
|
+
z3.object({
|
|
959
|
+
type: z3.literal("text"),
|
|
960
|
+
text: z3.string()
|
|
918
961
|
}),
|
|
919
|
-
|
|
920
|
-
type:
|
|
921
|
-
thinking:
|
|
962
|
+
z3.object({
|
|
963
|
+
type: z3.literal("thinking"),
|
|
964
|
+
thinking: z3.string()
|
|
922
965
|
}),
|
|
923
|
-
|
|
924
|
-
type:
|
|
925
|
-
id:
|
|
926
|
-
name:
|
|
966
|
+
z3.object({
|
|
967
|
+
type: z3.literal("tool_use"),
|
|
968
|
+
id: z3.string(),
|
|
969
|
+
name: z3.string()
|
|
927
970
|
}),
|
|
928
|
-
|
|
929
|
-
type:
|
|
930
|
-
data:
|
|
971
|
+
z3.object({
|
|
972
|
+
type: z3.literal("redacted_thinking"),
|
|
973
|
+
data: z3.string()
|
|
931
974
|
})
|
|
932
975
|
])
|
|
933
976
|
}),
|
|
934
|
-
|
|
935
|
-
type:
|
|
936
|
-
index:
|
|
937
|
-
delta:
|
|
938
|
-
|
|
939
|
-
type:
|
|
940
|
-
partial_json:
|
|
977
|
+
z3.object({
|
|
978
|
+
type: z3.literal("content_block_delta"),
|
|
979
|
+
index: z3.number(),
|
|
980
|
+
delta: z3.discriminatedUnion("type", [
|
|
981
|
+
z3.object({
|
|
982
|
+
type: z3.literal("input_json_delta"),
|
|
983
|
+
partial_json: z3.string()
|
|
941
984
|
}),
|
|
942
|
-
|
|
943
|
-
type:
|
|
944
|
-
text:
|
|
985
|
+
z3.object({
|
|
986
|
+
type: z3.literal("text_delta"),
|
|
987
|
+
text: z3.string()
|
|
945
988
|
}),
|
|
946
|
-
|
|
947
|
-
type:
|
|
948
|
-
thinking:
|
|
989
|
+
z3.object({
|
|
990
|
+
type: z3.literal("thinking_delta"),
|
|
991
|
+
thinking: z3.string()
|
|
949
992
|
}),
|
|
950
|
-
|
|
951
|
-
type:
|
|
952
|
-
signature:
|
|
993
|
+
z3.object({
|
|
994
|
+
type: z3.literal("signature_delta"),
|
|
995
|
+
signature: z3.string()
|
|
953
996
|
})
|
|
954
997
|
])
|
|
955
998
|
}),
|
|
956
|
-
|
|
957
|
-
type:
|
|
958
|
-
index:
|
|
999
|
+
z3.object({
|
|
1000
|
+
type: z3.literal("content_block_stop"),
|
|
1001
|
+
index: z3.number()
|
|
959
1002
|
}),
|
|
960
|
-
|
|
961
|
-
type:
|
|
962
|
-
error:
|
|
963
|
-
type:
|
|
964
|
-
message:
|
|
1003
|
+
z3.object({
|
|
1004
|
+
type: z3.literal("error"),
|
|
1005
|
+
error: z3.object({
|
|
1006
|
+
type: z3.string(),
|
|
1007
|
+
message: z3.string()
|
|
965
1008
|
})
|
|
966
1009
|
}),
|
|
967
|
-
|
|
968
|
-
type:
|
|
969
|
-
delta:
|
|
970
|
-
usage:
|
|
1010
|
+
z3.object({
|
|
1011
|
+
type: z3.literal("message_delta"),
|
|
1012
|
+
delta: z3.object({ stop_reason: z3.string().nullish() }),
|
|
1013
|
+
usage: z3.object({ output_tokens: z3.number() })
|
|
971
1014
|
}),
|
|
972
|
-
|
|
973
|
-
type:
|
|
1015
|
+
z3.object({
|
|
1016
|
+
type: z3.literal("message_stop")
|
|
974
1017
|
}),
|
|
975
|
-
|
|
976
|
-
type:
|
|
1018
|
+
z3.object({
|
|
1019
|
+
type: z3.literal("ping")
|
|
977
1020
|
})
|
|
978
1021
|
]);
|
|
979
|
-
var
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
budgetTokens: z2.number().optional()
|
|
983
|
-
}).optional()
|
|
1022
|
+
var anthropicReasoningMetadataSchema = z3.object({
|
|
1023
|
+
signature: z3.string().optional(),
|
|
1024
|
+
redactedData: z3.string().optional()
|
|
984
1025
|
});
|
|
985
1026
|
|
|
986
1027
|
// src/anthropic-tools.ts
|
|
987
|
-
import { z as
|
|
988
|
-
var Bash20241022Parameters =
|
|
989
|
-
command:
|
|
990
|
-
restart:
|
|
1028
|
+
import { z as z4 } from "zod";
|
|
1029
|
+
var Bash20241022Parameters = z4.object({
|
|
1030
|
+
command: z4.string(),
|
|
1031
|
+
restart: z4.boolean().optional()
|
|
991
1032
|
});
|
|
992
1033
|
function bashTool_20241022(options = {}) {
|
|
993
1034
|
return {
|
|
@@ -999,9 +1040,9 @@ function bashTool_20241022(options = {}) {
|
|
|
999
1040
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1000
1041
|
};
|
|
1001
1042
|
}
|
|
1002
|
-
var Bash20250124Parameters =
|
|
1003
|
-
command:
|
|
1004
|
-
restart:
|
|
1043
|
+
var Bash20250124Parameters = z4.object({
|
|
1044
|
+
command: z4.string(),
|
|
1045
|
+
restart: z4.boolean().optional()
|
|
1005
1046
|
});
|
|
1006
1047
|
function bashTool_20250124(options = {}) {
|
|
1007
1048
|
return {
|
|
@@ -1013,14 +1054,14 @@ function bashTool_20250124(options = {}) {
|
|
|
1013
1054
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1014
1055
|
};
|
|
1015
1056
|
}
|
|
1016
|
-
var TextEditor20241022Parameters =
|
|
1017
|
-
command:
|
|
1018
|
-
path:
|
|
1019
|
-
file_text:
|
|
1020
|
-
insert_line:
|
|
1021
|
-
new_str:
|
|
1022
|
-
old_str:
|
|
1023
|
-
view_range:
|
|
1057
|
+
var TextEditor20241022Parameters = z4.object({
|
|
1058
|
+
command: z4.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1059
|
+
path: z4.string(),
|
|
1060
|
+
file_text: z4.string().optional(),
|
|
1061
|
+
insert_line: z4.number().int().optional(),
|
|
1062
|
+
new_str: z4.string().optional(),
|
|
1063
|
+
old_str: z4.string().optional(),
|
|
1064
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
1024
1065
|
});
|
|
1025
1066
|
function textEditorTool_20241022(options = {}) {
|
|
1026
1067
|
return {
|
|
@@ -1032,14 +1073,14 @@ function textEditorTool_20241022(options = {}) {
|
|
|
1032
1073
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1033
1074
|
};
|
|
1034
1075
|
}
|
|
1035
|
-
var TextEditor20250124Parameters =
|
|
1036
|
-
command:
|
|
1037
|
-
path:
|
|
1038
|
-
file_text:
|
|
1039
|
-
insert_line:
|
|
1040
|
-
new_str:
|
|
1041
|
-
old_str:
|
|
1042
|
-
view_range:
|
|
1076
|
+
var TextEditor20250124Parameters = z4.object({
|
|
1077
|
+
command: z4.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
|
|
1078
|
+
path: z4.string(),
|
|
1079
|
+
file_text: z4.string().optional(),
|
|
1080
|
+
insert_line: z4.number().int().optional(),
|
|
1081
|
+
new_str: z4.string().optional(),
|
|
1082
|
+
old_str: z4.string().optional(),
|
|
1083
|
+
view_range: z4.array(z4.number().int()).optional()
|
|
1043
1084
|
});
|
|
1044
1085
|
function textEditorTool_20250124(options = {}) {
|
|
1045
1086
|
return {
|
|
@@ -1051,8 +1092,8 @@ function textEditorTool_20250124(options = {}) {
|
|
|
1051
1092
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1052
1093
|
};
|
|
1053
1094
|
}
|
|
1054
|
-
var Computer20241022Parameters =
|
|
1055
|
-
action:
|
|
1095
|
+
var Computer20241022Parameters = z4.object({
|
|
1096
|
+
action: z4.enum([
|
|
1056
1097
|
"key",
|
|
1057
1098
|
"type",
|
|
1058
1099
|
"mouse_move",
|
|
@@ -1064,8 +1105,8 @@ var Computer20241022Parameters = z3.object({
|
|
|
1064
1105
|
"screenshot",
|
|
1065
1106
|
"cursor_position"
|
|
1066
1107
|
]),
|
|
1067
|
-
coordinate:
|
|
1068
|
-
text:
|
|
1108
|
+
coordinate: z4.array(z4.number().int()).optional(),
|
|
1109
|
+
text: z4.string().optional()
|
|
1069
1110
|
});
|
|
1070
1111
|
function computerTool_20241022(options) {
|
|
1071
1112
|
return {
|
|
@@ -1081,8 +1122,8 @@ function computerTool_20241022(options) {
|
|
|
1081
1122
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1082
1123
|
};
|
|
1083
1124
|
}
|
|
1084
|
-
var Computer20250124Parameters =
|
|
1085
|
-
action:
|
|
1125
|
+
var Computer20250124Parameters = z4.object({
|
|
1126
|
+
action: z4.enum([
|
|
1086
1127
|
"key",
|
|
1087
1128
|
"hold_key",
|
|
1088
1129
|
"type",
|
|
@@ -1100,12 +1141,12 @@ var Computer20250124Parameters = z3.object({
|
|
|
1100
1141
|
"wait",
|
|
1101
1142
|
"screenshot"
|
|
1102
1143
|
]),
|
|
1103
|
-
coordinate:
|
|
1104
|
-
duration:
|
|
1105
|
-
scroll_amount:
|
|
1106
|
-
scroll_direction:
|
|
1107
|
-
start_coordinate:
|
|
1108
|
-
text:
|
|
1144
|
+
coordinate: z4.tuple([z4.number().int(), z4.number().int()]).optional(),
|
|
1145
|
+
duration: z4.number().optional(),
|
|
1146
|
+
scroll_amount: z4.number().optional(),
|
|
1147
|
+
scroll_direction: z4.enum(["up", "down", "left", "right"]).optional(),
|
|
1148
|
+
start_coordinate: z4.tuple([z4.number().int(), z4.number().int()]).optional(),
|
|
1149
|
+
text: z4.string().optional()
|
|
1109
1150
|
});
|
|
1110
1151
|
function computerTool_20250124(options) {
|
|
1111
1152
|
return {
|
|
@@ -1143,7 +1184,7 @@ function createAnthropic(options = {}) {
|
|
|
1143
1184
|
}),
|
|
1144
1185
|
...options.headers
|
|
1145
1186
|
});
|
|
1146
|
-
const createChatModel = (modelId
|
|
1187
|
+
const createChatModel = (modelId) => new AnthropicMessagesLanguageModel(modelId, {
|
|
1147
1188
|
provider: "anthropic.messages",
|
|
1148
1189
|
baseURL,
|
|
1149
1190
|
headers: getHeaders,
|
|
@@ -1152,13 +1193,13 @@ function createAnthropic(options = {}) {
|
|
|
1152
1193
|
"image/*": [/^https?:\/\/.*$/]
|
|
1153
1194
|
})
|
|
1154
1195
|
});
|
|
1155
|
-
const provider = function(modelId
|
|
1196
|
+
const provider = function(modelId) {
|
|
1156
1197
|
if (new.target) {
|
|
1157
1198
|
throw new Error(
|
|
1158
1199
|
"The Anthropic model function cannot be called with the new keyword."
|
|
1159
1200
|
);
|
|
1160
1201
|
}
|
|
1161
|
-
return createChatModel(modelId
|
|
1202
|
+
return createChatModel(modelId);
|
|
1162
1203
|
};
|
|
1163
1204
|
provider.languageModel = createChatModel;
|
|
1164
1205
|
provider.chat = createChatModel;
|