@hiper2d/ai-agents 0.36.1 → 0.37.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/dist/index.d.mts CHANGED
@@ -1468,6 +1468,15 @@ declare class ClaudeAgent extends AbstractAgent {
1468
1468
  * requires 1h entries to precede 5m ones, and a single TTL keeps that trivially true.
1469
1469
  */
1470
1470
  cacheTtl: ClaudeCacheMode;
1471
+ /**
1472
+ * Which message carries the message breakpoint (see applyCacheBreakpoint).
1473
+ * 'previous' (default): the second-to-last message, for hosts whose final message carries
1474
+ * content they never send again (an unsaved reminder) - a breakpoint there would only pay
1475
+ * the write. 'last': the final message, for hosts that replay every request in full on the
1476
+ * next one (Werewolf since 2026-11-15 stores its turn tail and replays it), so the whole
1477
+ * request is written and the next call reads all of it.
1478
+ */
1479
+ cacheAnchor: 'previous' | 'last';
1471
1480
  /** The cache_control to attach to a breakpoint, or none when caching is off. */
1472
1481
  private get cacheControl();
1473
1482
  private get defaultParams();
@@ -1497,6 +1506,9 @@ declare class ClaudeAgent extends AbstractAgent {
1497
1506
  * reply, or an earlier flushed block) reappears verbatim next turn, where the moved-
1498
1507
  * forward breakpoint finds it via the 20-block lookback.
1499
1508
  *
1509
+ * With `cacheAnchor = 'last'` the host says its final message IS replayed, and the
1510
+ * breakpoint goes on the last message instead.
1511
+ *
1500
1512
  * NOT the top-level auto-caching mode: that mode targets the LAST cacheable block,
1501
1513
  * which for us is exactly the never-repeated tail — every entry it wrote would be dead.
1502
1514
  */
package/dist/index.d.ts CHANGED
@@ -1468,6 +1468,15 @@ declare class ClaudeAgent extends AbstractAgent {
1468
1468
  * requires 1h entries to precede 5m ones, and a single TTL keeps that trivially true.
1469
1469
  */
1470
1470
  cacheTtl: ClaudeCacheMode;
1471
+ /**
1472
+ * Which message carries the message breakpoint (see applyCacheBreakpoint).
1473
+ * 'previous' (default): the second-to-last message, for hosts whose final message carries
1474
+ * content they never send again (an unsaved reminder) - a breakpoint there would only pay
1475
+ * the write. 'last': the final message, for hosts that replay every request in full on the
1476
+ * next one (Werewolf since 2026-11-15 stores its turn tail and replays it), so the whole
1477
+ * request is written and the next call reads all of it.
1478
+ */
1479
+ cacheAnchor: 'previous' | 'last';
1471
1480
  /** The cache_control to attach to a breakpoint, or none when caching is off. */
1472
1481
  private get cacheControl();
1473
1482
  private get defaultParams();
@@ -1497,6 +1506,9 @@ declare class ClaudeAgent extends AbstractAgent {
1497
1506
  * reply, or an earlier flushed block) reappears verbatim next turn, where the moved-
1498
1507
  * forward breakpoint finds it via the 20-block lookback.
1499
1508
  *
1509
+ * With `cacheAnchor = 'last'` the host says its final message IS replayed, and the
1510
+ * breakpoint goes on the last message instead.
1511
+ *
1500
1512
  * NOT the top-level auto-caching mode: that mode targets the LAST cacheable block,
1501
1513
  * which for us is exactly the never-repeated tail — every entry it wrote would be dead.
1502
1514
  */
package/dist/index.js CHANGED
@@ -3101,6 +3101,15 @@ var ClaudeAgent = class extends AbstractAgent {
3101
3101
  * requires 1h entries to precede 5m ones, and a single TTL keeps that trivially true.
3102
3102
  */
3103
3103
  cacheTtl = "1h";
3104
+ /**
3105
+ * Which message carries the message breakpoint (see applyCacheBreakpoint).
3106
+ * 'previous' (default): the second-to-last message, for hosts whose final message carries
3107
+ * content they never send again (an unsaved reminder) - a breakpoint there would only pay
3108
+ * the write. 'last': the final message, for hosts that replay every request in full on the
3109
+ * next one (Werewolf since 2026-11-15 stores its turn tail and replays it), so the whole
3110
+ * request is written and the next call reads all of it.
3111
+ */
3112
+ cacheAnchor = "previous";
3104
3113
  /** The cache_control to attach to a breakpoint, or none when caching is off. */
3105
3114
  get cacheControl() {
3106
3115
  return this.cacheTtl === "off" ? {} : { cache_control: { type: "ephemeral", ttl: this.cacheTtl } };
@@ -3215,6 +3224,9 @@ var ClaudeAgent = class extends AbstractAgent {
3215
3224
  * reply, or an earlier flushed block) reappears verbatim next turn, where the moved-
3216
3225
  * forward breakpoint finds it via the 20-block lookback.
3217
3226
  *
3227
+ * With `cacheAnchor = 'last'` the host says its final message IS replayed, and the
3228
+ * breakpoint goes on the last message instead.
3229
+ *
3218
3230
  * NOT the top-level auto-caching mode: that mode targets the LAST cacheable block,
3219
3231
  * which for us is exactly the never-repeated tail — every entry it wrote would be dead.
3220
3232
  */
@@ -3222,10 +3234,11 @@ var ClaudeAgent = class extends AbstractAgent {
3222
3234
  if (this.cacheTtl === "off") {
3223
3235
  return;
3224
3236
  }
3225
- if (messages.length < 2) {
3237
+ const back = this.cacheAnchor === "last" ? 1 : 2;
3238
+ if (messages.length < back) {
3226
3239
  return;
3227
3240
  }
3228
- const anchor = messages[messages.length - 2];
3241
+ const anchor = messages[messages.length - back];
3229
3242
  if (typeof anchor.content === "string") {
3230
3243
  if (anchor.content.length > 0) {
3231
3244
  anchor.content = [{ type: "text", text: anchor.content, cache_control: { type: "ephemeral", ttl: this.cacheTtl } }];