@ai-sdk/anthropic 4.0.109 → 4.0.111
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 +13 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts +6 -2
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +24 -3
- package/dist/internal/index.js.map +1 -1
- package/docs/05-anthropic.mdx +23 -0
- package/package.json +2 -2
- package/src/anthropic-api.ts +2 -2
- package/src/anthropic-language-model-options.ts +10 -0
- package/src/anthropic-language-model.ts +2 -0
- package/src/anthropic-model-catalog.ts +3 -0
- package/src/convert-to-anthropic-prompt.ts +35 -4
package/dist/internal/index.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ type AnthropicToolChangeContent = {
|
|
|
51
51
|
type: 'tool_reference';
|
|
52
52
|
name: string;
|
|
53
53
|
};
|
|
54
|
-
cache_control?:
|
|
54
|
+
cache_control?: AnthropicCacheControl;
|
|
55
55
|
} | {
|
|
56
56
|
type: 'tool_addition';
|
|
57
57
|
/**
|
|
@@ -63,7 +63,7 @@ type AnthropicToolChangeContent = {
|
|
|
63
63
|
type: 'tool_definition';
|
|
64
64
|
definition: AnthropicTool;
|
|
65
65
|
};
|
|
66
|
-
cache_control?:
|
|
66
|
+
cache_control?: AnthropicCacheControl;
|
|
67
67
|
};
|
|
68
68
|
interface AnthropicUserMessage {
|
|
69
69
|
role: 'user';
|
|
@@ -863,6 +863,9 @@ export declare const anthropicProviderOptions: {
|
|
|
863
863
|
includePings: {
|
|
864
864
|
description: string;
|
|
865
865
|
};
|
|
866
|
+
midConversationSystemMessages: {
|
|
867
|
+
description: string;
|
|
868
|
+
};
|
|
866
869
|
structuredOutputMode: {
|
|
867
870
|
description: string;
|
|
868
871
|
};
|
|
@@ -1468,6 +1471,7 @@ declare const anthropicLanguageModelOptions: import("@ai-sdk/provider-utils").La
|
|
|
1468
1471
|
sendReasoning?: boolean | undefined;
|
|
1469
1472
|
structuredOutputMode?: "outputFormat" | "jsonTool" | "auto" | undefined;
|
|
1470
1473
|
includePings?: boolean | undefined;
|
|
1474
|
+
midConversationSystemMessages?: boolean | undefined;
|
|
1471
1475
|
thinking?: {
|
|
1472
1476
|
type: "adaptive";
|
|
1473
1477
|
display?: "omitted" | "summarized" | "updates" | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__anthropic_api0.AnthropicToolChoice","_$__anthropic_api0.AnthropicMessage","_$__anthropic_api0.AnthropicTextContent","SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member"],"sources":["../../src/files/anthropic-files.ts","../../src/anthropic-api.ts","../../src/anthropic-model-catalog.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/supports-native-structured-output-schema.ts","../../src/skills/anthropic-skills.ts"],"mappings":";;;;UAiCU;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,0BAA0B;mBAOR;WANpB;MAEL;EAIyB,YAAA,QAAQ;UAE7B;UAWM;EAUR,aACJ,MACA,WACA,UACA,aACA,WACC,+BAA+B,QAAQ;EAwCpC,aACJ,MACA,aACA,WACC,+BAA+B,QAAQ;EAmBpC,kBACJ,MACA,aACA,WACC,oCAAoC,QAAQ;UA4BvC;EAqBF,eACJ,MACA,aACA,WACC,iCAAiC,QAAQ;;;;KCvLlC,mBACR,uBACA,4BACA;KAEQ;EACV;EACA;;UAGe;EACf;EACA,SAAS,MAAM,uBAAuB;EACtC;EACA;IACE;;;;;;;;;;;;KAaQ;EAEN;EACA;IAAQ;IAAwB;;EAChC;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__anthropic_api0.AnthropicToolChoice","_$__anthropic_api0.AnthropicMessage","_$__anthropic_api0.AnthropicTextContent","SandboxSession","SandboxSession","_$__tool_computer_toolset_202608010.ComputerToolset_20260801Member"],"sources":["../../src/files/anthropic-files.ts","../../src/anthropic-api.ts","../../src/anthropic-model-catalog.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/supports-native-structured-output-schema.ts","../../src/skills/anthropic-skills.ts"],"mappings":";;;;UAiCU;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,0BAA0B;mBAOR;WANpB;MAEL;EAIyB,YAAA,QAAQ;UAE7B;UAWM;EAUR,aACJ,MACA,WACA,UACA,aACA,WACC,+BAA+B,QAAQ;EAwCpC,aACJ,MACA,aACA,WACC,+BAA+B,QAAQ;EAmBpC,kBACJ,MACA,aACA,WACC,oCAAoC,QAAQ;UA4BvC;EAqBF,eACJ,MACA,aACA,WACC,iCAAiC,QAAQ;;;;KCvLlC,mBACR,uBACA,4BACA;KAEQ;EACV;EACA;;UAGe;EACf;EACA,SAAS,MAAM,uBAAuB;EACtC;EACA;IACE;;;;;;;;;;;;KAaQ;EAEN;EACA;IAAQ;IAAwB;;EAChC,gBAAgB;;EAGhB;;;;;;EAMA;IAAQ;IAAyB,YAAY;;EAC7C,gBAAgB;;UAGL;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;I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AO;EACP,YAAY;;;;;;EAOZ;EACA;EACA,wBAAwB;;;;EAKxB;;;;EAKA;;;;;EAMA;;;;;;EAOA;IACE;EACF,OAAO,MAAM;EACb,YAAY;EACZ,cAAc;EACd,OAAO;;;;;;;;;;;wBCnCO,mBAAmB,QAAQ,cAAc;;;;;;;;;;;;wBCDzC,qCACd,QAAQ;;;UCtBA;EACR;EACA;EACA,SAAS,WAAW;EACpB,QAAQ;;qBAGG,2BAA2B;mBAOT;WANpB;MAEL;EAIyB,YAAA,QAAQ;UAEvB;UAMA;EA0BR,YACJ,QAAQ,WAAW,8BAClB,QAAQ,QAAQ,WAAW"}
|
package/dist/internal/index.js
CHANGED
|
@@ -157,6 +157,7 @@ const anthropicProviderOptions = { language: {
|
|
|
157
157
|
thread: { description: "Create or continue a short-lived message thread." },
|
|
158
158
|
sendReasoning: { description: "Whether to send reasoning to the model." },
|
|
159
159
|
includePings: { description: "Include transient ping events in streams." },
|
|
160
|
+
midConversationSystemMessages: { description: "Keep later system messages in the conversation." },
|
|
160
161
|
structuredOutputMode: { description: "How structured outputs are generated." },
|
|
161
162
|
thinking: { description: "Extended thinking configuration." },
|
|
162
163
|
disableParallelToolUse: { description: "Use at most one tool per response." },
|
|
@@ -1785,6 +1786,15 @@ const anthropicLanguageModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
1785
1786
|
/** Emit typed streaming heartbeat parts. Disabled by default. */
|
|
1786
1787
|
includePings: z.boolean().optional(),
|
|
1787
1788
|
/**
|
|
1789
|
+
* Keep a system message that follows user or assistant messages in the
|
|
1790
|
+
* `messages` array, even when no system message comes before it. By
|
|
1791
|
+
* default the first system message becomes the top-level `system`
|
|
1792
|
+
* prompt wherever it appears, which models without mid-conversation
|
|
1793
|
+
* system message support require. Enable this only for models that
|
|
1794
|
+
* support mid-conversation system messages.
|
|
1795
|
+
*/
|
|
1796
|
+
midConversationSystemMessages: z.boolean().optional(),
|
|
1797
|
+
/**
|
|
1788
1798
|
* Configuration for enabling Claude's extended thinking.
|
|
1789
1799
|
*
|
|
1790
1800
|
* When enabled, responses include thinking content blocks showing Claude's thinking process before the final answer.
|
|
@@ -3212,7 +3222,7 @@ async function getInlineToolsFromPrompt(prompt) {
|
|
|
3212
3222
|
}
|
|
3213
3223
|
return inlineTools;
|
|
3214
3224
|
}
|
|
3215
|
-
async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cacheControlValidator, toolNameMapping, toolsetNames = {}, convertMediaPart, convertInlineTool }) {
|
|
3225
|
+
async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cacheControlValidator, toolNameMapping, toolsetNames = {}, convertMediaPart, convertInlineTool, keepMidConversationSystemMessages = false }) {
|
|
3216
3226
|
const betas = /* @__PURE__ */ new Set();
|
|
3217
3227
|
const blocks = groupIntoBlocks(prompt);
|
|
3218
3228
|
const validator = cacheControlValidator || new CacheControlValidator();
|
|
@@ -3259,7 +3269,8 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
|
|
|
3259
3269
|
});
|
|
3260
3270
|
const toolChanges = systemMessageOptions?.toolChanges ?? [];
|
|
3261
3271
|
const content = [];
|
|
3262
|
-
|
|
3272
|
+
const emitsText = text !== "" || toolChanges.length === 0 && systemMessageOptions?.clearAt == null && systemMessageOptions?.effort == null;
|
|
3273
|
+
if (emitsText) content.push({
|
|
3263
3274
|
type: "text",
|
|
3264
3275
|
text,
|
|
3265
3276
|
cache_control: validator.getCacheControl(providerOptions, {
|
|
@@ -3304,6 +3315,15 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
|
|
|
3304
3315
|
});
|
|
3305
3316
|
toolChangeCount++;
|
|
3306
3317
|
}
|
|
3318
|
+
const lastToolChange = content.at(-1);
|
|
3319
|
+
const definesOwnCacheControl = lastToolChange?.type === "tool_addition" && lastToolChange.tool.type === "tool_definition" && "cache_control" in lastToolChange.tool.definition && lastToolChange.tool.definition.cache_control != null;
|
|
3320
|
+
if (!emitsText && lastToolChange != null && !definesOwnCacheControl) {
|
|
3321
|
+
const cacheControl = validator.getCacheControl(providerOptions, {
|
|
3322
|
+
type: "system message",
|
|
3323
|
+
canCache: true
|
|
3324
|
+
});
|
|
3325
|
+
if (cacheControl != null) lastToolChange.cache_control = cacheControl;
|
|
3326
|
+
}
|
|
3307
3327
|
if (content.length === 0 && systemMessageOptions?.clearAt == null && systemMessageOptions?.effort == null) continue;
|
|
3308
3328
|
convertedMessages.push({
|
|
3309
3329
|
content,
|
|
@@ -3315,7 +3335,7 @@ async function convertToAnthropicPrompt({ prompt, sendReasoning, warnings, cache
|
|
|
3315
3335
|
}
|
|
3316
3336
|
const toolChangeCount = convertedMessages.reduce((count, message) => count + message.toolChangeCount, 0);
|
|
3317
3337
|
const hasInlineSystemOptions = convertedMessages.some((message) => message.clearAt != null || message.effort != null);
|
|
3318
|
-
if (i === 0 || system == null && toolChangeCount === 0 && !hasInlineSystemOptions) {
|
|
3338
|
+
if (i === 0 || !keepMidConversationSystemMessages && system == null && toolChangeCount === 0 && !hasInlineSystemOptions) {
|
|
3319
3339
|
if (toolChangeCount > 0) warnings.push({
|
|
3320
3340
|
type: "other",
|
|
3321
3341
|
message: "tool changes on the initial system message are not supported by Anthropic. Configure the initial tool set via the tools option instead. The tool changes have been ignored."
|
|
@@ -4917,6 +4937,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4917
4937
|
toolNameMapping,
|
|
4918
4938
|
toolsetNames,
|
|
4919
4939
|
convertMediaPart: config.convertMediaPart,
|
|
4940
|
+
keepMidConversationSystemMessages: anthropicOptions?.midConversationSystemMessages ?? false,
|
|
4920
4941
|
convertInlineTool: async (tool) => {
|
|
4921
4942
|
const { tools: definitions, toolWarnings, betas } = await prepareTools({
|
|
4922
4943
|
tools: [tool],
|