@warlock.js/ai-anthropic 5.43.0 → 5.44.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 CHANGED
@@ -4,6 +4,12 @@ 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.44.0 - 2026-11-05
8
+
9
+ ### Added
10
+
11
+ - `anthropic.model({ name, contextWindow })` sets `capabilities.contextWindow`; without it the window comes from a table of 200K Claude models, and unknown models stay unset so window-relative `compaction.afterTokens` triggers do not fire.
12
+
7
13
  ## 5.40.0 - 2026-10-29
8
14
 
9
15
  ### Added
package/cjs/index.cjs CHANGED
@@ -405,6 +405,35 @@ function inferPreservedThinking(modelName) {
405
405
  return true;
406
406
  }
407
407
 
408
+ //#endregion
409
+ //#region ../../packages/ai-anthropic/src/known-context-windows.ts
410
+ const RELEASE_CONTEXT_WINDOWS = [
411
+ ["claude-opus-4-5", 2e5],
412
+ ["claude-sonnet-4-5", 2e5],
413
+ ["claude-haiku-4-5", 2e5],
414
+ ["claude-3-7-sonnet", 2e5],
415
+ ["claude-3-5-sonnet", 2e5],
416
+ ["claude-3-5-haiku", 2e5],
417
+ ["claude-3-opus", 2e5],
418
+ ["claude-3-haiku", 2e5]
419
+ ];
420
+ /**
421
+ * The known context window of a Claude model, or `undefined` for an id that
422
+ * is not in the table. Platform prefixes before `claude-` and dated or `@`
423
+ * snapshot suffixes are accepted.
424
+ *
425
+ * @example
426
+ * inferContextWindow("claude-haiku-4-5-20251001"); // → 200000
427
+ * inferContextWindow("my-gateway/model"); // → undefined
428
+ */
429
+ function inferContextWindow(modelName) {
430
+ const lowered = modelName.toLowerCase();
431
+ const start = lowered.indexOf("claude-");
432
+ if (start === -1) return;
433
+ const normalized = lowered.slice(start);
434
+ for (const [root, window] of RELEASE_CONTEXT_WINDOWS) if (matchesReleaseRoot(normalized, root)) return window;
435
+ }
436
+
408
437
  //#endregion
409
438
  //#region ../../packages/ai-anthropic/src/known-output-limits.ts
410
439
  /** Family prefixes whose every release has a 128K output limit. */
@@ -1217,6 +1246,7 @@ var AnthropicModel = class {
1217
1246
  structuredOutput: config.structuredOutput ?? true,
1218
1247
  vision: config.vision ?? inferVisionCapability(config.name),
1219
1248
  reasoning: config.reasoning ?? true,
1249
+ ...windowCapability(config.contextWindow ?? inferContextWindow(config.name)),
1220
1250
  promptCaching: true,
1221
1251
  nativeContextEditing: true,
1222
1252
  pdf: true
@@ -2051,6 +2081,9 @@ function resolveAnthropicOptions(options) {
2051
2081
  const raw = options?.providerOptions?.anthropic;
2052
2082
  return typeof raw === "object" && raw !== null ? raw : {};
2053
2083
  }
2084
+ function windowCapability(window) {
2085
+ return window === void 0 ? {} : { contextWindow: window };
2086
+ }
2054
2087
 
2055
2088
  //#endregion
2056
2089
  //#region ../../packages/ai-anthropic/src/sdk.ts