@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.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({
|
|
@@ -176,7 +191,7 @@ function prepareTools({
|
|
|
176
191
|
// src/convert-to-anthropic-messages-prompt.ts
|
|
177
192
|
var import_provider2 = require("@ai-sdk/provider");
|
|
178
193
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
179
|
-
function convertToAnthropicMessagesPrompt({
|
|
194
|
+
async function convertToAnthropicMessagesPrompt({
|
|
180
195
|
prompt,
|
|
181
196
|
sendReasoning,
|
|
182
197
|
warnings
|
|
@@ -339,12 +354,37 @@ function convertToAnthropicMessagesPrompt({
|
|
|
339
354
|
}
|
|
340
355
|
case "reasoning": {
|
|
341
356
|
if (sendReasoning) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
cache_control: cacheControl
|
|
357
|
+
const reasoningMetadata = await (0, import_provider_utils2.parseProviderOptions)({
|
|
358
|
+
provider: "anthropic",
|
|
359
|
+
providerOptions: part.providerOptions,
|
|
360
|
+
schema: anthropicReasoningMetadataSchema
|
|
347
361
|
});
|
|
362
|
+
if (reasoningMetadata != null) {
|
|
363
|
+
if (reasoningMetadata.signature != null) {
|
|
364
|
+
anthropicContent.push({
|
|
365
|
+
type: "thinking",
|
|
366
|
+
thinking: part.text,
|
|
367
|
+
signature: reasoningMetadata.signature,
|
|
368
|
+
cache_control: cacheControl
|
|
369
|
+
});
|
|
370
|
+
} else if (reasoningMetadata.redactedData != null) {
|
|
371
|
+
anthropicContent.push({
|
|
372
|
+
type: "redacted_thinking",
|
|
373
|
+
data: reasoningMetadata.redactedData,
|
|
374
|
+
cache_control: cacheControl
|
|
375
|
+
});
|
|
376
|
+
} else {
|
|
377
|
+
warnings.push({
|
|
378
|
+
type: "other",
|
|
379
|
+
message: "unsupported reasoning metadata"
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
} else {
|
|
383
|
+
warnings.push({
|
|
384
|
+
type: "other",
|
|
385
|
+
message: "unsupported reasoning metadata"
|
|
386
|
+
});
|
|
387
|
+
}
|
|
348
388
|
} else {
|
|
349
389
|
warnings.push({
|
|
350
390
|
type: "other",
|
|
@@ -353,14 +393,6 @@ function convertToAnthropicMessagesPrompt({
|
|
|
353
393
|
}
|
|
354
394
|
break;
|
|
355
395
|
}
|
|
356
|
-
case "redacted-reasoning": {
|
|
357
|
-
anthropicContent.push({
|
|
358
|
-
type: "redacted_thinking",
|
|
359
|
-
data: part.data,
|
|
360
|
-
cache_control: cacheControl
|
|
361
|
-
});
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
396
|
case "tool-call": {
|
|
365
397
|
anthropicContent.push({
|
|
366
398
|
type: "tool_use",
|
|
@@ -452,10 +484,9 @@ function mapAnthropicStopReason(finishReason) {
|
|
|
452
484
|
|
|
453
485
|
// src/anthropic-messages-language-model.ts
|
|
454
486
|
var AnthropicMessagesLanguageModel = class {
|
|
455
|
-
constructor(modelId,
|
|
487
|
+
constructor(modelId, config) {
|
|
456
488
|
this.specificationVersion = "v2";
|
|
457
489
|
this.modelId = modelId;
|
|
458
|
-
this.settings = settings;
|
|
459
490
|
this.config = config;
|
|
460
491
|
}
|
|
461
492
|
supportsUrl(url) {
|
|
@@ -511,15 +542,15 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
511
542
|
details: "JSON response format is not supported."
|
|
512
543
|
});
|
|
513
544
|
}
|
|
514
|
-
const
|
|
515
|
-
prompt,
|
|
516
|
-
sendReasoning: (_a = this.settings.sendReasoning) != null ? _a : true,
|
|
517
|
-
warnings
|
|
518
|
-
});
|
|
519
|
-
const anthropicOptions = (0, import_provider_utils3.parseProviderOptions)({
|
|
545
|
+
const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
|
|
520
546
|
provider: "anthropic",
|
|
521
547
|
providerOptions,
|
|
522
|
-
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
|
|
523
554
|
});
|
|
524
555
|
const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
|
|
525
556
|
const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
|
|
@@ -634,21 +665,24 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
634
665
|
case "thinking": {
|
|
635
666
|
content.push({
|
|
636
667
|
type: "reasoning",
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
signature: part.signature
|
|
668
|
+
text: part.thinking,
|
|
669
|
+
providerMetadata: {
|
|
670
|
+
anthropic: {
|
|
671
|
+
signature: part.signature
|
|
672
|
+
}
|
|
673
|
+
}
|
|
644
674
|
});
|
|
645
675
|
break;
|
|
646
676
|
}
|
|
647
677
|
case "redacted_thinking": {
|
|
648
678
|
content.push({
|
|
649
679
|
type: "reasoning",
|
|
650
|
-
|
|
651
|
-
|
|
680
|
+
text: "",
|
|
681
|
+
providerMetadata: {
|
|
682
|
+
anthropic: {
|
|
683
|
+
redactedData: part.data
|
|
684
|
+
}
|
|
685
|
+
}
|
|
652
686
|
});
|
|
653
687
|
break;
|
|
654
688
|
}
|
|
@@ -737,9 +771,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
737
771
|
case "redacted_thinking": {
|
|
738
772
|
controller.enqueue({
|
|
739
773
|
type: "reasoning",
|
|
740
|
-
|
|
741
|
-
|
|
774
|
+
text: "",
|
|
775
|
+
providerMetadata: {
|
|
776
|
+
anthropic: {
|
|
777
|
+
redactedData: value.content_block.data
|
|
778
|
+
}
|
|
779
|
+
}
|
|
742
780
|
});
|
|
781
|
+
controller.enqueue({ type: "reasoning-part-finish" });
|
|
743
782
|
return;
|
|
744
783
|
}
|
|
745
784
|
case "tool_use": {
|
|
@@ -786,7 +825,6 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
786
825
|
case "thinking_delta": {
|
|
787
826
|
controller.enqueue({
|
|
788
827
|
type: "reasoning",
|
|
789
|
-
reasoningType: "text",
|
|
790
828
|
text: value.delta.thinking
|
|
791
829
|
});
|
|
792
830
|
return;
|
|
@@ -795,9 +833,14 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
795
833
|
if (blockType === "thinking") {
|
|
796
834
|
controller.enqueue({
|
|
797
835
|
type: "reasoning",
|
|
798
|
-
|
|
799
|
-
|
|
836
|
+
text: "",
|
|
837
|
+
providerMetadata: {
|
|
838
|
+
anthropic: {
|
|
839
|
+
signature: value.delta.signature
|
|
840
|
+
}
|
|
841
|
+
}
|
|
800
842
|
});
|
|
843
|
+
controller.enqueue({ type: "reasoning-part-finish" });
|
|
801
844
|
}
|
|
802
845
|
return;
|
|
803
846
|
}
|
|
@@ -868,135 +911,133 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
868
911
|
};
|
|
869
912
|
}
|
|
870
913
|
};
|
|
871
|
-
var anthropicMessagesResponseSchema =
|
|
872
|
-
type:
|
|
873
|
-
id:
|
|
874
|
-
model:
|
|
875
|
-
content:
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
type:
|
|
879
|
-
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()
|
|
880
923
|
}),
|
|
881
|
-
|
|
882
|
-
type:
|
|
883
|
-
thinking:
|
|
884
|
-
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()
|
|
885
928
|
}),
|
|
886
|
-
|
|
887
|
-
type:
|
|
888
|
-
data:
|
|
929
|
+
import_zod3.z.object({
|
|
930
|
+
type: import_zod3.z.literal("redacted_thinking"),
|
|
931
|
+
data: import_zod3.z.string()
|
|
889
932
|
}),
|
|
890
|
-
|
|
891
|
-
type:
|
|
892
|
-
id:
|
|
893
|
-
name:
|
|
894
|
-
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()
|
|
895
938
|
})
|
|
896
939
|
])
|
|
897
940
|
),
|
|
898
|
-
stop_reason:
|
|
899
|
-
usage:
|
|
900
|
-
input_tokens:
|
|
901
|
-
output_tokens:
|
|
902
|
-
cache_creation_input_tokens:
|
|
903
|
-
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()
|
|
904
947
|
})
|
|
905
948
|
});
|
|
906
|
-
var anthropicMessagesChunkSchema =
|
|
907
|
-
|
|
908
|
-
type:
|
|
909
|
-
message:
|
|
910
|
-
id:
|
|
911
|
-
model:
|
|
912
|
-
usage:
|
|
913
|
-
input_tokens:
|
|
914
|
-
output_tokens:
|
|
915
|
-
cache_creation_input_tokens:
|
|
916
|
-
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()
|
|
917
960
|
})
|
|
918
961
|
})
|
|
919
962
|
}),
|
|
920
|
-
|
|
921
|
-
type:
|
|
922
|
-
index:
|
|
923
|
-
content_block:
|
|
924
|
-
|
|
925
|
-
type:
|
|
926
|
-
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()
|
|
927
970
|
}),
|
|
928
|
-
|
|
929
|
-
type:
|
|
930
|
-
thinking:
|
|
971
|
+
import_zod3.z.object({
|
|
972
|
+
type: import_zod3.z.literal("thinking"),
|
|
973
|
+
thinking: import_zod3.z.string()
|
|
931
974
|
}),
|
|
932
|
-
|
|
933
|
-
type:
|
|
934
|
-
id:
|
|
935
|
-
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()
|
|
936
979
|
}),
|
|
937
|
-
|
|
938
|
-
type:
|
|
939
|
-
data:
|
|
980
|
+
import_zod3.z.object({
|
|
981
|
+
type: import_zod3.z.literal("redacted_thinking"),
|
|
982
|
+
data: import_zod3.z.string()
|
|
940
983
|
})
|
|
941
984
|
])
|
|
942
985
|
}),
|
|
943
|
-
|
|
944
|
-
type:
|
|
945
|
-
index:
|
|
946
|
-
delta:
|
|
947
|
-
|
|
948
|
-
type:
|
|
949
|
-
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()
|
|
950
993
|
}),
|
|
951
|
-
|
|
952
|
-
type:
|
|
953
|
-
text:
|
|
994
|
+
import_zod3.z.object({
|
|
995
|
+
type: import_zod3.z.literal("text_delta"),
|
|
996
|
+
text: import_zod3.z.string()
|
|
954
997
|
}),
|
|
955
|
-
|
|
956
|
-
type:
|
|
957
|
-
thinking:
|
|
998
|
+
import_zod3.z.object({
|
|
999
|
+
type: import_zod3.z.literal("thinking_delta"),
|
|
1000
|
+
thinking: import_zod3.z.string()
|
|
958
1001
|
}),
|
|
959
|
-
|
|
960
|
-
type:
|
|
961
|
-
signature:
|
|
1002
|
+
import_zod3.z.object({
|
|
1003
|
+
type: import_zod3.z.literal("signature_delta"),
|
|
1004
|
+
signature: import_zod3.z.string()
|
|
962
1005
|
})
|
|
963
1006
|
])
|
|
964
1007
|
}),
|
|
965
|
-
|
|
966
|
-
type:
|
|
967
|
-
index:
|
|
1008
|
+
import_zod3.z.object({
|
|
1009
|
+
type: import_zod3.z.literal("content_block_stop"),
|
|
1010
|
+
index: import_zod3.z.number()
|
|
968
1011
|
}),
|
|
969
|
-
|
|
970
|
-
type:
|
|
971
|
-
error:
|
|
972
|
-
type:
|
|
973
|
-
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()
|
|
974
1017
|
})
|
|
975
1018
|
}),
|
|
976
|
-
|
|
977
|
-
type:
|
|
978
|
-
delta:
|
|
979
|
-
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() })
|
|
980
1023
|
}),
|
|
981
|
-
|
|
982
|
-
type:
|
|
1024
|
+
import_zod3.z.object({
|
|
1025
|
+
type: import_zod3.z.literal("message_stop")
|
|
983
1026
|
}),
|
|
984
|
-
|
|
985
|
-
type:
|
|
1027
|
+
import_zod3.z.object({
|
|
1028
|
+
type: import_zod3.z.literal("ping")
|
|
986
1029
|
})
|
|
987
1030
|
]);
|
|
988
|
-
var
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
budgetTokens: import_zod2.z.number().optional()
|
|
992
|
-
}).optional()
|
|
1031
|
+
var anthropicReasoningMetadataSchema = import_zod3.z.object({
|
|
1032
|
+
signature: import_zod3.z.string().optional(),
|
|
1033
|
+
redactedData: import_zod3.z.string().optional()
|
|
993
1034
|
});
|
|
994
1035
|
|
|
995
1036
|
// src/anthropic-tools.ts
|
|
996
|
-
var
|
|
997
|
-
var Bash20241022Parameters =
|
|
998
|
-
command:
|
|
999
|
-
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()
|
|
1000
1041
|
});
|
|
1001
1042
|
function bashTool_20241022(options = {}) {
|
|
1002
1043
|
return {
|
|
@@ -1008,9 +1049,9 @@ function bashTool_20241022(options = {}) {
|
|
|
1008
1049
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1009
1050
|
};
|
|
1010
1051
|
}
|
|
1011
|
-
var Bash20250124Parameters =
|
|
1012
|
-
command:
|
|
1013
|
-
restart:
|
|
1052
|
+
var Bash20250124Parameters = import_zod4.z.object({
|
|
1053
|
+
command: import_zod4.z.string(),
|
|
1054
|
+
restart: import_zod4.z.boolean().optional()
|
|
1014
1055
|
});
|
|
1015
1056
|
function bashTool_20250124(options = {}) {
|
|
1016
1057
|
return {
|
|
@@ -1022,14 +1063,14 @@ function bashTool_20250124(options = {}) {
|
|
|
1022
1063
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1023
1064
|
};
|
|
1024
1065
|
}
|
|
1025
|
-
var TextEditor20241022Parameters =
|
|
1026
|
-
command:
|
|
1027
|
-
path:
|
|
1028
|
-
file_text:
|
|
1029
|
-
insert_line:
|
|
1030
|
-
new_str:
|
|
1031
|
-
old_str:
|
|
1032
|
-
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()
|
|
1033
1074
|
});
|
|
1034
1075
|
function textEditorTool_20241022(options = {}) {
|
|
1035
1076
|
return {
|
|
@@ -1041,14 +1082,14 @@ function textEditorTool_20241022(options = {}) {
|
|
|
1041
1082
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1042
1083
|
};
|
|
1043
1084
|
}
|
|
1044
|
-
var TextEditor20250124Parameters =
|
|
1045
|
-
command:
|
|
1046
|
-
path:
|
|
1047
|
-
file_text:
|
|
1048
|
-
insert_line:
|
|
1049
|
-
new_str:
|
|
1050
|
-
old_str:
|
|
1051
|
-
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()
|
|
1052
1093
|
});
|
|
1053
1094
|
function textEditorTool_20250124(options = {}) {
|
|
1054
1095
|
return {
|
|
@@ -1060,8 +1101,8 @@ function textEditorTool_20250124(options = {}) {
|
|
|
1060
1101
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1061
1102
|
};
|
|
1062
1103
|
}
|
|
1063
|
-
var Computer20241022Parameters =
|
|
1064
|
-
action:
|
|
1104
|
+
var Computer20241022Parameters = import_zod4.z.object({
|
|
1105
|
+
action: import_zod4.z.enum([
|
|
1065
1106
|
"key",
|
|
1066
1107
|
"type",
|
|
1067
1108
|
"mouse_move",
|
|
@@ -1073,8 +1114,8 @@ var Computer20241022Parameters = import_zod3.z.object({
|
|
|
1073
1114
|
"screenshot",
|
|
1074
1115
|
"cursor_position"
|
|
1075
1116
|
]),
|
|
1076
|
-
coordinate:
|
|
1077
|
-
text:
|
|
1117
|
+
coordinate: import_zod4.z.array(import_zod4.z.number().int()).optional(),
|
|
1118
|
+
text: import_zod4.z.string().optional()
|
|
1078
1119
|
});
|
|
1079
1120
|
function computerTool_20241022(options) {
|
|
1080
1121
|
return {
|
|
@@ -1090,8 +1131,8 @@ function computerTool_20241022(options) {
|
|
|
1090
1131
|
experimental_toToolResultContent: options.experimental_toToolResultContent
|
|
1091
1132
|
};
|
|
1092
1133
|
}
|
|
1093
|
-
var Computer20250124Parameters =
|
|
1094
|
-
action:
|
|
1134
|
+
var Computer20250124Parameters = import_zod4.z.object({
|
|
1135
|
+
action: import_zod4.z.enum([
|
|
1095
1136
|
"key",
|
|
1096
1137
|
"hold_key",
|
|
1097
1138
|
"type",
|
|
@@ -1109,12 +1150,12 @@ var Computer20250124Parameters = import_zod3.z.object({
|
|
|
1109
1150
|
"wait",
|
|
1110
1151
|
"screenshot"
|
|
1111
1152
|
]),
|
|
1112
|
-
coordinate:
|
|
1113
|
-
duration:
|
|
1114
|
-
scroll_amount:
|
|
1115
|
-
scroll_direction:
|
|
1116
|
-
start_coordinate:
|
|
1117
|
-
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()
|
|
1118
1159
|
});
|
|
1119
1160
|
function computerTool_20250124(options) {
|
|
1120
1161
|
return {
|
|
@@ -1152,7 +1193,7 @@ function createAnthropic(options = {}) {
|
|
|
1152
1193
|
}),
|
|
1153
1194
|
...options.headers
|
|
1154
1195
|
});
|
|
1155
|
-
const createChatModel = (modelId
|
|
1196
|
+
const createChatModel = (modelId) => new AnthropicMessagesLanguageModel(modelId, {
|
|
1156
1197
|
provider: "anthropic.messages",
|
|
1157
1198
|
baseURL,
|
|
1158
1199
|
headers: getHeaders,
|
|
@@ -1161,13 +1202,13 @@ function createAnthropic(options = {}) {
|
|
|
1161
1202
|
"image/*": [/^https?:\/\/.*$/]
|
|
1162
1203
|
})
|
|
1163
1204
|
});
|
|
1164
|
-
const provider = function(modelId
|
|
1205
|
+
const provider = function(modelId) {
|
|
1165
1206
|
if (new.target) {
|
|
1166
1207
|
throw new Error(
|
|
1167
1208
|
"The Anthropic model function cannot be called with the new keyword."
|
|
1168
1209
|
);
|
|
1169
1210
|
}
|
|
1170
|
-
return createChatModel(modelId
|
|
1211
|
+
return createChatModel(modelId);
|
|
1171
1212
|
};
|
|
1172
1213
|
provider.languageModel = createChatModel;
|
|
1173
1214
|
provider.chat = createChatModel;
|