@ai-sdk/anthropic 4.0.97 → 4.0.99
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 +25 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +280 -71
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +277 -9
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +275 -71
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +224 -3
- package/package.json +3 -3
- package/src/anthropic-api.ts +19 -6
- package/src/anthropic-batch.ts +6 -0
- package/src/anthropic-error.ts +7 -0
- package/src/anthropic-language-model-options.ts +46 -5
- package/src/anthropic-language-model.ts +276 -35
- package/src/anthropic-model-catalog.ts +4 -0
- package/src/anthropic-prepare-tools.ts +21 -9
- package/src/anthropic-provider.ts +1 -0
- package/src/convert-to-anthropic-prompt.ts +136 -2
- package/src/get-cache-control.ts +6 -1
- package/src/internal/index.ts +6 -0
- package/src/tool/computer-toolset_20260801.ts +40 -26
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APICallError, InvalidArgumentError, InvalidResponseDataError, NoSuchModelError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
2
|
-
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, deleteFromApi, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, normalizeHeaders, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, stringifyWithBigIntAndCycles, validateBaseURL, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertAsyncIteratorToReadableStream, convertBase64ToUint8Array, convertInlineFileDataToUint8Array, convertToBase64, createBinaryStreamResponseHandler, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonLinesResponseHandler, createJsonResponseHandler, createProviderDefinedToolFactory, createProviderExecutedToolFactory, createProviderStreamError, createToolNameMapping, deleteFromApi, encodePathSegment, experimental_toolCaller, generateId, getFromApi, getTopLevelMediaType, isCustomReasoning, isNonNullable, isProviderStreamError, isRecord, lazySchema, loadApiKey, loadOptionalSetting, mapReasoningToProviderBudget, mapReasoningToProviderEffort, normalizeBatchRequestCounts, normalizeHeaders, parseProviderOptions, postFormDataToApi, postJsonToApi, resolve, resolveFullMediaType, resolveProviderOptions, resolveProviderReference, safeValidateTypes, secureJsonParse, serializeModelOptions, stringifyWithBigIntAndCycles, validateBaseURL, validateTypes, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { Experimental_DecisionLanguageModel } from "@ai-sdk/provider-utils/experimental-decision";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
5
|
//#region src/anthropic-error.ts
|
|
@@ -7,7 +7,11 @@ const anthropicErrorDataSchema = lazySchema(() => zodSchema(z.object({
|
|
|
7
7
|
type: z.literal("error"),
|
|
8
8
|
error: z.object({
|
|
9
9
|
type: z.string(),
|
|
10
|
-
message: z.string()
|
|
10
|
+
message: z.string(),
|
|
11
|
+
details: z.object({
|
|
12
|
+
error_code: z.string().nullish().catch(void 0),
|
|
13
|
+
unsupported: z.array(z.string()).nullish().catch(void 0)
|
|
14
|
+
}).nullish().catch(void 0)
|
|
11
15
|
})
|
|
12
16
|
})));
|
|
13
17
|
const anthropicFailedResponseHandler = createJsonErrorResponseHandler({
|
|
@@ -151,6 +155,7 @@ var AnthropicFiles = class {
|
|
|
151
155
|
* keeps this list in sync with the option schema.
|
|
152
156
|
*/
|
|
153
157
|
const anthropicProviderOptions = { language: {
|
|
158
|
+
thread: { description: "Create or continue a short-lived message thread." },
|
|
154
159
|
sendReasoning: { description: "Whether to send reasoning to the model." },
|
|
155
160
|
includePings: { description: "Include transient ping events in streams." },
|
|
156
161
|
structuredOutputMode: { description: "How structured outputs are generated." },
|
|
@@ -1260,20 +1265,55 @@ const anthropicSystemMessageProviderOptions = lazySchema(() => zodSchema(z.objec
|
|
|
1260
1265
|
* initial system prompt). A system message carrying tool changes must come
|
|
1261
1266
|
* right before an assistant message or at the end of the messages.
|
|
1262
1267
|
*
|
|
1263
|
-
*
|
|
1264
|
-
*
|
|
1265
|
-
* the
|
|
1266
|
-
* `
|
|
1268
|
+
* A `tool_addition` either references a tool by `toolName` or defines it
|
|
1269
|
+
* by value with `tool`:
|
|
1270
|
+
* - By reference: the tool must be declared in the `tools` option
|
|
1271
|
+
* (typically with `deferLoading: true` so it is not loaded until the
|
|
1272
|
+
* addition surfaces it). The required
|
|
1273
|
+
* `mid-conversation-tool-changes-2026-07-01` beta is added
|
|
1274
|
+
* automatically.
|
|
1275
|
+
* - By value: `tool` is a function or provider tool, in the same shape as
|
|
1276
|
+
* an entry of the `tools` option. The tool does not need to be declared
|
|
1277
|
+
* in `tools`, and defining a tool under an existing name replaces it
|
|
1278
|
+
* from that point on. The required `inline-tools-2026-09-15` beta is
|
|
1279
|
+
* added automatically.
|
|
1280
|
+
*
|
|
1281
|
+
* A `tool_removal` always references the tool by `toolName`.
|
|
1267
1282
|
*/
|
|
1268
|
-
toolChanges: z.array(z.
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1283
|
+
toolChanges: z.array(z.union([
|
|
1284
|
+
z.object({
|
|
1285
|
+
type: z.literal("tool_addition"),
|
|
1286
|
+
toolName: z.string()
|
|
1287
|
+
}),
|
|
1288
|
+
z.object({
|
|
1289
|
+
type: z.literal("tool_addition"),
|
|
1290
|
+
tool: z.union([z.looseObject({
|
|
1291
|
+
type: z.literal("function"),
|
|
1292
|
+
name: z.string(),
|
|
1293
|
+
inputSchema: z.record(z.string(), z.unknown())
|
|
1294
|
+
}), z.looseObject({
|
|
1295
|
+
type: z.literal("provider"),
|
|
1296
|
+
id: z.string(),
|
|
1297
|
+
name: z.string(),
|
|
1298
|
+
args: z.record(z.string(), z.unknown())
|
|
1299
|
+
})])
|
|
1300
|
+
}),
|
|
1301
|
+
z.object({
|
|
1302
|
+
type: z.literal("tool_removal"),
|
|
1303
|
+
toolName: z.string()
|
|
1304
|
+
})
|
|
1305
|
+
])).optional()
|
|
1275
1306
|
})));
|
|
1276
1307
|
const anthropicLanguageModelOptions = lazySchema(() => zodSchema(z.object({
|
|
1308
|
+
/**
|
|
1309
|
+
* Create or continue a short-lived server-side message thread.
|
|
1310
|
+
* On continuation, messages must contain only new messages. Keep the full
|
|
1311
|
+
* conversation locally so it can be replayed when the thread expires.
|
|
1312
|
+
*/
|
|
1313
|
+
thread: z.discriminatedUnion("type", [z.object({ type: z.literal("create") }), z.object({
|
|
1314
|
+
type: z.literal("continue"),
|
|
1315
|
+
previousMessageId: z.string().min(1)
|
|
1316
|
+
})]).optional(),
|
|
1277
1317
|
/**
|
|
1278
1318
|
* Whether to send reasoning to the model.
|
|
1279
1319
|
*
|
|
@@ -1565,10 +1605,11 @@ function getCacheControl(providerMetadata, providerOptionsName) {
|
|
|
1565
1605
|
return custom?.cacheControl ?? custom?.cache_control ?? anthropic?.cacheControl ?? anthropic?.cache_control;
|
|
1566
1606
|
}
|
|
1567
1607
|
var CacheControlValidator = class {
|
|
1568
|
-
constructor(providerOptionsName = "anthropic") {
|
|
1608
|
+
constructor(providerOptionsName = "anthropic", initialBreakpointCount = 0) {
|
|
1569
1609
|
this.providerOptionsName = providerOptionsName;
|
|
1570
1610
|
this.breakpointCount = 0;
|
|
1571
1611
|
this.warnings = [];
|
|
1612
|
+
this.breakpointCount = initialBreakpointCount;
|
|
1572
1613
|
}
|
|
1573
1614
|
getCacheControl(providerMetadata, context) {
|
|
1574
1615
|
const cacheControlValue = getCacheControl(providerMetadata, this.providerOptionsName);
|
|
@@ -1624,14 +1665,14 @@ const advisor_20260301OutputSchema = lazySchema(() => zodSchema(z.discriminatedU
|
|
|
1624
1665
|
})
|
|
1625
1666
|
])));
|
|
1626
1667
|
const advisor_20260301InputSchema = lazySchema(() => zodSchema(z.object({}).strict()));
|
|
1627
|
-
const factory$
|
|
1668
|
+
const factory$13 = createProviderExecutedToolFactory({
|
|
1628
1669
|
id: "anthropic.advisor_20260301",
|
|
1629
1670
|
inputSchema: advisor_20260301InputSchema,
|
|
1630
1671
|
outputSchema: advisor_20260301OutputSchema,
|
|
1631
1672
|
supportsDeferredResults: true
|
|
1632
1673
|
});
|
|
1633
1674
|
const advisor_20260301 = (args) => {
|
|
1634
|
-
return factory$
|
|
1675
|
+
return factory$13(args);
|
|
1635
1676
|
};
|
|
1636
1677
|
//#endregion
|
|
1637
1678
|
//#region src/tool/computer-toolset_20260801.ts
|
|
@@ -1659,8 +1700,8 @@ const computerToolset_20260801Members = [
|
|
|
1659
1700
|
"hold_key",
|
|
1660
1701
|
"wait"
|
|
1661
1702
|
];
|
|
1662
|
-
const computerToolset_20260801InputSchema = lazySchema(() => zodSchema(z.object({
|
|
1663
|
-
action: z.enum(computerToolset_20260801Members),
|
|
1703
|
+
const computerToolset_20260801InputSchema = (configs) => lazySchema(() => zodSchema(z.object({
|
|
1704
|
+
action: z.enum(computerToolset_20260801Members.filter((member) => configs?.[member]?.enabled !== false)),
|
|
1664
1705
|
coordinate: z.tuple([z.number().int(), z.number().int()]).optional(),
|
|
1665
1706
|
duration: z.number().optional(),
|
|
1666
1707
|
region: z.tuple([
|
|
@@ -1684,9 +1725,13 @@ const computerToolset_20260801ArgsSchema = lazySchema(() => zodSchema(z.object({
|
|
|
1684
1725
|
enabled: z.boolean().optional(),
|
|
1685
1726
|
deferLoading: z.boolean().optional()
|
|
1686
1727
|
})).optional() })));
|
|
1687
|
-
const
|
|
1728
|
+
const factory$12 = createProviderDefinedToolFactory({
|
|
1688
1729
|
id: "anthropic.computer_toolset_20260801",
|
|
1689
|
-
inputSchema: computerToolset_20260801InputSchema
|
|
1730
|
+
inputSchema: computerToolset_20260801InputSchema()
|
|
1731
|
+
});
|
|
1732
|
+
const computerToolset_20260801 = (args) => ({
|
|
1733
|
+
...factory$12(args),
|
|
1734
|
+
inputSchema: computerToolset_20260801InputSchema(args.configs)
|
|
1690
1735
|
});
|
|
1691
1736
|
//#endregion
|
|
1692
1737
|
//#region src/tool/text-editor_20250728.ts
|
|
@@ -1925,19 +1970,19 @@ const webFetch_20250910 = (args = {}) => {
|
|
|
1925
1970
|
};
|
|
1926
1971
|
//#endregion
|
|
1927
1972
|
//#region src/anthropic-prepare-tools.ts
|
|
1928
|
-
async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming = false, rejectsForcedToolUse = false }) {
|
|
1973
|
+
async function prepareTools({ tools, toolChoice, hasInlineTools = false, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, defaultEagerInputStreaming = false, rejectsForcedToolUse = false }) {
|
|
1929
1974
|
tools = tools?.length ? tools : void 0;
|
|
1930
1975
|
const toolWarnings = [];
|
|
1931
1976
|
const betas = /* @__PURE__ */ new Set();
|
|
1932
1977
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
1933
|
-
if (tools == null) return {
|
|
1978
|
+
if (tools == null && !hasInlineTools) return {
|
|
1934
1979
|
tools: void 0,
|
|
1935
1980
|
toolChoice: void 0,
|
|
1936
1981
|
toolWarnings,
|
|
1937
1982
|
betas
|
|
1938
1983
|
};
|
|
1939
1984
|
const anthropicTools = [];
|
|
1940
|
-
for (const tool of tools) switch (tool.type) {
|
|
1985
|
+
for (const tool of tools ?? []) switch (tool.type) {
|
|
1941
1986
|
case "function": {
|
|
1942
1987
|
const cacheControl = validator.getCacheControl(tool.providerOptions, {
|
|
1943
1988
|
type: "tool definition",
|
|
@@ -2244,8 +2289,9 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
|
|
|
2244
2289
|
feature: `tool ${tool}`
|
|
2245
2290
|
});
|
|
2246
2291
|
}
|
|
2292
|
+
const declaredTools = tools == null ? void 0 : anthropicTools;
|
|
2247
2293
|
if (toolChoice == null) return {
|
|
2248
|
-
tools:
|
|
2294
|
+
tools: declaredTools,
|
|
2249
2295
|
toolChoice: disableParallelToolUse ? {
|
|
2250
2296
|
type: "auto",
|
|
2251
2297
|
disable_parallel_tool_use: disableParallelToolUse
|
|
@@ -2256,7 +2302,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
|
|
|
2256
2302
|
const type = toolChoice.type;
|
|
2257
2303
|
switch (type) {
|
|
2258
2304
|
case "auto": return {
|
|
2259
|
-
tools:
|
|
2305
|
+
tools: declaredTools,
|
|
2260
2306
|
toolChoice: {
|
|
2261
2307
|
type: "auto",
|
|
2262
2308
|
disable_parallel_tool_use: disableParallelToolUse
|
|
@@ -2272,7 +2318,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
|
|
|
2272
2318
|
details: "toolChoice 'required' is not supported with this model or thinking configuration. Using 'auto' instead. Instruct the model to use a tool in the prompt and verify that a tool call was made."
|
|
2273
2319
|
});
|
|
2274
2320
|
return {
|
|
2275
|
-
tools:
|
|
2321
|
+
tools: declaredTools,
|
|
2276
2322
|
toolChoice: {
|
|
2277
2323
|
type: "auto",
|
|
2278
2324
|
disable_parallel_tool_use: disableParallelToolUse
|
|
@@ -2282,7 +2328,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
|
|
|
2282
2328
|
};
|
|
2283
2329
|
}
|
|
2284
2330
|
return {
|
|
2285
|
-
tools:
|
|
2331
|
+
tools: declaredTools,
|
|
2286
2332
|
toolChoice: {
|
|
2287
2333
|
type: "any",
|
|
2288
2334
|
disable_parallel_tool_use: disableParallelToolUse
|
|
@@ -2291,7 +2337,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
|
|
|
2291
2337
|
betas
|
|
2292
2338
|
};
|
|
2293
2339
|
case "none": return {
|
|
2294
|
-
tools:
|
|
2340
|
+
tools: declaredTools,
|
|
2295
2341
|
toolChoice: { type: "none" },
|
|
2296
2342
|
toolWarnings,
|
|
2297
2343
|
betas
|
|
@@ -2304,7 +2350,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
|
|
|
2304
2350
|
details: `toolChoice 'tool' is not supported with this model or thinking configuration. Only the '${toolChoice.toolName}' tool is sent with 'auto' tool choice. Instruct the model to use the tool in the prompt and verify that a tool call was made.`
|
|
2305
2351
|
});
|
|
2306
2352
|
return {
|
|
2307
|
-
tools:
|
|
2353
|
+
tools: declaredTools?.filter((tool) => "name" in tool && tool.name === toolChoice.toolName),
|
|
2308
2354
|
toolChoice: {
|
|
2309
2355
|
type: "auto",
|
|
2310
2356
|
disable_parallel_tool_use: disableParallelToolUse
|
|
@@ -2314,7 +2360,7 @@ async function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheCo
|
|
|
2314
2360
|
};
|
|
2315
2361
|
}
|
|
2316
2362
|
return {
|
|
2317
|
-
tools:
|
|
2363
|
+
tools: declaredTools,
|
|
2318
2364
|
toolChoice: {
|
|
2319
2365
|
type: "tool",
|
|
2320
2366
|
name: toolChoice.toolName,
|
|
@@ -2692,7 +2738,31 @@ function extractErrorValue(value) {
|
|
|
2692
2738
|
}
|
|
2693
2739
|
return {};
|
|
2694
2740
|
}
|
|
2695
|
-
|
|
2741
|
+
function isComputerTool(tool) {
|
|
2742
|
+
return tool.type === "provider" && tool.id.startsWith("anthropic.computer_");
|
|
2743
|
+
}
|
|
2744
|
+
/**
|
|
2745
|
+
* Collects the tools that mid-conversation tool changes add by value, so they
|
|
2746
|
+
* can take part in tool name mapping like the tools of the `tools` option.
|
|
2747
|
+
* Tools that cannot be added by value are left out because they are ignored.
|
|
2748
|
+
*/
|
|
2749
|
+
async function getInlineToolsFromPrompt(prompt) {
|
|
2750
|
+
const inlineTools = [];
|
|
2751
|
+
for (const message of prompt) {
|
|
2752
|
+
if (message.role !== "system" || message.providerOptions == null) continue;
|
|
2753
|
+
const options = await parseProviderOptions({
|
|
2754
|
+
provider: "anthropic",
|
|
2755
|
+
providerOptions: message.providerOptions,
|
|
2756
|
+
schema: anthropicSystemMessageProviderOptions
|
|
2757
|
+
});
|
|
2758
|
+
for (const toolChange of options?.toolChanges ?? []) if ("tool" in toolChange) {
|
|
2759
|
+
const tool = toolChange.tool;
|
|
2760
|
+
if (!isComputerTool(tool)) inlineTools.push(tool);
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
return inlineTools;
|
|
2764
|
+
}
|
|
2765
|
+
async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cacheControlValidator, toolNameMapping, toolsetNames = {}, convertMediaPart, convertInlineTool }) {
|
|
2696
2766
|
const betas = /* @__PURE__ */ new Set();
|
|
2697
2767
|
const blocks = groupIntoBlocks(prompt);
|
|
2698
2768
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -2747,18 +2817,50 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
|
|
|
2747
2817
|
canCache: true
|
|
2748
2818
|
})
|
|
2749
2819
|
});
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2820
|
+
let toolChangeCount = 0;
|
|
2821
|
+
let hasInlineToolDefinition = false;
|
|
2822
|
+
for (const toolChange of toolChanges) {
|
|
2823
|
+
if ("tool" in toolChange) {
|
|
2824
|
+
if (convertInlineTool == null) throw new UnsupportedFunctionalityError({ functionality: "tool additions by value in mid-conversation tool changes" });
|
|
2825
|
+
const tool = toolChange.tool;
|
|
2826
|
+
if (isComputerTool(tool)) {
|
|
2827
|
+
warnings.push({
|
|
2828
|
+
type: "other",
|
|
2829
|
+
message: `The tool '${tool.name}' cannot be added by value in a tool change. Declare it in the tools option and add it by reference with toolName. The tool change has been ignored.`
|
|
2830
|
+
});
|
|
2831
|
+
continue;
|
|
2832
|
+
}
|
|
2833
|
+
const { definition, warnings: toolWarnings, betas: toolBetas } = await convertInlineTool(tool);
|
|
2834
|
+
warnings.push(...toolWarnings);
|
|
2835
|
+
for (const beta of toolBetas) betas.add(beta);
|
|
2836
|
+
if (definition == null) continue;
|
|
2837
|
+
content.push({
|
|
2838
|
+
type: "tool_addition",
|
|
2839
|
+
tool: {
|
|
2840
|
+
type: "tool_definition",
|
|
2841
|
+
definition
|
|
2842
|
+
}
|
|
2843
|
+
});
|
|
2844
|
+
toolChangeCount++;
|
|
2845
|
+
hasInlineToolDefinition = true;
|
|
2846
|
+
continue;
|
|
2755
2847
|
}
|
|
2756
|
-
|
|
2848
|
+
content.push({
|
|
2849
|
+
type: toolChange.type,
|
|
2850
|
+
tool: {
|
|
2851
|
+
type: "tool_reference",
|
|
2852
|
+
name: toolNameMapping.toProviderToolName(toolChange.toolName)
|
|
2853
|
+
}
|
|
2854
|
+
});
|
|
2855
|
+
toolChangeCount++;
|
|
2856
|
+
}
|
|
2857
|
+
if (content.length === 0 && systemMessageOptions?.clearAt == null && systemMessageOptions?.effort == null) continue;
|
|
2757
2858
|
convertedMessages.push({
|
|
2758
2859
|
content,
|
|
2759
2860
|
clearAt: systemMessageOptions?.clearAt,
|
|
2760
2861
|
effort: systemMessageOptions?.effort,
|
|
2761
|
-
toolChangeCount
|
|
2862
|
+
toolChangeCount,
|
|
2863
|
+
hasInlineToolDefinition
|
|
2762
2864
|
});
|
|
2763
2865
|
}
|
|
2764
2866
|
const toolChangeCount = convertedMessages.reduce((count, message) => count + message.toolChangeCount, 0);
|
|
@@ -2789,7 +2891,8 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
|
|
|
2789
2891
|
...message.clearAt != null && { clear_at: message.clearAt },
|
|
2790
2892
|
...message.effort != null && { output_config: { effort: message.effort } }
|
|
2791
2893
|
});
|
|
2792
|
-
if (message.
|
|
2894
|
+
if (message.hasInlineToolDefinition) betas.add("inline-tools-2026-09-15");
|
|
2895
|
+
else if (message.toolChangeCount > 0) betas.add("mid-conversation-tool-changes-2026-07-01");
|
|
2793
2896
|
if (message.clearAt != null) betas.add("mid-conversation-system-clear-at-2026-08-21");
|
|
2794
2897
|
if (message.effort != null) betas.add("mid-conversation-output-config-2026-07-01");
|
|
2795
2898
|
}
|
|
@@ -4005,6 +4108,16 @@ function isOpenObject(node) {
|
|
|
4005
4108
|
}
|
|
4006
4109
|
//#endregion
|
|
4007
4110
|
//#region src/anthropic-language-model.ts
|
|
4111
|
+
function validateToolsetMember({ toolsetName, memberName, tools }) {
|
|
4112
|
+
const toolset = tools?.find((tool) => "type" in tool && tool.type === "computer_toolset_20260801");
|
|
4113
|
+
if (toolsetName !== "computer" || toolset == null || !computerToolset_20260801Members.some((member) => member === memberName) || toolset.configs?.[memberName]?.enabled === false) throw new InvalidResponseDataError({
|
|
4114
|
+
data: {
|
|
4115
|
+
toolsetName,
|
|
4116
|
+
memberName
|
|
4117
|
+
},
|
|
4118
|
+
message: `Received an unavailable toolset member: ${toolsetName}.${memberName}.`
|
|
4119
|
+
});
|
|
4120
|
+
}
|
|
4008
4121
|
function createAnthropicStreamError(error) {
|
|
4009
4122
|
const inferredMetadata = getAnthropicStreamErrorMetadata(error.type);
|
|
4010
4123
|
return createProviderStreamError({
|
|
@@ -4113,15 +4226,24 @@ function getAnthropicToolsetNames(tools) {
|
|
|
4113
4226
|
* computer tool versions.
|
|
4114
4227
|
*/
|
|
4115
4228
|
function toToolsetMemberInput({ memberName, input }) {
|
|
4229
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) throw new InvalidResponseDataError({
|
|
4230
|
+
data: input,
|
|
4231
|
+
message: "Invalid toolset member input: expected an object."
|
|
4232
|
+
});
|
|
4116
4233
|
return {
|
|
4117
|
-
|
|
4118
|
-
|
|
4234
|
+
...input,
|
|
4235
|
+
action: memberName
|
|
4119
4236
|
};
|
|
4120
4237
|
}
|
|
4121
4238
|
function getProviderOptionsName(provider) {
|
|
4122
4239
|
const dotIndex = provider.indexOf(".");
|
|
4123
4240
|
return dotIndex === -1 ? provider : provider.substring(0, dotIndex);
|
|
4124
4241
|
}
|
|
4242
|
+
/**
|
|
4243
|
+
* Legacy names of custom providerOptions keys, read when the current key is
|
|
4244
|
+
* absent.
|
|
4245
|
+
*/
|
|
4246
|
+
const LEGACY_PROVIDER_OPTIONS_NAMES = { googleVertex: ["vertex"] };
|
|
4125
4247
|
const TEXT_OR_THINKING_BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
4126
4248
|
"redacted_thinking",
|
|
4127
4249
|
"text",
|
|
@@ -4213,12 +4335,13 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4213
4335
|
providerOptions,
|
|
4214
4336
|
schema: anthropicLanguageModelOptions
|
|
4215
4337
|
});
|
|
4216
|
-
const customProviderOptions
|
|
4217
|
-
provider: providerOptionsName,
|
|
4338
|
+
const { options: customProviderOptions, namespaces: [customProviderOptionsName] } = await resolveProviderOptions({
|
|
4218
4339
|
providerOptions,
|
|
4340
|
+
namespaces: providerOptionsName !== "anthropic" ? [providerOptionsName, ...Object.hasOwn(LEGACY_PROVIDER_OPTIONS_NAMES, providerOptionsName) ? LEGACY_PROVIDER_OPTIONS_NAMES[providerOptionsName] : []] : [],
|
|
4341
|
+
resolution: "first",
|
|
4219
4342
|
schema: anthropicLanguageModelOptions
|
|
4220
|
-
})
|
|
4221
|
-
const usedCustomProviderKey =
|
|
4343
|
+
});
|
|
4344
|
+
const usedCustomProviderKey = customProviderOptionsName === providerOptionsName;
|
|
4222
4345
|
const anthropicOptions = Object.assign({}, canonicalOptions ?? {}, customProviderOptions ?? {});
|
|
4223
4346
|
if (anthropicOptions.serviceTier != null) {
|
|
4224
4347
|
const supportedTiers = providerOptionsName === "anthropic" ? ["auto", "standard_only"] : providerOptionsName === "minimax" ? ["standard", "priority"] : void 0;
|
|
@@ -4294,9 +4417,20 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4294
4417
|
argument: "providerOptions",
|
|
4295
4418
|
message: "Anthropic provider options `compaction` and `contextManagement` cannot be used together."
|
|
4296
4419
|
});
|
|
4297
|
-
const
|
|
4420
|
+
const thread = anthropicOptions?.thread;
|
|
4421
|
+
if (thread != null && config.supportsMessageThreads !== true) throw new UnsupportedFunctionalityError({
|
|
4422
|
+
functionality: "Anthropic message threads",
|
|
4423
|
+
message: `${config.provider} does not support Anthropic message threads.`
|
|
4424
|
+
});
|
|
4425
|
+
if (thread != null && (compaction != null || contextManagement?.edits.some((edit) => edit.type !== "clear_thinking_20251015" || edit.keep !== "all"))) throw new InvalidArgumentError({
|
|
4426
|
+
argument: "providerOptions.anthropic.thread",
|
|
4427
|
+
message: "Anthropic message threads do not support compaction or context editing, except clear_thinking_20251015 with keep: \"all\"."
|
|
4428
|
+
});
|
|
4429
|
+
const cacheControlValidator = new CacheControlValidator(config.cacheControlProviderOptionsName, thread != null && anthropicOptions?.cacheControl != null ? 1 : 0);
|
|
4430
|
+
const defaultEagerInputStreaming = stream && (anthropicOptions?.toolStreaming ?? true);
|
|
4431
|
+
const inlineTools = await getInlineToolsFromPrompt(prompt);
|
|
4298
4432
|
const toolNameMapping = createToolNameMapping({
|
|
4299
|
-
tools,
|
|
4433
|
+
tools: [...inlineTools, ...tools ?? []],
|
|
4300
4434
|
providerToolNames: {
|
|
4301
4435
|
"anthropic.code_execution_20250522": "code_execution",
|
|
4302
4436
|
"anthropic.code_execution_20250825": "code_execution",
|
|
@@ -4324,6 +4458,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4324
4458
|
}
|
|
4325
4459
|
});
|
|
4326
4460
|
const toolsetNames = getAnthropicToolsetNames(tools);
|
|
4461
|
+
const inlineToolDefinitions = [];
|
|
4327
4462
|
const { prompt: messagesPrompt, betas } = await convertToAnthropicPrompt({
|
|
4328
4463
|
prompt,
|
|
4329
4464
|
sendReasoning: anthropicOptions?.sendReasoning ?? true,
|
|
@@ -4331,8 +4466,39 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4331
4466
|
cacheControlValidator,
|
|
4332
4467
|
toolNameMapping,
|
|
4333
4468
|
toolsetNames,
|
|
4334
|
-
convertMediaPart: config.convertMediaPart
|
|
4469
|
+
convertMediaPart: config.convertMediaPart,
|
|
4470
|
+
convertInlineTool: async (tool) => {
|
|
4471
|
+
const { tools: definitions, toolWarnings, betas } = await prepareTools({
|
|
4472
|
+
tools: [tool],
|
|
4473
|
+
toolChoice: void 0,
|
|
4474
|
+
cacheControlValidator,
|
|
4475
|
+
supportsStructuredOutput,
|
|
4476
|
+
supportsStrictTools
|
|
4477
|
+
});
|
|
4478
|
+
if (definitions?.[0] != null) inlineToolDefinitions.push({
|
|
4479
|
+
sdkName: tool.name,
|
|
4480
|
+
definition: definitions[0]
|
|
4481
|
+
});
|
|
4482
|
+
return {
|
|
4483
|
+
definition: definitions?.[0],
|
|
4484
|
+
warnings: toolWarnings,
|
|
4485
|
+
betas
|
|
4486
|
+
};
|
|
4487
|
+
}
|
|
4335
4488
|
});
|
|
4489
|
+
if (thread != null) {
|
|
4490
|
+
const unpinnedBetas = [...betas].filter((beta) => !userSuppliedBetas.has(beta) && !anthropicOptions?.anthropicBeta?.includes(beta));
|
|
4491
|
+
if (unpinnedBetas.length > 0) warnings.push({
|
|
4492
|
+
type: "compatibility",
|
|
4493
|
+
feature: "providerOptions.anthropic.thread",
|
|
4494
|
+
details: `Message content enabled beta headers: ${unpinnedBetas.join(", ")}. Thread requests require the same beta set on every turn. Pin these values with anthropicBeta on every request, or start a new thread when the set changes.`
|
|
4495
|
+
});
|
|
4496
|
+
if (thread.type === "continue" && (messagesPrompt.system != null || (tools?.length ?? 0) > 0)) warnings.push({
|
|
4497
|
+
type: "compatibility",
|
|
4498
|
+
feature: "providerOptions.anthropic.thread",
|
|
4499
|
+
details: "Continuation uses the system prompt and tool definitions stored by the create request; supplied definitions are omitted from the wire request. Supply identical tools for local tool handling and fixed request settings. To change system instructions or tools, start a new thread."
|
|
4500
|
+
});
|
|
4501
|
+
}
|
|
4336
4502
|
if (isCustomReasoning(reasoning) && anthropicOptions?.effort == null) {
|
|
4337
4503
|
const reasoningConfig = resolveAnthropicReasoningConfig({
|
|
4338
4504
|
reasoning,
|
|
@@ -4450,7 +4616,11 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4450
4616
|
version: skill.version
|
|
4451
4617
|
}))
|
|
4452
4618
|
} : anthropicOptions.container.id },
|
|
4453
|
-
system: messagesPrompt.system,
|
|
4619
|
+
system: thread?.type === "continue" ? void 0 : messagesPrompt.system,
|
|
4620
|
+
...thread != null && { thread: thread.type === "create" ? { type: "create" } : {
|
|
4621
|
+
type: "continue",
|
|
4622
|
+
previous_message_id: thread.previousMessageId
|
|
4623
|
+
} },
|
|
4454
4624
|
messages: messagesPrompt.messages,
|
|
4455
4625
|
...anthropicOptions?.safeguards && anthropicOptions.safeguards.length > 0 && { safeguards: anthropicOptions.safeguards.map((safeguard) => ({
|
|
4456
4626
|
type: safeguard.type,
|
|
@@ -4566,7 +4736,6 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4566
4736
|
if (thinkingBlockBinding != null) betas.add("thinking-binding-controls-2026-08-01");
|
|
4567
4737
|
if (anthropicOptions?.fallbacks === "default") betas.add("server-side-fallback-2026-07-01");
|
|
4568
4738
|
else if (anthropicOptions?.fallbacks && anthropicOptions.fallbacks.length > 0) betas.add("server-side-fallback-2026-06-01");
|
|
4569
|
-
const defaultEagerInputStreaming = stream && (anthropicOptions?.toolStreaming ?? true);
|
|
4570
4739
|
const { tools: anthropicTools, toolChoice: anthropicToolChoice, toolWarnings, betas: toolsBetas } = await prepareTools(jsonResponseTool != null ? {
|
|
4571
4740
|
tools: [...(tools ?? []).filter((tool) => toolChoice?.type !== "none" && (toolChoice?.type !== "tool" || tool.name === toolChoice.toolName)), jsonResponseTool],
|
|
4572
4741
|
toolChoice: { type: "required" },
|
|
@@ -4579,6 +4748,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4579
4748
|
} : {
|
|
4580
4749
|
tools: tools ?? [],
|
|
4581
4750
|
toolChoice,
|
|
4751
|
+
hasInlineTools: inlineTools.length > 0,
|
|
4582
4752
|
disableParallelToolUse: anthropicOptions?.disableParallelToolUse,
|
|
4583
4753
|
cacheControlValidator,
|
|
4584
4754
|
supportsStructuredOutput,
|
|
@@ -4586,11 +4756,30 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4586
4756
|
defaultEagerInputStreaming,
|
|
4587
4757
|
rejectsForcedToolUse: rejectsForcedToolUse || thinkingType === "enabled"
|
|
4588
4758
|
});
|
|
4759
|
+
if (toolChoice?.type === "tool" && (anthropicToolChoice?.type === "auto" || jsonResponseTool != null) || toolChoice?.type === "none" && jsonResponseTool != null) {
|
|
4760
|
+
for (const server of baseArgs.mcp_servers ?? []) server.tool_configuration = {
|
|
4761
|
+
allowed_tools: server.tool_configuration?.allowed_tools,
|
|
4762
|
+
enabled: false
|
|
4763
|
+
};
|
|
4764
|
+
const emittedInlineDefinitions = new Set(messagesPrompt.messages.flatMap((message) => message.role === "system" ? message.content.flatMap((part) => part.type === "tool_addition" && part.tool.type === "tool_definition" ? [part.tool.definition] : []) : []));
|
|
4765
|
+
const selectedSdkName = toolChoice.type === "tool" ? toolChoice.toolName : void 0;
|
|
4766
|
+
const selectedTool = tools?.find((tool) => tool.name === selectedSdkName);
|
|
4767
|
+
const selectedProviderName = jsonResponseTool != null && selectedSdkName != null && selectedTool?.type !== "function" ? toolNameMapping.toProviderToolName(selectedSdkName) : selectedSdkName;
|
|
4768
|
+
const conflictingTool = inlineToolDefinitions.find(({ sdkName, definition }) => emittedInlineDefinitions.has(definition) && (toolChoice.type === "none" || jsonResponseTool != null && sdkName !== selectedSdkName || !("name" in definition) || definition.name !== selectedProviderName));
|
|
4769
|
+
if (conflictingTool != null) {
|
|
4770
|
+
const toolName = "name" in conflictingTool.definition ? conflictingTool.definition.name : conflictingTool.definition.type;
|
|
4771
|
+
const choice = toolChoice.type === "tool" ? `named tool choice '${toolChoice.toolName}'` : `tool choice 'none'`;
|
|
4772
|
+
throw new InvalidArgumentError({
|
|
4773
|
+
argument: "toolChoice",
|
|
4774
|
+
message: `Inline tool '${toolName}' conflicts with ${choice}. Inline definitions must respect the tool choice when forced tool use falls back or the JSON response tool is used.`
|
|
4775
|
+
});
|
|
4776
|
+
}
|
|
4777
|
+
}
|
|
4589
4778
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
4590
4779
|
return {
|
|
4591
4780
|
args: {
|
|
4592
4781
|
...baseArgs,
|
|
4593
|
-
tools: anthropicTools,
|
|
4782
|
+
tools: thread?.type === "continue" ? void 0 : anthropicTools,
|
|
4594
4783
|
tool_choice: anthropicToolChoice,
|
|
4595
4784
|
stream: stream === true ? true : void 0
|
|
4596
4785
|
},
|
|
@@ -4600,14 +4789,17 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4600
4789
|
...cacheWarnings
|
|
4601
4790
|
],
|
|
4602
4791
|
betas: /* @__PURE__ */ new Set([
|
|
4792
|
+
...thread != null ? ["message-threads-2026-08-12"] : [],
|
|
4603
4793
|
...betas,
|
|
4604
4794
|
...toolsBetas,
|
|
4605
4795
|
...userSuppliedBetas,
|
|
4606
4796
|
...anthropicOptions?.anthropicBeta ?? []
|
|
4607
4797
|
]),
|
|
4798
|
+
markCodeExecutionDynamic: hasDynamicFilteringWebToolWithoutCodeExecution(anthropicTools),
|
|
4608
4799
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
4609
4800
|
includePings: stream === true && anthropicOptions?.includePings === true,
|
|
4610
4801
|
toolNameMapping,
|
|
4802
|
+
preparedTools: anthropicTools,
|
|
4611
4803
|
providerOptionsName,
|
|
4612
4804
|
usedCustomProviderKey
|
|
4613
4805
|
};
|
|
@@ -4651,13 +4843,12 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4651
4843
|
}
|
|
4652
4844
|
async doGenerate(options) {
|
|
4653
4845
|
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
4654
|
-
const { args, warnings, betas, usesJsonResponseTool, toolNameMapping, providerOptionsName, usedCustomProviderKey } = await this.getArgs({
|
|
4846
|
+
const { args, warnings, betas, usesJsonResponseTool, markCodeExecutionDynamic, toolNameMapping, preparedTools, providerOptionsName, usedCustomProviderKey } = await this.getArgs({
|
|
4655
4847
|
...options,
|
|
4656
4848
|
stream: false,
|
|
4657
4849
|
userSuppliedBetas: this.getBetasFromHeaders(configHeaders, options.headers)
|
|
4658
4850
|
});
|
|
4659
4851
|
const citationDocuments = [...this.extractCitationDocuments(options.prompt)];
|
|
4660
|
-
const markCodeExecutionDynamic = hasDynamicFilteringWebToolWithoutCodeExecution(args.tools);
|
|
4661
4852
|
const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
|
|
4662
4853
|
url: this.buildRequestUrl(false),
|
|
4663
4854
|
headers: await this.getHeaders({
|
|
@@ -4734,20 +4925,26 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4734
4925
|
type: "text",
|
|
4735
4926
|
text: JSON.stringify(part.input)
|
|
4736
4927
|
});
|
|
4737
|
-
} else if (part.toolset_name != null)
|
|
4738
|
-
|
|
4739
|
-
toolCallId: part.id,
|
|
4740
|
-
toolName: toolNameMapping.toCustomToolName(part.toolset_name),
|
|
4741
|
-
input: JSON.stringify(toToolsetMemberInput({
|
|
4742
|
-
memberName: part.name,
|
|
4743
|
-
input: part.input
|
|
4744
|
-
})),
|
|
4745
|
-
providerMetadata: { anthropic: {
|
|
4928
|
+
} else if (part.toolset_name != null) {
|
|
4929
|
+
validateToolsetMember({
|
|
4746
4930
|
toolsetName: part.toolset_name,
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4931
|
+
memberName: part.name,
|
|
4932
|
+
tools: preparedTools
|
|
4933
|
+
});
|
|
4934
|
+
content.push({
|
|
4935
|
+
type: "tool-call",
|
|
4936
|
+
toolCallId: part.id,
|
|
4937
|
+
toolName: toolNameMapping.toCustomToolName(part.toolset_name),
|
|
4938
|
+
input: JSON.stringify(toToolsetMemberInput({
|
|
4939
|
+
memberName: part.name,
|
|
4940
|
+
input: part.input
|
|
4941
|
+
})),
|
|
4942
|
+
providerMetadata: { anthropic: {
|
|
4943
|
+
toolsetName: part.toolset_name,
|
|
4944
|
+
...getAnthropicCallerMetadata(part.caller).providerMetadata?.anthropic
|
|
4945
|
+
} }
|
|
4946
|
+
});
|
|
4947
|
+
} else content.push({
|
|
4751
4948
|
type: "tool-call",
|
|
4752
4949
|
toolCallId: part.id,
|
|
4753
4950
|
toolName: part.name,
|
|
@@ -5076,13 +5273,12 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
5076
5273
|
async doStream(options) {
|
|
5077
5274
|
"use step";
|
|
5078
5275
|
const configHeaders = this.config.headers ? await resolve(this.config.headers) : void 0;
|
|
5079
|
-
const { args: body, warnings, betas, usesJsonResponseTool, includePings, toolNameMapping, providerOptionsName, usedCustomProviderKey } = await this.getArgs({
|
|
5276
|
+
const { args: body, warnings, betas, usesJsonResponseTool, markCodeExecutionDynamic, includePings, toolNameMapping, preparedTools, providerOptionsName, usedCustomProviderKey } = await this.getArgs({
|
|
5080
5277
|
...options,
|
|
5081
5278
|
stream: true,
|
|
5082
5279
|
userSuppliedBetas: this.getBetasFromHeaders(configHeaders, options.headers)
|
|
5083
5280
|
});
|
|
5084
5281
|
const citationDocuments = [...this.extractCitationDocuments(options.prompt)];
|
|
5085
|
-
const markCodeExecutionDynamic = hasDynamicFilteringWebToolWithoutCodeExecution(body.tools);
|
|
5086
5282
|
const url = this.buildRequestUrl(true);
|
|
5087
5283
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
5088
5284
|
url,
|
|
@@ -5247,6 +5443,11 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
5247
5443
|
id: String(value.index)
|
|
5248
5444
|
});
|
|
5249
5445
|
} else if (part.toolset_name != null) {
|
|
5446
|
+
validateToolsetMember({
|
|
5447
|
+
toolsetName: part.toolset_name,
|
|
5448
|
+
memberName: part.name,
|
|
5449
|
+
tools: preparedTools
|
|
5450
|
+
});
|
|
5250
5451
|
const callerInfo = getAnthropicCallerInfo(part.caller);
|
|
5251
5452
|
const customToolName = toolNameMapping.toCustomToolName(part.toolset_name);
|
|
5252
5453
|
const hasNonEmptyInput = part.input && Object.keys(part.input).length > 0;
|
|
@@ -5591,9 +5792,12 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
5591
5792
|
try {
|
|
5592
5793
|
memberInput = contentBlock.input === "" ? {} : secureJsonParse(contentBlock.input);
|
|
5593
5794
|
} catch {
|
|
5594
|
-
|
|
5795
|
+
throw new InvalidResponseDataError({
|
|
5796
|
+
data: contentBlock.input,
|
|
5797
|
+
message: "Invalid toolset member input JSON."
|
|
5798
|
+
});
|
|
5595
5799
|
}
|
|
5596
|
-
contentBlock.input =
|
|
5800
|
+
contentBlock.input = JSON.stringify(toToolsetMemberInput({
|
|
5597
5801
|
memberName: contentBlock.toolset.memberName,
|
|
5598
5802
|
input: memberInput
|
|
5599
5803
|
}));
|
|
@@ -6173,6 +6377,10 @@ var AnthropicBatch = class {
|
|
|
6173
6377
|
userSuppliedBetas: new Set(explicitBatchBetas)
|
|
6174
6378
|
}
|
|
6175
6379
|
});
|
|
6380
|
+
if (prepared.args.thread != null) throw new UnsupportedFunctionalityError({
|
|
6381
|
+
functionality: "message threads in batches",
|
|
6382
|
+
message: `Anthropic Message Batches do not support message threads (request "${request.id}").`
|
|
6383
|
+
});
|
|
6176
6384
|
if (prepared.usesJsonResponseTool) throw new UnsupportedFunctionalityError({
|
|
6177
6385
|
functionality: "batch responseFormat JSON-tool fallback",
|
|
6178
6386
|
message: `Anthropic Message Batches cannot decode the JSON-tool structured-output fallback (request "${request.id}") because batch results are retrieved independently of the start call. Use a model that supports native output_format structured outputs.`
|
|
@@ -7470,7 +7678,7 @@ var AnthropicSkills = class {
|
|
|
7470
7678
|
};
|
|
7471
7679
|
//#endregion
|
|
7472
7680
|
//#region src/version.ts
|
|
7473
|
-
const VERSION = "4.0.
|
|
7681
|
+
const VERSION = "4.0.99";
|
|
7474
7682
|
//#endregion
|
|
7475
7683
|
//#region src/anthropic-provider.ts
|
|
7476
7684
|
const ANTHROPIC_API_URL = "https://api.anthropic.com";
|
|
@@ -7516,6 +7724,7 @@ function createAnthropic(options = {}) {
|
|
|
7516
7724
|
};
|
|
7517
7725
|
const languageModelConfig = {
|
|
7518
7726
|
provider: providerName,
|
|
7727
|
+
supportsMessageThreads: true,
|
|
7519
7728
|
baseURL,
|
|
7520
7729
|
headers: getHeaders,
|
|
7521
7730
|
fetch: options.fetch,
|