@hiper2d/ai-agents 0.36.0 → 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.mjs CHANGED
@@ -813,8 +813,7 @@ var SCHEMA_ENFORCING_API_KEYS = /* @__PURE__ */ new Set([
813
813
  API_KEY_CONSTANTS.GOOGLE,
814
814
  API_KEY_CONSTANTS.MISTRAL,
815
815
  API_KEY_CONSTANTS.QWEN,
816
- API_KEY_CONSTANTS.MOONSHOT,
817
- API_KEY_CONSTANTS.META
816
+ API_KEY_CONSTANTS.MOONSHOT
818
817
  ]);
819
818
  var SupportedAiKeyNames = {
820
819
  [API_KEY_CONSTANTS.OPENAI]: "OpenAI",
@@ -2919,6 +2918,15 @@ var ClaudeAgent = class extends AbstractAgent {
2919
2918
  * requires 1h entries to precede 5m ones, and a single TTL keeps that trivially true.
2920
2919
  */
2921
2920
  cacheTtl = "1h";
2921
+ /**
2922
+ * Which message carries the message breakpoint (see applyCacheBreakpoint).
2923
+ * 'previous' (default): the second-to-last message, for hosts whose final message carries
2924
+ * content they never send again (an unsaved reminder) - a breakpoint there would only pay
2925
+ * the write. 'last': the final message, for hosts that replay every request in full on the
2926
+ * next one (Werewolf since 2026-11-15 stores its turn tail and replays it), so the whole
2927
+ * request is written and the next call reads all of it.
2928
+ */
2929
+ cacheAnchor = "previous";
2922
2930
  /** The cache_control to attach to a breakpoint, or none when caching is off. */
2923
2931
  get cacheControl() {
2924
2932
  return this.cacheTtl === "off" ? {} : { cache_control: { type: "ephemeral", ttl: this.cacheTtl } };
@@ -3033,6 +3041,9 @@ var ClaudeAgent = class extends AbstractAgent {
3033
3041
  * reply, or an earlier flushed block) reappears verbatim next turn, where the moved-
3034
3042
  * forward breakpoint finds it via the 20-block lookback.
3035
3043
  *
3044
+ * With `cacheAnchor = 'last'` the host says its final message IS replayed, and the
3045
+ * breakpoint goes on the last message instead.
3046
+ *
3036
3047
  * NOT the top-level auto-caching mode: that mode targets the LAST cacheable block,
3037
3048
  * which for us is exactly the never-repeated tail — every entry it wrote would be dead.
3038
3049
  */
@@ -3040,10 +3051,11 @@ var ClaudeAgent = class extends AbstractAgent {
3040
3051
  if (this.cacheTtl === "off") {
3041
3052
  return;
3042
3053
  }
3043
- if (messages.length < 2) {
3054
+ const back = this.cacheAnchor === "last" ? 1 : 2;
3055
+ if (messages.length < back) {
3044
3056
  return;
3045
3057
  }
3046
- const anchor = messages[messages.length - 2];
3058
+ const anchor = messages[messages.length - back];
3047
3059
  if (typeof anchor.content === "string") {
3048
3060
  if (anchor.content.length > 0) {
3049
3061
  anchor.content = [{ type: "text", text: anchor.content, cache_control: { type: "ephemeral", ttl: this.cacheTtl } }];