@ai-sdk/anthropic 4.0.84 → 4.0.85
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.ts +138 -176
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -43
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +10 -10
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +38 -41
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +48 -4
- package/package.json +2 -2
- package/src/anthropic-api.ts +144 -130
- package/src/anthropic-batch.ts +8 -7
- package/src/anthropic-language-model-options.ts +417 -398
- package/src/convert-to-anthropic-prompt.ts +2 -2
- package/src/skills/anthropic-skills.ts +1 -11
package/dist/internal/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ interface AnthropicAssistantMessage {
|
|
|
53
53
|
role: 'assistant';
|
|
54
54
|
content: Array<AnthropicTextContent | AnthropicThinkingContent | AnthropicRedactedThinkingContent | AnthropicFallbackContent | AnthropicToolCallContent | AnthropicServerToolUseContent | AnthropicCodeExecutionToolResultContent | AnthropicWebFetchToolResultContent | AnthropicWebSearchToolResultContent | AnthropicToolSearchToolResultContent | AnthropicBashCodeExecutionToolResultContent | AnthropicTextEditorCodeExecutionToolResultContent | AnthropicAdvisorToolResultContent | AnthropicMcpToolUseContent | AnthropicMcpToolResultContent | AnthropicCompactionContent>;
|
|
55
55
|
}
|
|
56
|
-
declare const anthropicFallbackContentSchema: z.ZodObject<{
|
|
56
|
+
declare const anthropicFallbackContentSchema: () => z.ZodObject<{
|
|
57
57
|
type: z.ZodLiteral<"fallback">;
|
|
58
58
|
from: z.ZodObject<{
|
|
59
59
|
model: z.ZodString;
|
|
@@ -62,7 +62,7 @@ declare const anthropicFallbackContentSchema: z.ZodObject<{
|
|
|
62
62
|
model: z.ZodString;
|
|
63
63
|
}, z.core.$strip>;
|
|
64
64
|
}, z.core.$strip>;
|
|
65
|
-
type AnthropicFallbackContent = InferSchema<typeof anthropicFallbackContentSchema
|
|
65
|
+
type AnthropicFallbackContent = InferSchema<ReturnType<typeof anthropicFallbackContentSchema>> & {
|
|
66
66
|
cache_control?: never;
|
|
67
67
|
};
|
|
68
68
|
interface AnthropicCompactionContent {
|
|
@@ -494,6 +494,14 @@ type AnthropicToolChoice = {
|
|
|
494
494
|
declare const anthropicResponseSchema: import("@ai-sdk/provider-utils").LazySchema<{
|
|
495
495
|
type: "message";
|
|
496
496
|
content: ({
|
|
497
|
+
type: "fallback";
|
|
498
|
+
from: {
|
|
499
|
+
model: string;
|
|
500
|
+
};
|
|
501
|
+
to: {
|
|
502
|
+
model: string;
|
|
503
|
+
};
|
|
504
|
+
} | {
|
|
497
505
|
type: "text";
|
|
498
506
|
text: string;
|
|
499
507
|
citations?: ({
|
|
@@ -744,14 +752,6 @@ declare const anthropicResponseSchema: import("@ai-sdk/provider-utils").LazySche
|
|
|
744
752
|
type: "advisor_tool_result_error";
|
|
745
753
|
error_code: string;
|
|
746
754
|
};
|
|
747
|
-
} | {
|
|
748
|
-
type: "fallback";
|
|
749
|
-
from: {
|
|
750
|
-
model: string;
|
|
751
|
-
};
|
|
752
|
-
to: {
|
|
753
|
-
model: string;
|
|
754
|
-
};
|
|
755
755
|
})[];
|
|
756
756
|
usage: {
|
|
757
757
|
[x: string]: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__anthropic_api0.AnthropicToolChoice","_$__anthropic_api0.AnthropicTextContent","_$__anthropic_api0.AnthropicMessage","SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member"],"sources":["../../src/anthropic-files.ts","../../src/anthropic-api.ts","../../src/anthropic-language-model-options.ts","../../src/get-cache-control.ts","../../src/convert-to-anthropic-prompt.ts","../../src/anthropic-language-model.ts","../../src/tool/computer-toolset_20260801.ts","../../src/tool/bash_20241022.ts","../../src/tool/bash_20250124.ts","../../src/anthropic-tools.ts","../../src/anthropic-prepare-tools.ts","../../src/sanitize-json-schema.ts","../../src/skills/anthropic-skills.ts"],"mappings":";;;;UA+BU;EACR;EACA;EACA,eAAe;EACf,QAAQ;;qBAGG,0BAA0B;mBAOR;WANpB;MAEL;EAIyB,YAAA,QAAQ;EAE/B,aACJ,MACA,WACA,UACA,aACA,WACC,+BAA+B,QAAQ;;;;KCxChC,mBACR,uBACA,4BACA;KAEQ;EACV;EACA;;UAGe;EACf;EACA,SAAS,MAAM,uBAAuB;EACtC;EACA;IACE;;;;;;;;;;UAWa;EACf;EACA;IAAQ;IAAwB;;EAChC;;UAGe;EACf;EACA,SAAS,MACL,uBACA,wBACA,wBACA,2BACA,kCACA;;UAIW;EACf;EACA,SAAS,MACL,uBACA,2BACA,mCACA,2BACA,2BACA,gCACA,0CACA,qCACA,sCACA,uCACA,8CACA,oDACA,oCACA,6BACA,gCACA;;cAIO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__anthropic_api0.AnthropicToolChoice","_$__anthropic_api0.AnthropicTextContent","_$__anthropic_api0.AnthropicMessage","SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member"],"sources":["../../src/anthropic-files.ts","../../src/anthropic-api.ts","../../src/anthropic-language-model-options.ts","../../src/get-cache-control.ts","../../src/convert-to-anthropic-prompt.ts","../../src/anthropic-language-model.ts","../../src/tool/computer-toolset_20260801.ts","../../src/tool/bash_20241022.ts","../../src/tool/bash_20250124.ts","../../src/anthropic-tools.ts","../../src/anthropic-prepare-tools.ts","../../src/sanitize-json-schema.ts","../../src/skills/anthropic-skills.ts"],"mappings":";;;;UA+BU;EACR;EACA;EACA,eAAe;EACf,QAAQ;;qBAGG,0BAA0B;mBAOR;WANpB;MAEL;EAIyB,YAAA,QAAQ;EAE/B,aACJ,MACA,WACA,UACA,aACA,WACC,+BAA+B,QAAQ;;;;KCxChC,mBACR,uBACA,4BACA;KAEQ;EACV;EACA;;UAGe;EACf;EACA,SAAS,MAAM,uBAAuB;EACtC;EACA;IACE;;;;;;;;;;UAWa;EACf;EACA;IAAQ;IAAwB;;EAChC;;UAGe;EACf;EACA,SAAS,MACL,uBACA,wBACA,wBACA,2BACA,kCACA;;UAIW;EACf;EACA,SAAS,MACL,uBACA,2BACA,mCACA,2BACA,2BACA,gCACA,0CACA,qCACA,sCACA,uCACA,8CACA,oDACA,oCACA,6BACA,gCACA;;cAIO,sCAA8B,EAAA;;;;;;;;GAKvC,EAAA,KAAA;KAKQ,2BAA2B,YACrC,kBAAkB;EAElB;;UAGe;EACf;EACA;EACA;EACA,gBAAgB;;UAGD;EACf;EACA;EACA,YAAY;EACZ,eAAe;;UAGA;EACf;EACA;EACA;EAGA;;UAGe;EACf;EACA;EAGA;;KAGG;EAEC;EACA;EACA;;EAGA;EACA;;EAGA;EACA;EACA;;EAGA;EACA;;UAGW;EACf;EACA,QAAQ;EACR,eAAe;;;UAIA;EACf;EACA,QAAQ;EACR,eAAe;;UAGA;EACf;EACA,QAAQ;EACR;EACA;EACA;IAAc;;EACd,eAAe;;UAGA;EACf;EACA;EACA;;;;;;KAOU;EAEN;EACA;;EAGA;EACA;;EAGA;;UAGW;EACf;EACA;EACA;EACA;;;;;EAKA,SAAS;;;;;EAKT;EACA,eAAe;;UAGA;EACf;EACA;EACA;EAaA;EACA,SAAS;EACT,eAAe;;KAKZ,6BAA6B,KAChC;EAGA;;KAGG,8BAA8B,KACjC;EAGA;;KAGG,iCAAiC,KACpC;EAGA;;UAGe;EACf;EACA;;UAGe;EACf;EACA;;;;EAIA;EACA,kBAEI,MACI,6BACA,8BACA,iCACA;EAER;EACA,eAAe;;UAGA;EACf;EACA;EACA,SACI;IACE;IACA;IACA;IACA;IACA;;IAGA;IACA;;EAEN,SAAS;EACT,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA,iBAAiB;MACf;MACA;;;IAIF;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;IACA,SAAS;MAAQ;MAA+B;;;IAGhD;IACA;IACA;IACA;IACA,SAAS;MAAQ;MAA+B;;;IAGhD;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;;IAGA;IACA;;IAGA;IACA;IACA;IACA;IACA;IACA;;IAGA;IACA;IACA;IACA;IACA;IACA;;EAEN,eAAe;;UAIA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;IACA;MACE;MACA;;;IAIF;IACA;;EAEN,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA;IACA;;IAGA;IACA;IACA;;IAGA;;;;;;IAMA;;EAEN,eAAe;;UAGA;EACf;EACA;EACA;IAEM;IACA;IACA;IACA;MACE;MACA;MACA;QAAc;;MACd;QACM;QAAgB;QAA+B;;QAC/C;QAAc;QAA0B;;;;IAIhD;IACA;;EAEN,SAAS;EACT,eAAe;;UAEA;EACf;EACA;EACA;EACA;EACA;EACA,eAAe;;UAGA;EACf;EACA;EACA;EACA,kBAEI;IACE;IACA;IACA,YAAY;;EAElB,eAAe;;KAGL;EAEN;EACA;EACA,cAAc;EACd,eAAe;EACf;EACA;;;;;EAKA;;;;;;;;EAQA,kBAAkB;;EAKlB;EACA;EACA,eAAe;;EAGf;EACA;;EAGA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA,eAAe;;EAGf;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;;;;;;EAOf;EACA,UAAU;IAAiB;IAAmB;;EAC9C,eAAe;;EAGf;EACA;EAIA,eAAe;;EAGf;EACA;EACA;EACA,eAAe;;EAGf;EACA;EACA,eAAe;;EAGf;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;IAAc;;EACd;EACA;EACA;EACA,eAAe;;EAGf;EAIA;EACA;EACA;EACA;EACA;IACE;IACA;IACA;IACA;IACA;;EAEF;EACA,eAAe;;EAGf;EACA;;EAGA;EACA;;EAGA;EACA;EACA;EACA;EACA;EACA;IACE;IACA;;;KAMI;EACN;EAAsB;;E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;;;;;;;;;;;;;;;;;;;;;;;;MAJlB;MACF;MACJ;MAEwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAHxB;MACA;MAEa;MACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBCnBC,eACpB,OACA,YACA,wBACA,uBACA,0BACA,qBACA,4BACA;EAEA,OAAO;EACP,YAAY;EACZ;EACA,wBAAwB;;;;EAKxB;;;;EAKA;;;;;EAMA;;;;;;EAOA;IACE;EACF,OAAO,MAAM;EACb,YAAY;EACZ,cAAc;EACd,OAAO;;;;;;;;;;;wBC3BO,mBAAmB,QAAQ,cAAc;;;UCtB/C;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,2BAA2B;mBAOT;WANpB;MAEL;EAIyB,YAAA,QAAQ;UAEvB;UAMA;EA4BR,YACJ,QAAQ,WAAW,8BAClB,QAAQ,QAAQ,WAAW"}
|
package/dist/internal/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, mapReasoningToProviderBudget, mapReasoningToProviderEffort, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, validateTypes, zodSchema } from "@ai-sdk/provider-utils";
|
|
1
|
+
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, mapReasoningToProviderBudget, mapReasoningToProviderEffort, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, validateTypes, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
import { APICallError, InvalidArgumentError, InvalidResponseDataError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
4
4
|
//#region src/anthropic-error.ts
|
|
@@ -95,18 +95,19 @@ function mapAnthropicCitation(citation, documents) {
|
|
|
95
95
|
}
|
|
96
96
|
//#endregion
|
|
97
97
|
//#region src/anthropic-api.ts
|
|
98
|
-
const anthropicFallbackContentSchema = z.object({
|
|
98
|
+
const anthropicFallbackContentSchema = () => z.object({
|
|
99
99
|
type: z.literal("fallback"),
|
|
100
100
|
from: z.object({ model: z.string() }),
|
|
101
101
|
to: z.object({ model: z.string() })
|
|
102
102
|
});
|
|
103
|
-
const
|
|
103
|
+
const anthropicFallbackContentSchemaValidator = lazySchema(() => zodSchema(anthropicFallbackContentSchema()));
|
|
104
|
+
const anthropicStopDetailsSchema = () => z.object({
|
|
104
105
|
type: z.string(),
|
|
105
106
|
category: z.string().nullish(),
|
|
106
107
|
explanation: z.string().nullish(),
|
|
107
108
|
recommended_model: z.string().nullish()
|
|
108
109
|
});
|
|
109
|
-
const anthropicSafeguardResultSchema = z.object({
|
|
110
|
+
const anthropicSafeguardResultSchema = () => z.object({
|
|
110
111
|
type: z.string(),
|
|
111
112
|
status: z.object({
|
|
112
113
|
type: z.string(),
|
|
@@ -117,7 +118,7 @@ const anthropicSafeguardResultSchema = z.object({
|
|
|
117
118
|
})).nullish()
|
|
118
119
|
})
|
|
119
120
|
});
|
|
120
|
-
const anthropicToolCallCallerSchema = z.union([
|
|
121
|
+
const anthropicToolCallCallerSchema = () => z.union([
|
|
121
122
|
z.object({
|
|
122
123
|
type: z.literal("code_execution_20250825"),
|
|
123
124
|
tool_id: z.string()
|
|
@@ -128,7 +129,7 @@ const anthropicToolCallCallerSchema = z.union([
|
|
|
128
129
|
}),
|
|
129
130
|
z.object({ type: z.literal("direct") })
|
|
130
131
|
]);
|
|
131
|
-
const anthropicCitationSchema = z.discriminatedUnion("type", [
|
|
132
|
+
const anthropicCitationSchema = () => z.discriminatedUnion("type", [
|
|
132
133
|
z.object({
|
|
133
134
|
type: z.literal("web_search_result_location"),
|
|
134
135
|
cited_text: z.string(),
|
|
@@ -173,12 +174,12 @@ const anthropicCitationSchema = z.discriminatedUnion("type", [
|
|
|
173
174
|
end_block_index: z.number()
|
|
174
175
|
})
|
|
175
176
|
]);
|
|
176
|
-
const anthropicMcpToolResultContentSchema = z.union([z.string(), z.array(z.union([z.string(), z.object({
|
|
177
|
+
const anthropicMcpToolResultContentSchema = () => z.union([z.string(), z.array(z.union([z.string(), z.object({
|
|
177
178
|
type: z.literal("text"),
|
|
178
179
|
text: z.string(),
|
|
179
180
|
citations: z.array(z.json()).nullable().optional()
|
|
180
181
|
})]))]);
|
|
181
|
-
const anthropicInputTransformationSchema = z.object({
|
|
182
|
+
const anthropicInputTransformationSchema = () => z.object({
|
|
182
183
|
type: z.string(),
|
|
183
184
|
path: z.string(),
|
|
184
185
|
reason: z.string()
|
|
@@ -191,7 +192,7 @@ const anthropicResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
191
192
|
z.object({
|
|
192
193
|
type: z.literal("text"),
|
|
193
194
|
text: z.string(),
|
|
194
|
-
citations: z.array(anthropicCitationSchema).nullable().optional()
|
|
195
|
+
citations: z.array(anthropicCitationSchema()).nullable().optional()
|
|
195
196
|
}),
|
|
196
197
|
z.object({
|
|
197
198
|
type: z.literal("thinking"),
|
|
@@ -212,7 +213,7 @@ const anthropicResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
212
213
|
id: z.string(),
|
|
213
214
|
name: z.string(),
|
|
214
215
|
input: z.unknown(),
|
|
215
|
-
caller: anthropicToolCallCallerSchema.optional(),
|
|
216
|
+
caller: anthropicToolCallCallerSchema().optional(),
|
|
216
217
|
toolset_name: z.string().nullish()
|
|
217
218
|
}),
|
|
218
219
|
z.object({
|
|
@@ -220,7 +221,7 @@ const anthropicResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
220
221
|
id: z.string(),
|
|
221
222
|
name: z.string(),
|
|
222
223
|
input: z.record(z.string(), z.unknown()).nullish(),
|
|
223
|
-
caller: anthropicToolCallCallerSchema.optional()
|
|
224
|
+
caller: anthropicToolCallCallerSchema().optional()
|
|
224
225
|
}),
|
|
225
226
|
z.object({
|
|
226
227
|
type: z.literal("mcp_tool_use"),
|
|
@@ -233,12 +234,12 @@ const anthropicResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
233
234
|
type: z.literal("mcp_tool_result"),
|
|
234
235
|
tool_use_id: z.string(),
|
|
235
236
|
is_error: z.boolean(),
|
|
236
|
-
content: anthropicMcpToolResultContentSchema
|
|
237
|
+
content: anthropicMcpToolResultContentSchema()
|
|
237
238
|
}),
|
|
238
239
|
z.object({
|
|
239
240
|
type: z.literal("web_fetch_tool_result"),
|
|
240
241
|
tool_use_id: z.string(),
|
|
241
|
-
caller: anthropicToolCallCallerSchema.optional(),
|
|
242
|
+
caller: anthropicToolCallCallerSchema().optional(),
|
|
242
243
|
content: z.union([z.object({
|
|
243
244
|
type: z.literal("web_fetch_result"),
|
|
244
245
|
url: z.string(),
|
|
@@ -265,7 +266,7 @@ const anthropicResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
265
266
|
z.object({
|
|
266
267
|
type: z.literal("web_search_tool_result"),
|
|
267
268
|
tool_use_id: z.string(),
|
|
268
|
-
caller: anthropicToolCallCallerSchema.optional(),
|
|
269
|
+
caller: anthropicToolCallCallerSchema().optional(),
|
|
269
270
|
content: z.union([z.array(z.object({
|
|
270
271
|
type: z.literal("web_search_result"),
|
|
271
272
|
url: z.string(),
|
|
@@ -392,13 +393,13 @@ const anthropicResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
392
393
|
})
|
|
393
394
|
])
|
|
394
395
|
}),
|
|
395
|
-
anthropicFallbackContentSchema
|
|
396
|
+
anthropicFallbackContentSchema()
|
|
396
397
|
])),
|
|
397
398
|
stop_reason: z.string().nullish(),
|
|
398
399
|
stop_sequence: z.string().nullish(),
|
|
399
|
-
stop_details: anthropicStopDetailsSchema.nullish(),
|
|
400
|
-
input_transformations: z.array(anthropicInputTransformationSchema).nullish(),
|
|
401
|
-
safeguard_results: z.array(anthropicSafeguardResultSchema).nullish(),
|
|
400
|
+
stop_details: anthropicStopDetailsSchema().nullish(),
|
|
401
|
+
input_transformations: z.array(anthropicInputTransformationSchema()).nullish(),
|
|
402
|
+
safeguard_results: z.array(anthropicSafeguardResultSchema()).nullish(),
|
|
402
403
|
usage: z.looseObject({
|
|
403
404
|
input_tokens: z.number(),
|
|
404
405
|
output_tokens: z.number(),
|
|
@@ -459,11 +460,11 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
459
460
|
id: z.string(),
|
|
460
461
|
name: z.string(),
|
|
461
462
|
input: z.unknown(),
|
|
462
|
-
caller: anthropicToolCallCallerSchema.optional(),
|
|
463
|
+
caller: anthropicToolCallCallerSchema().optional(),
|
|
463
464
|
toolset_name: z.string().nullish()
|
|
464
465
|
})])).nullish(),
|
|
465
466
|
stop_reason: z.string().nullish(),
|
|
466
|
-
input_transformations: z.array(anthropicInputTransformationSchema).nullish(),
|
|
467
|
+
input_transformations: z.array(anthropicInputTransformationSchema()).nullish(),
|
|
467
468
|
container: z.object({
|
|
468
469
|
expires_at: z.string(),
|
|
469
470
|
id: z.string()
|
|
@@ -487,7 +488,7 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
487
488
|
id: z.string(),
|
|
488
489
|
name: z.string(),
|
|
489
490
|
input: z.record(z.string(), z.unknown()).optional(),
|
|
490
|
-
caller: anthropicToolCallCallerSchema.optional(),
|
|
491
|
+
caller: anthropicToolCallCallerSchema().optional(),
|
|
491
492
|
toolset_name: z.string().nullish()
|
|
492
493
|
}),
|
|
493
494
|
z.object({
|
|
@@ -504,7 +505,7 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
504
505
|
id: z.string(),
|
|
505
506
|
name: z.string(),
|
|
506
507
|
input: z.record(z.string(), z.unknown()).nullish(),
|
|
507
|
-
caller: anthropicToolCallCallerSchema.optional()
|
|
508
|
+
caller: anthropicToolCallCallerSchema().optional()
|
|
508
509
|
}),
|
|
509
510
|
z.object({
|
|
510
511
|
type: z.literal("mcp_tool_use"),
|
|
@@ -517,12 +518,12 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
517
518
|
type: z.literal("mcp_tool_result"),
|
|
518
519
|
tool_use_id: z.string(),
|
|
519
520
|
is_error: z.boolean(),
|
|
520
|
-
content: anthropicMcpToolResultContentSchema
|
|
521
|
+
content: anthropicMcpToolResultContentSchema()
|
|
521
522
|
}),
|
|
522
523
|
z.object({
|
|
523
524
|
type: z.literal("web_fetch_tool_result"),
|
|
524
525
|
tool_use_id: z.string(),
|
|
525
|
-
caller: anthropicToolCallCallerSchema.optional(),
|
|
526
|
+
caller: anthropicToolCallCallerSchema().optional(),
|
|
526
527
|
content: z.union([z.object({
|
|
527
528
|
type: z.literal("web_fetch_result"),
|
|
528
529
|
url: z.string(),
|
|
@@ -549,7 +550,7 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
549
550
|
z.object({
|
|
550
551
|
type: z.literal("web_search_tool_result"),
|
|
551
552
|
tool_use_id: z.string(),
|
|
552
|
-
caller: anthropicToolCallCallerSchema.optional(),
|
|
553
|
+
caller: anthropicToolCallCallerSchema().optional(),
|
|
553
554
|
content: z.union([z.array(z.object({
|
|
554
555
|
type: z.literal("web_search_result"),
|
|
555
556
|
url: z.string(),
|
|
@@ -672,7 +673,7 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
672
673
|
})
|
|
673
674
|
])
|
|
674
675
|
}),
|
|
675
|
-
anthropicFallbackContentSchema
|
|
676
|
+
anthropicFallbackContentSchema()
|
|
676
677
|
])
|
|
677
678
|
}),
|
|
678
679
|
z.object({
|
|
@@ -701,7 +702,7 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
701
702
|
}),
|
|
702
703
|
z.object({
|
|
703
704
|
type: z.literal("citations_delta"),
|
|
704
|
-
citation: anthropicCitationSchema
|
|
705
|
+
citation: anthropicCitationSchema()
|
|
705
706
|
})
|
|
706
707
|
])
|
|
707
708
|
}),
|
|
@@ -725,8 +726,8 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
725
726
|
delta: z.object({
|
|
726
727
|
stop_reason: z.string().nullish(),
|
|
727
728
|
stop_sequence: z.string().nullish(),
|
|
728
|
-
stop_details: anthropicStopDetailsSchema.nullish(),
|
|
729
|
-
safeguard_results: z.array(anthropicSafeguardResultSchema).nullish(),
|
|
729
|
+
stop_details: anthropicStopDetailsSchema().nullish(),
|
|
730
|
+
safeguard_results: z.array(anthropicSafeguardResultSchema()).nullish(),
|
|
730
731
|
container: z.object({
|
|
731
732
|
expires_at: z.string(),
|
|
732
733
|
id: z.string(),
|
|
@@ -757,7 +758,7 @@ const anthropicChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("ty
|
|
|
757
758
|
cache_read_input_tokens: z.number().nullish()
|
|
758
759
|
})).nullish()
|
|
759
760
|
}),
|
|
760
|
-
input_transformations: z.array(anthropicInputTransformationSchema).nullish(),
|
|
761
|
+
input_transformations: z.array(anthropicInputTransformationSchema()).nullish(),
|
|
761
762
|
context_management: z.object({ applied_edits: z.array(z.union([
|
|
762
763
|
z.object({
|
|
763
764
|
type: z.literal("clear_tool_uses_20250919"),
|
|
@@ -785,7 +786,7 @@ const anthropicReasoningMetadataSchema = lazySchema(() => zodSchema(z.object({
|
|
|
785
786
|
* Anthropic file part provider options for document-specific features.
|
|
786
787
|
* These options apply to individual file parts (documents).
|
|
787
788
|
*/
|
|
788
|
-
const anthropicFilePartProviderOptions = z.object({
|
|
789
|
+
const anthropicFilePartProviderOptions = lazySchema(() => zodSchema(z.object({
|
|
789
790
|
/**
|
|
790
791
|
* Upload this file into the code execution container instead of sending it as
|
|
791
792
|
* a normal document or image content block.
|
|
@@ -811,11 +812,11 @@ enabled: z.boolean() }).optional(),
|
|
|
811
812
|
* Useful for storing document metadata as text or stringified JSON.
|
|
812
813
|
*/
|
|
813
814
|
context: z.string().optional()
|
|
814
|
-
});
|
|
815
|
+
})));
|
|
815
816
|
/**
|
|
816
817
|
* Anthropic provider options for system messages.
|
|
817
818
|
*/
|
|
818
|
-
const anthropicSystemMessageProviderOptions = z.object({
|
|
819
|
+
const anthropicSystemMessageProviderOptions = lazySchema(() => zodSchema(z.object({
|
|
819
820
|
/**
|
|
820
821
|
* Controls when an ephemeral mid-conversation system message is cleared.
|
|
821
822
|
*
|
|
@@ -858,8 +859,8 @@ const anthropicSystemMessageProviderOptions = z.object({
|
|
|
858
859
|
type: z.literal("tool_removal"),
|
|
859
860
|
toolName: z.string()
|
|
860
861
|
})])).optional()
|
|
861
|
-
});
|
|
862
|
-
const anthropicLanguageModelOptions = z.object({
|
|
862
|
+
})));
|
|
863
|
+
const anthropicLanguageModelOptions = lazySchema(() => zodSchema(z.object({
|
|
863
864
|
/**
|
|
864
865
|
* Whether to send reasoning to the model.
|
|
865
866
|
*
|
|
@@ -1130,7 +1131,7 @@ userId: z.string().optional() }).optional(),
|
|
|
1130
1131
|
instructions: z.string().optional()
|
|
1131
1132
|
})
|
|
1132
1133
|
])) }).optional()
|
|
1133
|
-
});
|
|
1134
|
+
})));
|
|
1134
1135
|
//#endregion
|
|
1135
1136
|
//#region src/get-cache-control.ts
|
|
1136
1137
|
const MAX_CACHE_BREAKPOINTS = 4;
|
|
@@ -2744,7 +2745,7 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
|
|
|
2744
2745
|
if (part.kind !== "anthropic.fallback") break;
|
|
2745
2746
|
const fallbackMetadata = await safeValidateTypes({
|
|
2746
2747
|
value: part.providerOptions?.anthropic,
|
|
2747
|
-
schema:
|
|
2748
|
+
schema: anthropicFallbackContentSchemaValidator
|
|
2748
2749
|
});
|
|
2749
2750
|
if (!fallbackMetadata.success) {
|
|
2750
2751
|
warnings.push({
|
|
@@ -6172,10 +6173,6 @@ const anthropicSkillVersionResponseSchema = lazySchema(() => zodSchema(z.object(
|
|
|
6172
6173
|
})));
|
|
6173
6174
|
//#endregion
|
|
6174
6175
|
//#region src/skills/anthropic-skills.ts
|
|
6175
|
-
function encodePathSegment(value) {
|
|
6176
|
-
const encodedValue = encodeURIComponent(value);
|
|
6177
|
-
return encodedValue === "." ? "%252E" : encodedValue === ".." ? "%252E%252E" : encodedValue;
|
|
6178
|
-
}
|
|
6179
6176
|
var AnthropicSkills = class {
|
|
6180
6177
|
get provider() {
|
|
6181
6178
|
return this.config.provider;
|