@ai-sdk/anthropic 2.0.59 → 2.0.61
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 +12 -0
- package/dist/index.d.mts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +293 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +293 -24
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +292 -23
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +292 -23
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 2.0.61
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- af58c05: feat(anthropic): add the new compaction feature
|
|
8
|
+
|
|
9
|
+
## 2.0.60
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 368f270: feat(anthropic): add support for Opus 4.6 fast mode
|
|
14
|
+
|
|
3
15
|
## 2.0.59
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -3,10 +3,34 @@ import { z } from 'zod/v4';
|
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Represents a single iteration in the usage breakdown.
|
|
8
|
+
* When compaction occurs, the API returns an iterations array showing
|
|
9
|
+
* usage for each sampling iteration (compaction + message).
|
|
10
|
+
*/
|
|
11
|
+
interface AnthropicUsageIteration {
|
|
12
|
+
type: 'compaction' | 'message';
|
|
13
|
+
/**
|
|
14
|
+
* Number of input tokens consumed in this iteration.
|
|
15
|
+
*/
|
|
16
|
+
inputTokens: number;
|
|
17
|
+
/**
|
|
18
|
+
* Number of output tokens generated in this iteration.
|
|
19
|
+
*/
|
|
20
|
+
outputTokens: number;
|
|
21
|
+
}
|
|
6
22
|
interface AnthropicMessageMetadata {
|
|
7
23
|
usage: JSONObject;
|
|
8
24
|
cacheCreationInputTokens: number | null;
|
|
9
25
|
stopSequence: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Usage breakdown by iteration when compaction is triggered.
|
|
28
|
+
*
|
|
29
|
+
* When compaction occurs, this array contains usage for each sampling iteration.
|
|
30
|
+
* The first iteration is typically the compaction step, followed by the main
|
|
31
|
+
* message iteration.
|
|
32
|
+
*/
|
|
33
|
+
iterations: AnthropicUsageIteration[] | null;
|
|
10
34
|
/**
|
|
11
35
|
* Information about the container used in this request.
|
|
12
36
|
*
|
|
@@ -40,6 +64,35 @@ interface AnthropicMessageMetadata {
|
|
|
40
64
|
version: string;
|
|
41
65
|
}> | null;
|
|
42
66
|
} | null;
|
|
67
|
+
/**
|
|
68
|
+
* Information about context management operations applied to this request.
|
|
69
|
+
*/
|
|
70
|
+
contextManagement: {
|
|
71
|
+
/**
|
|
72
|
+
* List of context management edits that were applied.
|
|
73
|
+
*/
|
|
74
|
+
appliedEdits: Array<{
|
|
75
|
+
/**
|
|
76
|
+
* The type of context management edit applied.
|
|
77
|
+
* Possible value: 'clear_01'
|
|
78
|
+
*/
|
|
79
|
+
type: 'clear_01';
|
|
80
|
+
/**
|
|
81
|
+
* The number of input tokens that were cleared.
|
|
82
|
+
*/
|
|
83
|
+
clearedInputTokens: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Represents a compaction edit where the conversation context was summarized.
|
|
87
|
+
*/
|
|
88
|
+
| {
|
|
89
|
+
/**
|
|
90
|
+
* The type of context management edit applied.
|
|
91
|
+
* Possible value: 'compact_20260112'
|
|
92
|
+
*/
|
|
93
|
+
type: 'compact_20260112';
|
|
94
|
+
}>;
|
|
95
|
+
} | null;
|
|
43
96
|
}
|
|
44
97
|
|
|
45
98
|
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-opus-4-6' | (string & {});
|
|
@@ -77,6 +130,28 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
77
130
|
high: "high";
|
|
78
131
|
max: "max";
|
|
79
132
|
}>>;
|
|
133
|
+
speed: z.ZodOptional<z.ZodLiteral<"fast">>;
|
|
134
|
+
contextManagement: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
136
|
+
type: z.ZodLiteral<"clear_01">;
|
|
137
|
+
trigger: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<"input_tokens">;
|
|
139
|
+
value: z.ZodNumber;
|
|
140
|
+
}, z.core.$strip>>;
|
|
141
|
+
keep: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodObject<{
|
|
142
|
+
type: z.ZodLiteral<"thinking_turns">;
|
|
143
|
+
value: z.ZodNumber;
|
|
144
|
+
}, z.core.$strip>]>>;
|
|
145
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
146
|
+
type: z.ZodLiteral<"compact_20260112">;
|
|
147
|
+
trigger: z.ZodOptional<z.ZodObject<{
|
|
148
|
+
type: z.ZodLiteral<"input_tokens">;
|
|
149
|
+
value: z.ZodNumber;
|
|
150
|
+
}, z.core.$strip>>;
|
|
151
|
+
pauseAfterCompaction: z.ZodOptional<z.ZodBoolean>;
|
|
152
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strip>]>>;
|
|
154
|
+
}, z.core.$strip>>;
|
|
80
155
|
}, z.core.$strip>;
|
|
81
156
|
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
82
157
|
|
|
@@ -571,4 +646,4 @@ declare const anthropic: AnthropicProvider;
|
|
|
571
646
|
|
|
572
647
|
declare const VERSION: string;
|
|
573
648
|
|
|
574
|
-
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };
|
|
649
|
+
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,34 @@ import { z } from 'zod/v4';
|
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Represents a single iteration in the usage breakdown.
|
|
8
|
+
* When compaction occurs, the API returns an iterations array showing
|
|
9
|
+
* usage for each sampling iteration (compaction + message).
|
|
10
|
+
*/
|
|
11
|
+
interface AnthropicUsageIteration {
|
|
12
|
+
type: 'compaction' | 'message';
|
|
13
|
+
/**
|
|
14
|
+
* Number of input tokens consumed in this iteration.
|
|
15
|
+
*/
|
|
16
|
+
inputTokens: number;
|
|
17
|
+
/**
|
|
18
|
+
* Number of output tokens generated in this iteration.
|
|
19
|
+
*/
|
|
20
|
+
outputTokens: number;
|
|
21
|
+
}
|
|
6
22
|
interface AnthropicMessageMetadata {
|
|
7
23
|
usage: JSONObject;
|
|
8
24
|
cacheCreationInputTokens: number | null;
|
|
9
25
|
stopSequence: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Usage breakdown by iteration when compaction is triggered.
|
|
28
|
+
*
|
|
29
|
+
* When compaction occurs, this array contains usage for each sampling iteration.
|
|
30
|
+
* The first iteration is typically the compaction step, followed by the main
|
|
31
|
+
* message iteration.
|
|
32
|
+
*/
|
|
33
|
+
iterations: AnthropicUsageIteration[] | null;
|
|
10
34
|
/**
|
|
11
35
|
* Information about the container used in this request.
|
|
12
36
|
*
|
|
@@ -40,6 +64,35 @@ interface AnthropicMessageMetadata {
|
|
|
40
64
|
version: string;
|
|
41
65
|
}> | null;
|
|
42
66
|
} | null;
|
|
67
|
+
/**
|
|
68
|
+
* Information about context management operations applied to this request.
|
|
69
|
+
*/
|
|
70
|
+
contextManagement: {
|
|
71
|
+
/**
|
|
72
|
+
* List of context management edits that were applied.
|
|
73
|
+
*/
|
|
74
|
+
appliedEdits: Array<{
|
|
75
|
+
/**
|
|
76
|
+
* The type of context management edit applied.
|
|
77
|
+
* Possible value: 'clear_01'
|
|
78
|
+
*/
|
|
79
|
+
type: 'clear_01';
|
|
80
|
+
/**
|
|
81
|
+
* The number of input tokens that were cleared.
|
|
82
|
+
*/
|
|
83
|
+
clearedInputTokens: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Represents a compaction edit where the conversation context was summarized.
|
|
87
|
+
*/
|
|
88
|
+
| {
|
|
89
|
+
/**
|
|
90
|
+
* The type of context management edit applied.
|
|
91
|
+
* Possible value: 'compact_20260112'
|
|
92
|
+
*/
|
|
93
|
+
type: 'compact_20260112';
|
|
94
|
+
}>;
|
|
95
|
+
} | null;
|
|
43
96
|
}
|
|
44
97
|
|
|
45
98
|
type AnthropicMessagesModelId = 'claude-3-5-haiku-20241022' | 'claude-3-5-haiku-latest' | 'claude-3-7-sonnet-20250219' | 'claude-3-7-sonnet-latest' | 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-20250514' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-opus-4-6' | (string & {});
|
|
@@ -77,6 +130,28 @@ declare const anthropicProviderOptions: z.ZodObject<{
|
|
|
77
130
|
high: "high";
|
|
78
131
|
max: "max";
|
|
79
132
|
}>>;
|
|
133
|
+
speed: z.ZodOptional<z.ZodLiteral<"fast">>;
|
|
134
|
+
contextManagement: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
edits: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
136
|
+
type: z.ZodLiteral<"clear_01">;
|
|
137
|
+
trigger: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
type: z.ZodLiteral<"input_tokens">;
|
|
139
|
+
value: z.ZodNumber;
|
|
140
|
+
}, z.core.$strip>>;
|
|
141
|
+
keep: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodObject<{
|
|
142
|
+
type: z.ZodLiteral<"thinking_turns">;
|
|
143
|
+
value: z.ZodNumber;
|
|
144
|
+
}, z.core.$strip>]>>;
|
|
145
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
146
|
+
type: z.ZodLiteral<"compact_20260112">;
|
|
147
|
+
trigger: z.ZodOptional<z.ZodObject<{
|
|
148
|
+
type: z.ZodLiteral<"input_tokens">;
|
|
149
|
+
value: z.ZodNumber;
|
|
150
|
+
}, z.core.$strip>>;
|
|
151
|
+
pauseAfterCompaction: z.ZodOptional<z.ZodBoolean>;
|
|
152
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
153
|
+
}, z.core.$strip>]>>;
|
|
154
|
+
}, z.core.$strip>>;
|
|
80
155
|
}, z.core.$strip>;
|
|
81
156
|
type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
|
|
82
157
|
|
|
@@ -571,4 +646,4 @@ declare const anthropic: AnthropicProvider;
|
|
|
571
646
|
|
|
572
647
|
declare const VERSION: string;
|
|
573
648
|
|
|
574
|
-
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, VERSION, anthropic, createAnthropic };
|
|
649
|
+
export { type AnthropicMessageMetadata, type AnthropicProvider, type AnthropicProviderOptions, type AnthropicProviderSettings, type AnthropicUsageIteration, VERSION, anthropic, createAnthropic };
|