@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 +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2918,6 +2918,15 @@ var ClaudeAgent = class extends AbstractAgent {
|
|
|
2918
2918
|
* requires 1h entries to precede 5m ones, and a single TTL keeps that trivially true.
|
|
2919
2919
|
*/
|
|
2920
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";
|
|
2921
2930
|
/** The cache_control to attach to a breakpoint, or none when caching is off. */
|
|
2922
2931
|
get cacheControl() {
|
|
2923
2932
|
return this.cacheTtl === "off" ? {} : { cache_control: { type: "ephemeral", ttl: this.cacheTtl } };
|
|
@@ -3032,6 +3041,9 @@ var ClaudeAgent = class extends AbstractAgent {
|
|
|
3032
3041
|
* reply, or an earlier flushed block) reappears verbatim next turn, where the moved-
|
|
3033
3042
|
* forward breakpoint finds it via the 20-block lookback.
|
|
3034
3043
|
*
|
|
3044
|
+
* With `cacheAnchor = 'last'` the host says its final message IS replayed, and the
|
|
3045
|
+
* breakpoint goes on the last message instead.
|
|
3046
|
+
*
|
|
3035
3047
|
* NOT the top-level auto-caching mode: that mode targets the LAST cacheable block,
|
|
3036
3048
|
* which for us is exactly the never-repeated tail — every entry it wrote would be dead.
|
|
3037
3049
|
*/
|
|
@@ -3039,10 +3051,11 @@ var ClaudeAgent = class extends AbstractAgent {
|
|
|
3039
3051
|
if (this.cacheTtl === "off") {
|
|
3040
3052
|
return;
|
|
3041
3053
|
}
|
|
3042
|
-
|
|
3054
|
+
const back = this.cacheAnchor === "last" ? 1 : 2;
|
|
3055
|
+
if (messages.length < back) {
|
|
3043
3056
|
return;
|
|
3044
3057
|
}
|
|
3045
|
-
const anchor = messages[messages.length -
|
|
3058
|
+
const anchor = messages[messages.length - back];
|
|
3046
3059
|
if (typeof anchor.content === "string") {
|
|
3047
3060
|
if (anchor.content.length > 0) {
|
|
3048
3061
|
anchor.content = [{ type: "text", text: anchor.content, cache_control: { type: "ephemeral", ttl: this.cacheTtl } }];
|