@warlock.js/ai-anthropic 5.39.1 → 5.40.0
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 +7 -0
- package/cjs/index.cjs +51 -3
- package/cjs/index.cjs.map +1 -1
- package/esm/model.d.mts.map +1 -1
- package/esm/model.mjs +14 -3
- package/esm/model.mjs.map +1 -1
- package/esm/sdk.d.mts +14 -1
- package/esm/sdk.d.mts.map +1 -1
- package/esm/sdk.mjs +39 -0
- package/esm/sdk.mjs.map +1 -1
- package/llms-full.txt +4 -0
- package/package.json +3 -3
- package/skills/SKILL.md +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to `@warlock.js/ai-anthropic` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.40.0 - 2026-10-29
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- The provider-neutral `contextEditing.clearToolResults` rule (from the agent's `contextEditing` option) maps to a `clear_tool_uses` context edit: `afterTokens` becomes the input-token trigger, `keep` the number of tool uses kept and `exclude` the excluded tools. An explicit `providerOptions.anthropic.contextManagement.clearToolUses` still wins. The model now reports `capabilities.nativeContextEditing`.
|
|
12
|
+
- `anthropic.models()` lists the Claude models the key can use from `GET /v1/models` as `ModelInfo[]`, following pagination, with release date and token limits when the API reports them.
|
|
13
|
+
|
|
7
14
|
## 5.34.3 - 2026-10-20
|
|
8
15
|
|
|
9
16
|
### Changed
|
package/cjs/index.cjs
CHANGED
|
@@ -1218,6 +1218,7 @@ var AnthropicModel = class {
|
|
|
1218
1218
|
vision: config.vision ?? inferVisionCapability(config.name),
|
|
1219
1219
|
reasoning: config.reasoning ?? true,
|
|
1220
1220
|
promptCaching: true,
|
|
1221
|
+
nativeContextEditing: true,
|
|
1221
1222
|
pdf: true
|
|
1222
1223
|
};
|
|
1223
1224
|
}
|
|
@@ -1536,7 +1537,7 @@ var AnthropicModel = class {
|
|
|
1536
1537
|
display: anthropic.thinkingDisplay
|
|
1537
1538
|
};
|
|
1538
1539
|
if (anthropic.thinkingBlockBinding) this.applyBlockBinding(body, anthropic.thinkingBlockBinding, betas);
|
|
1539
|
-
const edits = buildContextEdits(anthropic);
|
|
1540
|
+
const edits = buildContextEdits(anthropic, options?.contextEditing);
|
|
1540
1541
|
if (edits.length > 0) {
|
|
1541
1542
|
if (anthropic.body?.context_management !== void 0) throw new _warlock_js_ai.InvalidRequestError("providerOptions.anthropic.contextManagement / serverCompaction cannot be combined with body.context_management: set the edits in one place.", { context: { fields: ["context_management"] } });
|
|
1542
1543
|
body.context_management = { edits };
|
|
@@ -1935,9 +1936,10 @@ const MIN_COMPACTION_TRIGGER = 5e4;
|
|
|
1935
1936
|
* `context_management.edits`. `clear_thinking_20251015` must come first
|
|
1936
1937
|
* when strategies are combined (Anthropic docs, "Context editing").
|
|
1937
1938
|
*/
|
|
1938
|
-
function buildContextEdits(anthropic) {
|
|
1939
|
+
function buildContextEdits(anthropic, neutral) {
|
|
1939
1940
|
const edits = [];
|
|
1940
|
-
const { clearThinking
|
|
1941
|
+
const { clearThinking } = anthropic.contextManagement ?? {};
|
|
1942
|
+
const clearToolUses = anthropic.contextManagement?.clearToolUses ?? neutralClearToolUses(neutral);
|
|
1941
1943
|
if (clearThinking) edits.push(clearThinkingEdit(clearThinking === true ? {} : clearThinking));
|
|
1942
1944
|
if (clearToolUses) edits.push(clearToolUsesEdit(clearToolUses === true ? {} : clearToolUses));
|
|
1943
1945
|
if (anthropic.serverCompaction) {
|
|
@@ -1954,6 +1956,15 @@ function buildContextEdits(anthropic) {
|
|
|
1954
1956
|
}
|
|
1955
1957
|
return edits;
|
|
1956
1958
|
}
|
|
1959
|
+
function neutralClearToolUses(neutral) {
|
|
1960
|
+
const rule = neutral?.clearToolResults;
|
|
1961
|
+
if (!rule) return void 0;
|
|
1962
|
+
return {
|
|
1963
|
+
...rule.afterTokens !== void 0 ? { trigger: { inputTokens: rule.afterTokens } } : {},
|
|
1964
|
+
...rule.keep !== void 0 ? { keep: rule.keep } : {},
|
|
1965
|
+
...rule.exclude?.length ? { excludeTools: rule.exclude } : {}
|
|
1966
|
+
};
|
|
1967
|
+
}
|
|
1957
1968
|
function clearThinkingEdit(options) {
|
|
1958
1969
|
if (options.keep === void 0 || options.keep === "all") return {
|
|
1959
1970
|
type: "clear_thinking_20251015",
|
|
@@ -2116,6 +2127,43 @@ var AnthropicSDK = class {
|
|
|
2116
2127
|
async count(text, _model) {
|
|
2117
2128
|
return (0, _warlock_js_ai.approximateTokenCount)(text);
|
|
2118
2129
|
}
|
|
2130
|
+
/**
|
|
2131
|
+
* List the Claude models this account can use, live from `GET /v1/models`,
|
|
2132
|
+
* mapped to {@link ModelInfo}. Follows pagination to the end. `created` is
|
|
2133
|
+
* the release date, `contextWindow` and `maxOutputTokens` come from
|
|
2134
|
+
* Anthropic's `max_input_tokens` / `max_tokens` when the API reports them.
|
|
2135
|
+
* Every entry is a chat model (`kind: "chat"`). Failures are thrown as the
|
|
2136
|
+
* adapter's usual provider errors, never an empty list.
|
|
2137
|
+
*
|
|
2138
|
+
* @example
|
|
2139
|
+
* const models = await anthropic.models();
|
|
2140
|
+
* models.map((model) => model.id); // ["claude-sonnet-4-5-...", ...]
|
|
2141
|
+
*/
|
|
2142
|
+
async models(options) {
|
|
2143
|
+
const found = /* @__PURE__ */ new Map();
|
|
2144
|
+
try {
|
|
2145
|
+
for await (const entry of this.client.models.list({ limit: 1e3 }, options?.signal ? { signal: options.signal } : void 0)) {
|
|
2146
|
+
const row = entry;
|
|
2147
|
+
const id = row.id;
|
|
2148
|
+
if (typeof id !== "string" || id === "") continue;
|
|
2149
|
+
const released = typeof row.created_at === "string" ? Date.parse(row.created_at) : NaN;
|
|
2150
|
+
const contextWindow = row.max_input_tokens;
|
|
2151
|
+
const maxOutputTokens = row.max_tokens;
|
|
2152
|
+
found.set(id, {
|
|
2153
|
+
id,
|
|
2154
|
+
label: typeof row.display_name === "string" && row.display_name ? row.display_name : id,
|
|
2155
|
+
provider: this.provider,
|
|
2156
|
+
kind: "chat",
|
|
2157
|
+
...Number.isNaN(released) ? {} : { created: Math.floor(released / 1e3) },
|
|
2158
|
+
...typeof contextWindow === "number" ? { contextWindow } : {},
|
|
2159
|
+
...typeof maxOutputTokens === "number" ? { maxOutputTokens } : {}
|
|
2160
|
+
});
|
|
2161
|
+
}
|
|
2162
|
+
} catch (thrown) {
|
|
2163
|
+
throw wrapAnthropicError(thrown);
|
|
2164
|
+
}
|
|
2165
|
+
return [...found.values()];
|
|
2166
|
+
}
|
|
2119
2167
|
};
|
|
2120
2168
|
|
|
2121
2169
|
//#endregion
|