@compilr-dev/agents 0.4.0 → 0.4.2
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/dist/providers/claude.d.ts +10 -2
- package/dist/providers/claude.js +13 -5
- package/package.json +1 -1
|
@@ -58,6 +58,13 @@ export interface ClaudeProviderConfig {
|
|
|
58
58
|
* Fallback: Math.ceil(text.length / 4)
|
|
59
59
|
*/
|
|
60
60
|
estimateTokens?: (text: string) => number;
|
|
61
|
+
/**
|
|
62
|
+
* Enable extended context window (1M tokens for supported Claude models).
|
|
63
|
+
* Sends `context-1m-2025-08-07` beta header.
|
|
64
|
+
* Long-context pricing applies above 200K tokens per request.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
enableExtendedContext?: boolean;
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* ClaudeProvider implements LLMProvider for Anthropic's Claude API
|
|
@@ -69,6 +76,7 @@ export declare class ClaudeProvider implements LLMProvider {
|
|
|
69
76
|
private readonly defaultMaxTokens;
|
|
70
77
|
private readonly enablePromptCaching;
|
|
71
78
|
private readonly enableTokenEfficientTools;
|
|
79
|
+
private readonly enableExtendedContext;
|
|
72
80
|
private readonly estimateTokensFn;
|
|
73
81
|
constructor(config: ClaudeProviderConfig);
|
|
74
82
|
/**
|
|
@@ -80,8 +88,8 @@ export declare class ClaudeProvider implements LLMProvider {
|
|
|
80
88
|
*/
|
|
81
89
|
countTokens(messages: Message[]): Promise<number>;
|
|
82
90
|
/**
|
|
83
|
-
* Build request options with optional abort signal and beta
|
|
84
|
-
*
|
|
91
|
+
* Build request options with optional abort signal and beta headers.
|
|
92
|
+
* Combines multiple beta features (comma-separated per Anthropic API spec).
|
|
85
93
|
*/
|
|
86
94
|
private buildRequestOptions;
|
|
87
95
|
/**
|
package/dist/providers/claude.js
CHANGED
|
@@ -31,6 +31,7 @@ export class ClaudeProvider {
|
|
|
31
31
|
defaultMaxTokens;
|
|
32
32
|
enablePromptCaching;
|
|
33
33
|
enableTokenEfficientTools;
|
|
34
|
+
enableExtendedContext;
|
|
34
35
|
estimateTokensFn;
|
|
35
36
|
constructor(config) {
|
|
36
37
|
this.client = new Anthropic({
|
|
@@ -41,6 +42,7 @@ export class ClaudeProvider {
|
|
|
41
42
|
this.defaultMaxTokens = config.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
42
43
|
this.enablePromptCaching = config.enablePromptCaching ?? true;
|
|
43
44
|
this.enableTokenEfficientTools = config.enableTokenEfficientTools ?? true;
|
|
45
|
+
this.enableExtendedContext = config.enableExtendedContext ?? false;
|
|
44
46
|
this.estimateTokensFn =
|
|
45
47
|
config.estimateTokens ?? ((s) => Math.ceil(s.length / 4));
|
|
46
48
|
}
|
|
@@ -139,16 +141,22 @@ export class ClaudeProvider {
|
|
|
139
141
|
return Promise.resolve(countMessageTokens(messages));
|
|
140
142
|
}
|
|
141
143
|
/**
|
|
142
|
-
* Build request options with optional abort signal and beta
|
|
143
|
-
*
|
|
144
|
+
* Build request options with optional abort signal and beta headers.
|
|
145
|
+
* Combines multiple beta features (comma-separated per Anthropic API spec).
|
|
144
146
|
*/
|
|
145
147
|
buildRequestOptions(signal, hasTools) {
|
|
146
|
-
const
|
|
147
|
-
if (
|
|
148
|
+
const betas = [];
|
|
149
|
+
if (this.enableTokenEfficientTools && hasTools) {
|
|
150
|
+
betas.push('token-efficient-tools-2025-02-19');
|
|
151
|
+
}
|
|
152
|
+
if (this.enableExtendedContext) {
|
|
153
|
+
betas.push('context-1m-2025-08-07');
|
|
154
|
+
}
|
|
155
|
+
if (!signal && betas.length === 0)
|
|
148
156
|
return undefined;
|
|
149
157
|
return {
|
|
150
158
|
...(signal ? { signal } : {}),
|
|
151
|
-
...(
|
|
159
|
+
...(betas.length > 0 ? { headers: { 'anthropic-beta': betas.join(',') } } : {}),
|
|
152
160
|
};
|
|
153
161
|
}
|
|
154
162
|
/**
|