@ai-sdk/anthropic 2.0.62 → 2.0.63
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 +6 -0
- package/dist/index.d.mts +52 -6
- package/dist/index.d.ts +52 -6
- package/dist/index.js +80 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +80 -24
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +79 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +79 -23
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -261,7 +261,13 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
261
261
|
applied_edits: import_v42.z.array(
|
|
262
262
|
import_v42.z.union([
|
|
263
263
|
import_v42.z.object({
|
|
264
|
-
type: import_v42.z.literal("
|
|
264
|
+
type: import_v42.z.literal("clear_tool_uses_20250919"),
|
|
265
|
+
cleared_tool_uses: import_v42.z.number(),
|
|
266
|
+
cleared_input_tokens: import_v42.z.number()
|
|
267
|
+
}),
|
|
268
|
+
import_v42.z.object({
|
|
269
|
+
type: import_v42.z.literal("clear_thinking_20251015"),
|
|
270
|
+
cleared_thinking_turns: import_v42.z.number(),
|
|
265
271
|
cleared_input_tokens: import_v42.z.number()
|
|
266
272
|
}),
|
|
267
273
|
import_v42.z.object({
|
|
@@ -558,7 +564,13 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
|
|
|
558
564
|
applied_edits: import_v42.z.array(
|
|
559
565
|
import_v42.z.union([
|
|
560
566
|
import_v42.z.object({
|
|
561
|
-
type: import_v42.z.literal("
|
|
567
|
+
type: import_v42.z.literal("clear_tool_uses_20250919"),
|
|
568
|
+
cleared_tool_uses: import_v42.z.number(),
|
|
569
|
+
cleared_input_tokens: import_v42.z.number()
|
|
570
|
+
}),
|
|
571
|
+
import_v42.z.object({
|
|
572
|
+
type: import_v42.z.literal("clear_thinking_20251015"),
|
|
573
|
+
cleared_thinking_turns: import_v42.z.number(),
|
|
562
574
|
cleared_input_tokens: import_v42.z.number()
|
|
563
575
|
}),
|
|
564
576
|
import_v42.z.object({
|
|
@@ -686,11 +698,30 @@ var anthropicProviderOptions = import_v43.z.object({
|
|
|
686
698
|
edits: import_v43.z.array(
|
|
687
699
|
import_v43.z.discriminatedUnion("type", [
|
|
688
700
|
import_v43.z.object({
|
|
689
|
-
type: import_v43.z.literal("
|
|
690
|
-
trigger: import_v43.z.
|
|
701
|
+
type: import_v43.z.literal("clear_tool_uses_20250919"),
|
|
702
|
+
trigger: import_v43.z.discriminatedUnion("type", [
|
|
703
|
+
import_v43.z.object({
|
|
704
|
+
type: import_v43.z.literal("input_tokens"),
|
|
705
|
+
value: import_v43.z.number()
|
|
706
|
+
}),
|
|
707
|
+
import_v43.z.object({
|
|
708
|
+
type: import_v43.z.literal("tool_uses"),
|
|
709
|
+
value: import_v43.z.number()
|
|
710
|
+
})
|
|
711
|
+
]).optional(),
|
|
712
|
+
keep: import_v43.z.object({
|
|
713
|
+
type: import_v43.z.literal("tool_uses"),
|
|
714
|
+
value: import_v43.z.number()
|
|
715
|
+
}).optional(),
|
|
716
|
+
clearAtLeast: import_v43.z.object({
|
|
691
717
|
type: import_v43.z.literal("input_tokens"),
|
|
692
718
|
value: import_v43.z.number()
|
|
693
719
|
}).optional(),
|
|
720
|
+
clearToolInputs: import_v43.z.boolean().optional(),
|
|
721
|
+
excludeTools: import_v43.z.array(import_v43.z.string()).optional()
|
|
722
|
+
}),
|
|
723
|
+
import_v43.z.object({
|
|
724
|
+
type: import_v43.z.literal("clear_thinking_20251015"),
|
|
694
725
|
keep: import_v43.z.union([
|
|
695
726
|
import_v43.z.literal("all"),
|
|
696
727
|
import_v43.z.object({
|
|
@@ -2027,26 +2058,35 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2027
2058
|
...(anthropicOptions == null ? void 0 : anthropicOptions.contextManagement) && {
|
|
2028
2059
|
context_management: {
|
|
2029
2060
|
edits: anthropicOptions.contextManagement.edits.map((edit) => {
|
|
2030
|
-
const
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
} : void 0;
|
|
2034
|
-
switch (edit.type) {
|
|
2035
|
-
case "clear_01":
|
|
2061
|
+
const strategy = edit.type;
|
|
2062
|
+
switch (strategy) {
|
|
2063
|
+
case "clear_tool_uses_20250919":
|
|
2036
2064
|
return {
|
|
2037
2065
|
type: edit.type,
|
|
2038
2066
|
...edit.trigger !== void 0 && {
|
|
2039
|
-
trigger:
|
|
2067
|
+
trigger: edit.trigger
|
|
2068
|
+
},
|
|
2069
|
+
...edit.keep !== void 0 && { keep: edit.keep },
|
|
2070
|
+
...edit.clearAtLeast !== void 0 && {
|
|
2071
|
+
clear_at_least: edit.clearAtLeast
|
|
2040
2072
|
},
|
|
2041
|
-
...edit.
|
|
2042
|
-
|
|
2073
|
+
...edit.clearToolInputs !== void 0 && {
|
|
2074
|
+
clear_tool_inputs: edit.clearToolInputs
|
|
2075
|
+
},
|
|
2076
|
+
...edit.excludeTools !== void 0 && {
|
|
2077
|
+
exclude_tools: edit.excludeTools
|
|
2043
2078
|
}
|
|
2044
2079
|
};
|
|
2080
|
+
case "clear_thinking_20251015":
|
|
2081
|
+
return {
|
|
2082
|
+
type: edit.type,
|
|
2083
|
+
...edit.keep !== void 0 && { keep: edit.keep }
|
|
2084
|
+
};
|
|
2045
2085
|
case "compact_20260112":
|
|
2046
2086
|
return {
|
|
2047
2087
|
type: edit.type,
|
|
2048
2088
|
...edit.trigger !== void 0 && {
|
|
2049
|
-
trigger:
|
|
2089
|
+
trigger: edit.trigger
|
|
2050
2090
|
},
|
|
2051
2091
|
...edit.pauseAfterCompaction !== void 0 && {
|
|
2052
2092
|
pause_after_compaction: edit.pauseAfterCompaction
|
|
@@ -2058,11 +2098,11 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2058
2098
|
default:
|
|
2059
2099
|
warnings.push({
|
|
2060
2100
|
type: "other",
|
|
2061
|
-
message: `Unknown context management
|
|
2101
|
+
message: `Unknown context management strategy: ${strategy}`
|
|
2062
2102
|
});
|
|
2063
|
-
return
|
|
2103
|
+
return void 0;
|
|
2064
2104
|
}
|
|
2065
|
-
})
|
|
2105
|
+
}).filter((edit) => edit !== void 0)
|
|
2066
2106
|
}
|
|
2067
2107
|
},
|
|
2068
2108
|
// prompt:
|
|
@@ -2524,10 +2564,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2524
2564
|
contextManagement: response.context_management ? {
|
|
2525
2565
|
appliedEdits: response.context_management.applied_edits.map(
|
|
2526
2566
|
(edit) => {
|
|
2527
|
-
|
|
2528
|
-
|
|
2567
|
+
const strategy = edit.type;
|
|
2568
|
+
switch (strategy) {
|
|
2569
|
+
case "clear_tool_uses_20250919":
|
|
2529
2570
|
return {
|
|
2530
2571
|
type: edit.type,
|
|
2572
|
+
clearedToolUses: edit.cleared_tool_uses,
|
|
2573
|
+
clearedInputTokens: edit.cleared_input_tokens
|
|
2574
|
+
};
|
|
2575
|
+
case "clear_thinking_20251015":
|
|
2576
|
+
return {
|
|
2577
|
+
type: edit.type,
|
|
2578
|
+
clearedThinkingTurns: edit.cleared_thinking_turns,
|
|
2531
2579
|
clearedInputTokens: edit.cleared_input_tokens
|
|
2532
2580
|
};
|
|
2533
2581
|
case "compact_20260112":
|
|
@@ -2536,7 +2584,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
2536
2584
|
};
|
|
2537
2585
|
}
|
|
2538
2586
|
}
|
|
2539
|
-
)
|
|
2587
|
+
).filter((edit) => edit !== void 0)
|
|
2540
2588
|
} : null
|
|
2541
2589
|
}
|
|
2542
2590
|
}
|
|
@@ -3023,10 +3071,18 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3023
3071
|
contextManagement = {
|
|
3024
3072
|
appliedEdits: value.context_management.applied_edits.map(
|
|
3025
3073
|
(edit) => {
|
|
3026
|
-
|
|
3027
|
-
|
|
3074
|
+
const strategy = edit.type;
|
|
3075
|
+
switch (strategy) {
|
|
3076
|
+
case "clear_tool_uses_20250919":
|
|
3077
|
+
return {
|
|
3078
|
+
type: edit.type,
|
|
3079
|
+
clearedToolUses: edit.cleared_tool_uses,
|
|
3080
|
+
clearedInputTokens: edit.cleared_input_tokens
|
|
3081
|
+
};
|
|
3082
|
+
case "clear_thinking_20251015":
|
|
3028
3083
|
return {
|
|
3029
3084
|
type: edit.type,
|
|
3085
|
+
clearedThinkingTurns: edit.cleared_thinking_turns,
|
|
3030
3086
|
clearedInputTokens: edit.cleared_input_tokens
|
|
3031
3087
|
};
|
|
3032
3088
|
case "compact_20260112":
|
|
@@ -3035,7 +3091,7 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3035
3091
|
};
|
|
3036
3092
|
}
|
|
3037
3093
|
}
|
|
3038
|
-
)
|
|
3094
|
+
).filter((edit) => edit !== void 0)
|
|
3039
3095
|
};
|
|
3040
3096
|
}
|
|
3041
3097
|
rawUsage = {
|