agentfootprint 7.14.0 → 7.16.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.
Files changed (203) hide show
  1. package/dist/adapters/hosting/agentcore.js +350 -0
  2. package/dist/adapters/hosting/agentcore.js.map +1 -0
  3. package/dist/adapters/llm/BrowserOpenAIProvider.js +7 -3
  4. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  5. package/dist/adapters/llm/OpenAIProvider.js +11 -3
  6. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  7. package/dist/adapters/memory/agentcore.js +125 -1
  8. package/dist/adapters/memory/agentcore.js.map +1 -1
  9. package/dist/adapters/security/agentcore.js +0 -0
  10. package/dist/adapters/security/agentcore.js.map +1 -0
  11. package/dist/conventions.js +7 -0
  12. package/dist/conventions.js.map +1 -1
  13. package/dist/core/Agent.js +56 -2
  14. package/dist/core/Agent.js.map +1 -1
  15. package/dist/core/agent/AgentBuilder.js +86 -1
  16. package/dist/core/agent/AgentBuilder.js.map +1 -1
  17. package/dist/core/agent/buildAgentChart.js +12 -1
  18. package/dist/core/agent/buildAgentChart.js.map +1 -1
  19. package/dist/core/agent/buildDynamicAgentChart.js +10 -1
  20. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  21. package/dist/core/agent/compaction/errors.js +40 -0
  22. package/dist/core/agent/compaction/errors.js.map +1 -0
  23. package/dist/core/agent/compaction/index.js +24 -0
  24. package/dist/core/agent/compaction/index.js.map +1 -0
  25. package/dist/core/agent/compaction/strategy.js +152 -0
  26. package/dist/core/agent/compaction/strategy.js.map +1 -0
  27. package/dist/core/agent/compaction/summarize.js +103 -0
  28. package/dist/core/agent/compaction/summarize.js.map +1 -0
  29. package/dist/core/agent/compaction/turns.js +153 -0
  30. package/dist/core/agent/compaction/turns.js.map +1 -0
  31. package/dist/core/agent/compaction/types.js +21 -0
  32. package/dist/core/agent/compaction/types.js.map +1 -0
  33. package/dist/core/agent/stages/compact.js +130 -0
  34. package/dist/core/agent/stages/compact.js.map +1 -0
  35. package/dist/esm/adapters/hosting/agentcore.d.ts +199 -0
  36. package/dist/esm/adapters/hosting/agentcore.js +321 -0
  37. package/dist/esm/adapters/hosting/agentcore.js.map +1 -0
  38. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +7 -3
  39. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  40. package/dist/esm/adapters/llm/OpenAIProvider.js +11 -3
  41. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  42. package/dist/esm/adapters/memory/agentcore.d.ts +88 -2
  43. package/dist/esm/adapters/memory/agentcore.js +125 -1
  44. package/dist/esm/adapters/memory/agentcore.js.map +1 -1
  45. package/dist/esm/adapters/security/agentcore.d.ts +157 -0
  46. package/dist/esm/adapters/security/agentcore.js +0 -0
  47. package/dist/esm/adapters/security/agentcore.js.map +1 -0
  48. package/dist/esm/conventions.d.ts +7 -0
  49. package/dist/esm/conventions.js +7 -0
  50. package/dist/esm/conventions.js.map +1 -1
  51. package/dist/esm/core/Agent.d.ts +8 -1
  52. package/dist/esm/core/Agent.js +56 -2
  53. package/dist/esm/core/Agent.js.map +1 -1
  54. package/dist/esm/core/agent/AgentBuilder.d.ts +43 -0
  55. package/dist/esm/core/agent/AgentBuilder.js +86 -1
  56. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  57. package/dist/esm/core/agent/buildAgentChart.d.ts +13 -0
  58. package/dist/esm/core/agent/buildAgentChart.js +12 -1
  59. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  60. package/dist/esm/core/agent/buildDynamicAgentChart.js +10 -1
  61. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  62. package/dist/esm/core/agent/compaction/errors.d.ts +26 -0
  63. package/dist/esm/core/agent/compaction/errors.js +36 -0
  64. package/dist/esm/core/agent/compaction/errors.js.map +1 -0
  65. package/dist/esm/core/agent/compaction/index.d.ts +18 -0
  66. package/dist/esm/core/agent/compaction/index.js +18 -0
  67. package/dist/esm/core/agent/compaction/index.js.map +1 -0
  68. package/dist/esm/core/agent/compaction/strategy.d.ts +103 -0
  69. package/dist/esm/core/agent/compaction/strategy.js +148 -0
  70. package/dist/esm/core/agent/compaction/strategy.js.map +1 -0
  71. package/dist/esm/core/agent/compaction/summarize.d.ts +61 -0
  72. package/dist/esm/core/agent/compaction/summarize.js +96 -0
  73. package/dist/esm/core/agent/compaction/summarize.js.map +1 -0
  74. package/dist/esm/core/agent/compaction/turns.d.ts +85 -0
  75. package/dist/esm/core/agent/compaction/turns.js +145 -0
  76. package/dist/esm/core/agent/compaction/turns.js.map +1 -0
  77. package/dist/esm/core/agent/compaction/types.d.ts +148 -0
  78. package/dist/esm/core/agent/compaction/types.js +20 -0
  79. package/dist/esm/core/agent/compaction/types.js.map +1 -0
  80. package/dist/esm/core/agent/stages/compact.d.ts +59 -0
  81. package/dist/esm/core/agent/stages/compact.js +126 -0
  82. package/dist/esm/core/agent/stages/compact.js.map +1 -0
  83. package/dist/esm/core/agent/types.d.ts +11 -0
  84. package/dist/esm/hosting/httpHost.d.ts +121 -0
  85. package/dist/esm/hosting/httpHost.js +248 -0
  86. package/dist/esm/hosting/httpHost.js.map +1 -0
  87. package/dist/esm/hosting/index.d.ts +8 -1
  88. package/dist/esm/hosting/index.js +7 -1
  89. package/dist/esm/hosting/index.js.map +1 -1
  90. package/dist/esm/hosting/nodeHost.d.ts +23 -16
  91. package/dist/esm/hosting/nodeHost.js +32 -199
  92. package/dist/esm/hosting/nodeHost.js.map +1 -1
  93. package/dist/esm/hosting-providers.d.ts +50 -0
  94. package/dist/esm/hosting-providers.js +50 -0
  95. package/dist/esm/hosting-providers.js.map +1 -0
  96. package/dist/esm/index.d.ts +1 -0
  97. package/dist/esm/index.js +5 -0
  98. package/dist/esm/index.js.map +1 -1
  99. package/dist/esm/lib/mcp/gatewayTransport.d.ts +103 -0
  100. package/dist/esm/lib/mcp/gatewayTransport.js +123 -0
  101. package/dist/esm/lib/mcp/gatewayTransport.js.map +1 -0
  102. package/dist/esm/lib/mcp/index.d.ts +2 -1
  103. package/dist/esm/lib/mcp/index.js +1 -0
  104. package/dist/esm/lib/mcp/index.js.map +1 -1
  105. package/dist/esm/lib/mcp/mcpClient.js +10 -2
  106. package/dist/esm/lib/mcp/mcpClient.js.map +1 -1
  107. package/dist/esm/lib/mcp/types.d.ts +45 -1
  108. package/dist/esm/memory/store/types.d.ts +22 -0
  109. package/dist/esm/memory-providers.d.ts +1 -1
  110. package/dist/esm/memory-providers.js.map +1 -1
  111. package/dist/esm/recorders/core/CompactionMeter.d.ts +78 -0
  112. package/dist/esm/recorders/core/CompactionMeter.js +101 -0
  113. package/dist/esm/recorders/core/CompactionMeter.js.map +1 -0
  114. package/dist/esm/security/index.d.ts +10 -1
  115. package/dist/esm/security/index.js +14 -1
  116. package/dist/esm/security/index.js.map +1 -1
  117. package/dist/esm/tool-providers/index.d.ts +6 -2
  118. package/dist/esm/tool-providers/index.js +5 -1
  119. package/dist/esm/tool-providers/index.js.map +1 -1
  120. package/dist/hosting/httpHost.js +276 -0
  121. package/dist/hosting/httpHost.js.map +1 -0
  122. package/dist/hosting/index.js +10 -1
  123. package/dist/hosting/index.js.map +1 -1
  124. package/dist/hosting/nodeHost.js +34 -224
  125. package/dist/hosting/nodeHost.js.map +1 -1
  126. package/dist/hosting-providers.js +57 -0
  127. package/dist/hosting-providers.js.map +1 -0
  128. package/dist/index.js +13 -5
  129. package/dist/index.js.map +1 -1
  130. package/dist/lib/mcp/gatewayTransport.js +129 -0
  131. package/dist/lib/mcp/gatewayTransport.js.map +1 -0
  132. package/dist/lib/mcp/index.js +4 -1
  133. package/dist/lib/mcp/index.js.map +1 -1
  134. package/dist/lib/mcp/mcpClient.js +10 -2
  135. package/dist/lib/mcp/mcpClient.js.map +1 -1
  136. package/dist/memory-providers.js.map +1 -1
  137. package/dist/recorders/core/CompactionMeter.js +105 -0
  138. package/dist/recorders/core/CompactionMeter.js.map +1 -0
  139. package/dist/security/index.js +16 -2
  140. package/dist/security/index.js.map +1 -1
  141. package/dist/tool-providers/index.js +7 -1
  142. package/dist/tool-providers/index.js.map +1 -1
  143. package/dist/types/adapters/hosting/agentcore.d.ts +200 -0
  144. package/dist/types/adapters/hosting/agentcore.d.ts.map +1 -0
  145. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  146. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  147. package/dist/types/adapters/memory/agentcore.d.ts +88 -2
  148. package/dist/types/adapters/memory/agentcore.d.ts.map +1 -1
  149. package/dist/types/adapters/security/agentcore.d.ts +158 -0
  150. package/dist/types/adapters/security/agentcore.d.ts.map +1 -0
  151. package/dist/types/conventions.d.ts +7 -0
  152. package/dist/types/conventions.d.ts.map +1 -1
  153. package/dist/types/core/Agent.d.ts +8 -1
  154. package/dist/types/core/Agent.d.ts.map +1 -1
  155. package/dist/types/core/agent/AgentBuilder.d.ts +43 -0
  156. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  157. package/dist/types/core/agent/buildAgentChart.d.ts +13 -0
  158. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  159. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  160. package/dist/types/core/agent/compaction/errors.d.ts +27 -0
  161. package/dist/types/core/agent/compaction/errors.d.ts.map +1 -0
  162. package/dist/types/core/agent/compaction/index.d.ts +19 -0
  163. package/dist/types/core/agent/compaction/index.d.ts.map +1 -0
  164. package/dist/types/core/agent/compaction/strategy.d.ts +104 -0
  165. package/dist/types/core/agent/compaction/strategy.d.ts.map +1 -0
  166. package/dist/types/core/agent/compaction/summarize.d.ts +62 -0
  167. package/dist/types/core/agent/compaction/summarize.d.ts.map +1 -0
  168. package/dist/types/core/agent/compaction/turns.d.ts +86 -0
  169. package/dist/types/core/agent/compaction/turns.d.ts.map +1 -0
  170. package/dist/types/core/agent/compaction/types.d.ts +149 -0
  171. package/dist/types/core/agent/compaction/types.d.ts.map +1 -0
  172. package/dist/types/core/agent/stages/compact.d.ts +60 -0
  173. package/dist/types/core/agent/stages/compact.d.ts.map +1 -0
  174. package/dist/types/core/agent/types.d.ts +11 -0
  175. package/dist/types/core/agent/types.d.ts.map +1 -1
  176. package/dist/types/hosting/httpHost.d.ts +122 -0
  177. package/dist/types/hosting/httpHost.d.ts.map +1 -0
  178. package/dist/types/hosting/index.d.ts +8 -1
  179. package/dist/types/hosting/index.d.ts.map +1 -1
  180. package/dist/types/hosting/nodeHost.d.ts +23 -16
  181. package/dist/types/hosting/nodeHost.d.ts.map +1 -1
  182. package/dist/types/hosting-providers.d.ts +51 -0
  183. package/dist/types/hosting-providers.d.ts.map +1 -0
  184. package/dist/types/index.d.ts +1 -0
  185. package/dist/types/index.d.ts.map +1 -1
  186. package/dist/types/lib/mcp/gatewayTransport.d.ts +104 -0
  187. package/dist/types/lib/mcp/gatewayTransport.d.ts.map +1 -0
  188. package/dist/types/lib/mcp/index.d.ts +2 -1
  189. package/dist/types/lib/mcp/index.d.ts.map +1 -1
  190. package/dist/types/lib/mcp/mcpClient.d.ts.map +1 -1
  191. package/dist/types/lib/mcp/types.d.ts +45 -1
  192. package/dist/types/lib/mcp/types.d.ts.map +1 -1
  193. package/dist/types/memory/store/types.d.ts +22 -0
  194. package/dist/types/memory/store/types.d.ts.map +1 -1
  195. package/dist/types/memory-providers.d.ts +1 -1
  196. package/dist/types/memory-providers.d.ts.map +1 -1
  197. package/dist/types/recorders/core/CompactionMeter.d.ts +79 -0
  198. package/dist/types/recorders/core/CompactionMeter.d.ts.map +1 -0
  199. package/dist/types/security/index.d.ts +10 -1
  200. package/dist/types/security/index.d.ts.map +1 -1
  201. package/dist/types/tool-providers/index.d.ts +6 -2
  202. package/dist/types/tool-providers/index.d.ts.map +1 -1
  203. package/package.json +14 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Agent.d.ts","sourceRoot":"","sources":["../../../src/core/Agent.ts"],"names":[],"mappings":"AAAA;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ACxC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC;IAQ5C;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAyB1B,MAAM,CACV,UAAU,EAAE,mBAAmB,EAC/B,KAAK,CAAC,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC;IAc5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAyCG;IACH,UAAU,IAAI,kBAAkB,GAAG,SAAS;IAmB5C,OAAO,CAAC,cAAc;IAkItB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,CAAC,IAAI,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAK3E,OAAO,CAAC,cAAc;IA8FtB,OAAO,CAAC,UAAU;CA8NnB"}
@@ -20,6 +20,7 @@ import type { ToolProvider } from '../../tool-providers/types.js';
20
20
  import { type SelfExplainOptions } from '../../lib/trace-toolpack/selfExplain.js';
21
21
  import { Agent } from '../Agent.js';
22
22
  import type { AgentOptions, RunConfigFn } from './types.js';
23
+ import type { CompactionOptions } from './compaction/types.js';
23
24
  /**
24
25
  * Fluent builder. `tool()` accepts any Tool<TArgs, TResult> and registers
25
26
  * it by its schema.name. Duplicate names throw at build time.
@@ -124,6 +125,9 @@ export declare class AgentBuilder {
124
125
  /** Per-run config resolver set via `.configure()`. Undefined = the agent
125
126
  * runs on its build-time model + system prompt, unchanged. */
126
127
  private runConfigFn?;
128
+ /** Resolved `.compaction()` config. Undefined = no compaction stage exists,
129
+ * the ReAct loop target is unchanged, and the run is byte-identical. */
130
+ private compactionConfig?;
127
131
  constructor(opts: AgentOptions);
128
132
  /**
129
133
  * Set the base system prompt.
@@ -230,6 +234,45 @@ export declare class AgentBuilder {
230
234
  * .build();
231
235
  */
232
236
  configure(fn: RunConfigFn): this;
237
+ /**
238
+ * Keep the live context window inside a token budget — without ever losing
239
+ * the record.
240
+ *
241
+ * At each ReAct iteration boundary, compaction compares the LAST call's
242
+ * **adapter-reported** input tokens against `thresholdTokens`. Over budget,
243
+ * it folds the oldest foldable span of the conversation into one summary
244
+ * message and sends that instead. Counted, never guessed: a provider that
245
+ * reports no usage gets a named refusal
246
+ * (`CompactionUnmeasurableError`) rather than an invented number.
247
+ *
248
+ * **The fold edits the window, not the record.** The turns it folds stay in
249
+ * the run's commit log byte-identical — footprintjs's log is append-only,
250
+ * so a fold cannot erase them even in principle. The summary enters as its
251
+ * own recorded step naming every `runtimeStageId` it folded, plus what was
252
+ * measured and what refused to fold. A compacted run is still a provable
253
+ * run: the lens draws a fold seam, not a hole.
254
+ *
255
+ * Never folded: the system envelope, the last `keepRecentTurns` turns, and
256
+ * any turn holding something unresolved — an unanswered tool call, a paused
257
+ * tool, a pending check-in. Folding an unanswered question would destroy
258
+ * the referent of the answer that has not arrived yet, so those refuse by
259
+ * name and the fold takes the next oldest instead.
260
+ *
261
+ * Omit `.compaction()` and nothing changes: no stage, no extra keys, the
262
+ * same request bytes as before.
263
+ *
264
+ * @example
265
+ * ```ts
266
+ * const agent = Agent.create({ provider: anthropic(), model: 'claude-sonnet-4-5' })
267
+ * .compaction({
268
+ * thresholdTokens: 120_000,
269
+ * summarizer: anthropic(),
270
+ * model: 'claude-haiku-4-5', // the cheap one writes the summary
271
+ * })
272
+ * .build();
273
+ * ```
274
+ */
275
+ compaction(options: CompactionOptions): this;
233
276
  /**
234
277
  * Override the ReAct iteration cap set via `Agent.create({
235
278
  * maxIterations })`. Convenience for builder-style code that prefers
@@ -1 +1 @@
1
- {"version":3,"file":"AgentBuilder.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/AgentBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,O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AAI;IAwB1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmDG;IACH,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAU5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI;IAUtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,QAAQ,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAiBxC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,OAAO,CAAC,IAAI,GAAE,qBAA0B,GAAG,IAAI;IAQ/C,WAAW,CAAC,IAAI,GAAE,kBAAuB,GAAG,IAAI;IAmBhD,KAAK,IAAI,KAAK;CAoFf"}
@@ -72,6 +72,19 @@ export interface AgentChartDeps {
72
72
  * mounted before the InjectionEngine (off the ReAct loop). Present only when the
73
73
  * skill graph was built with a relevance scorer. */
74
74
  readonly pickEntryStage?: (scope: never) => Promise<void>;
75
+ /**
76
+ * Context-compaction stage (`.compaction()`, 7.16). Present ONLY when the
77
+ * consumer configured compaction — and when present it BECOMES the ReAct
78
+ * loop target, mounted immediately before the current one.
79
+ *
80
+ * It has to be the loop target rather than merely sit in the loop body:
81
+ * the loop is branch-sourced (`tool-calls → { loopTo }`), so anything ahead
82
+ * of the target runs once and is never seen again. Being the target also
83
+ * puts the fold BEFORE the injection engine and the slots, which is the
84
+ * point — the triggers, the three slots and the wire then all see the same
85
+ * window, and no component gets a different past than the model does.
86
+ */
87
+ readonly compactStage?: (scope: never) => Promise<void>;
75
88
  readonly systemPromptSubflow: FlowChart;
76
89
  readonly messagesSubflow: FlowChart;
77
90
  readonly toolsSubflow: FlowChart;
@@ -1 +1 @@
1
- {"version":3,"file":"buildAgentChart.d.ts","sourceR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appings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAezD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgD3D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CAwXtE"}
1
+ {"version":3,"file":"buildDynamicAgentChart.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/buildDynamicAgentChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAc,MAAM,aAAa,CAAC;AAezD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAgD3D;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CAuYtE"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * compaction/errors — the one refusal compaction makes out loud.
3
+ *
4
+ * Pattern: Typed terminal error (peer of PolicyHaltError).
5
+ * Role: core/ layer.
6
+ * Emits: N/A.
7
+ */
8
+ /**
9
+ * Thrown when compaction is configured but the provider reports no token
10
+ * usage, so the threshold cannot be COUNTED.
11
+ *
12
+ * Compaction is counted, not guessed. Given a provider that reports nothing,
13
+ * the library has three options: guess the window size (a lie), silently do
14
+ * nothing (a configured budget that never applies — config that lies), or say
15
+ * so. It says so, by name, at the first iteration boundary where a completed
16
+ * call reported zero tokens in AND zero out.
17
+ *
18
+ * Terminal: `Agent.run` does not wrap this in `RunCheckpointError`, because
19
+ * resuming would walk into the same wall with the same provider.
20
+ */
21
+ export declare class CompactionUnmeasurableError extends Error {
22
+ readonly name = "CompactionUnmeasurableError";
23
+ /** `provider.name` of the adapter that reported nothing. */
24
+ readonly provider: string;
25
+ constructor(provider: string);
26
+ }
27
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/compaction/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,SAAkB,IAAI,iCAAiC;IACvD,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,QAAQ,EAAE,MAAM;CAY7B"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * compaction — keep the live window inside budget without ever losing the
3
+ * record.
4
+ *
5
+ * The one sentence: **compaction edits the WINDOW, never the LEDGER.** Folded
6
+ * turns stay in the commit log verbatim; the summary enters as its own
7
+ * recorded step naming every `runtimeStageId` it folded. A summary is a claim
8
+ * about the past, so this library files it as a claim — not as the past.
9
+ *
10
+ * Public surface (re-exported from the package root):
11
+ * `CompactionOptions` what `.compaction()` accepts
12
+ * `CompactionRecord` what each over-budget visit wrote to the ledger
13
+ * `FoldRefusal(Reason)` why a turn refused to fold
14
+ * `CompactionUnmeasurableError` the refusal for a provider that reports no usage
15
+ */
16
+ export { CompactionUnmeasurableError } from './errors.js';
17
+ export type { CompactionOptions, CompactionRecord, FoldRefusal, FoldRefusalReason, ResolvedCompaction, } from './types.js';
18
+ export { COMPACTED_FRAME_PREFIX, isCompactedSummary } from './summarize.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/compaction/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EACV,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * compaction/strategy — INTERNAL. How a window strategy is shaped.
3
+ *
4
+ * Pattern: Strategy (GoF), deliberately kept private for now.
5
+ * Role: core/ layer. The compaction stage does the wiring — read the
6
+ * meter, write the window, emit, record, cost — and delegates the
7
+ * one interesting question to a strategy:
8
+ *
9
+ * given the segmented turns, the meter readings, and the
10
+ * options → what should the window become, and what does the
11
+ * ledger need to be told about it?
12
+ *
13
+ * Emits: N/A. A strategy is pure decision + (optionally) its own LLM call;
14
+ * it never touches scope, never emits, and never writes. That is
15
+ * what makes it testable without a chart, and what keeps the
16
+ * "record everything you did" duty in ONE place (the stage) rather
17
+ * than duplicated per strategy.
18
+ *
19
+ * **Not exported from any barrel, and not part of the public API.** The only
20
+ * shipped implementation is `summarizeOldestStrategy` (what `.compaction()`
21
+ * configures). The interface lives here so that the day a second window
22
+ * strategy is warranted it is an added file rather than a rewrite of the
23
+ * stage — but a seam nobody has used twice is a guess, so it stays private
24
+ * until it has a second implementation to be right about.
25
+ */
26
+ import type { LLMMessage } from '../../../adapters/types.js';
27
+ import type { MessageOrigin } from '../../../recorders/core/CompactionMeter.js';
28
+ import { type FoldabilityContext, type Turn } from './turns.js';
29
+ import type { CompactionRecord, ResolvedCompaction } from './types.js';
30
+ /** Everything a strategy is allowed to look at. */
31
+ export interface WindowStrategyInput {
32
+ /** The window as it stands, detached. */
33
+ readonly history: readonly LLMMessage[];
34
+ /** The same window, segmented into turns. */
35
+ readonly turns: readonly Turn[];
36
+ /** Per-message provenance, aligned index-for-index with `history`. */
37
+ readonly origins: readonly MessageOrigin[];
38
+ /** What the provider REPORTED for the last call. Counted, never guessed. */
39
+ readonly measuredTokens: number;
40
+ /** What must not fold: unanswered calls, the paused tool, a pending check-in. */
41
+ readonly foldability: FoldabilityContext;
42
+ /** The ReAct iteration this decision belongs to. */
43
+ readonly iteration: number;
44
+ /** The run's cancellation signal, when there is one. */
45
+ readonly signal: AbortSignal | undefined;
46
+ /** Wall clock, injectable so a caller can pin `survivalMs`. */
47
+ readonly now: () => number;
48
+ }
49
+ /** One message leaving the window, with the facts an eviction event needs. */
50
+ export interface WindowEviction {
51
+ /** Index in the PRE-change window — the index the content hash was built on. */
52
+ readonly index: number;
53
+ /** How long it lived in the window. Exact; 0 when its birth is unknown. */
54
+ readonly survivalMs: number;
55
+ }
56
+ /** What the stage should do next. Everything is optional except the record. */
57
+ export interface WindowStrategyResult {
58
+ /** The new window. Absent = leave the window alone. */
59
+ readonly window?: readonly LLMMessage[];
60
+ /**
61
+ * How the meter must re-align its provenance to the new window, which is
62
+ * `[...head, <one new message>, ...tail]`. Present exactly when `window` is.
63
+ */
64
+ readonly rebase?: {
65
+ readonly headCount: number;
66
+ readonly keptTailCount: number;
67
+ };
68
+ /** What the ledger is told. Always present — a visit always explains itself. */
69
+ readonly record: CompactionRecord;
70
+ /** Messages that left the window, for `context.evicted`. */
71
+ readonly evictions: readonly WindowEviction[];
72
+ /** `planAction` for `context.budget_pressure`. */
73
+ readonly planAction: 'summarize' | 'none';
74
+ /** A billed call the strategy made, for the cost channel. */
75
+ readonly spend?: {
76
+ readonly model: string;
77
+ readonly usage: {
78
+ readonly input: number;
79
+ readonly output: number;
80
+ };
81
+ };
82
+ /** A one-per-run dev warning the stage should print. */
83
+ readonly warning?: string;
84
+ }
85
+ /**
86
+ * A window strategy: what the live window should become when it is over
87
+ * budget, and what the record must say about the change.
88
+ */
89
+ export interface WindowStrategy {
90
+ /** Stable name — goes nowhere public yet; used in messages and tests. */
91
+ readonly name: string;
92
+ plan(input: WindowStrategyInput): Promise<WindowStrategyResult>;
93
+ }
94
+ /**
95
+ * The shipped strategy: fold the oldest contiguous run of foldable turns into
96
+ * one summary message, keeping the recent turns and stepping over anything
97
+ * unresolved.
98
+ *
99
+ * Everything it decides, it explains. Every path returns a record — including
100
+ * the paths that change nothing, which are the ones a person debugging an
101
+ * over-budget window actually needs.
102
+ */
103
+ export declare function summarizeOldestStrategy(config: ResolvedCompaction, defaultModel: string): WindowStrategy;
104
+ //# sourceMappingURL=strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/compaction/strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EAAyB,KAAK,kBAAkB,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,KAAK,EAAE,gBAAgB,EAAe,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEpF,mDAAmD;AACnD,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAChC,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAC;IAC3C,4EAA4E;IAC5E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,iFAAiF;IACjF,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;IACzC,oDAAoD;IACpD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;CAC5B;AAED,8EAA8E;AAC9E,MAAM,WAAW,cAAc;IAC7B,gFAAgF;IAChF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,uDAAuD;IACvD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAAC;IACjF,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,SAAS,cAAc,EAAE,CAAC;IAC9C,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,CAAC;IAC1C,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE;QACf,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,KAAK,EAAE;YAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KACrE,CAAC;IACF,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,MAAM,GACnB,cAAc,CA+HhB"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * compaction/summarize — the authored frame, and the call that fills it.
3
+ *
4
+ * Pattern: Template Method with an authored envelope + untrusted payload.
5
+ * Role: core/ layer. Two boundaries are enforced here, and they are the
6
+ * same boundary pointed in opposite directions:
7
+ *
8
+ * 1. Going OUT to the summarizer, the folded transcript is DATA —
9
+ * wrapped in a delimiter the authored instruction names, so a
10
+ * message inside the conversation cannot re-instruct the
11
+ * summarizer just by looking like an instruction.
12
+ * 2. Coming BACK into the window, the summary is DATA — appended
13
+ * after an authored label the library wrote. A summarizer that
14
+ * returns "IGNORE ALL PREVIOUS INSTRUCTIONS" produces a message
15
+ * that still says, in the library's own words and first, that
16
+ * what follows is a summary written by a model.
17
+ *
18
+ * The frame is authored. The summary is data. Neither can become
19
+ * the other.
20
+ * Emits: N/A (the stage emits; this file only builds and calls).
21
+ */
22
+ import type { LLMMessage, LLMProvider, LLMResponse } from '../../../adapters/types.js';
23
+ /** Opening of the authored label. Stable — tests and readers match on it. */
24
+ export declare const COMPACTED_FRAME_PREFIX = "[compacted history";
25
+ /**
26
+ * What the summarizer is asked to do. Authored, fixed, and never composed
27
+ * from run content — the only variable part of the summarizer's prompt is
28
+ * the transcript, and that arrives between delimiters this text names.
29
+ */
30
+ export declare const SUMMARIZER_SYSTEM_PROMPT: string;
31
+ /** The folded span, rendered as the summarizer's input payload. */
32
+ export declare function renderTranscript(messages: readonly LLMMessage[]): string;
33
+ /**
34
+ * Build the message that replaces the folded span IN THE WINDOW.
35
+ *
36
+ * `role: 'user'` because the folded span always contains message 0 — the
37
+ * providers that care (Anthropic) require the window to open on a user turn.
38
+ *
39
+ * The label is written by this function and always comes first. `summary` is
40
+ * appended to it verbatim: the library never edits model output, and it never
41
+ * lets model output speak in the library's voice either.
42
+ */
43
+ export declare function buildSummaryMessage(summary: string, facts: {
44
+ readonly foldedMessageCount: number;
45
+ readonly iteration: number;
46
+ readonly model: string;
47
+ }): LLMMessage;
48
+ /** True when this message is a frame a previous fold wrote. */
49
+ export declare function isCompactedSummary(msg: LLMMessage | undefined): boolean;
50
+ export interface SummarizeResult {
51
+ readonly text: string;
52
+ readonly usage: LLMResponse['usage'];
53
+ }
54
+ /**
55
+ * Call the summarizer over the folded span.
56
+ *
57
+ * Throws whatever the provider throws — the STAGE decides that a broken
58
+ * summarizer means "no fold this iteration", not "no run". Deciding that
59
+ * here would hide the failure from the record.
60
+ */
61
+ export declare function runSummarizer(provider: LLMProvider, model: string, span: readonly LLMMessage[], signal: AbortSignal | undefined): Promise<SummarizeResult>;
62
+ //# sourceMappingURL=summarize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/compaction/summarize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEvF,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAM3D;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAYzB,CAAC;AAcb,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAExE;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE;IACL,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GACA,UAAU,CAOZ;AAED,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAEvE;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CACtC;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,WAAW,EACrB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,SAAS,UAAU,EAAE,EAC3B,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,eAAe,CAAC,CAQ1B"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * compaction/turns — where a turn boundary is, and which turns may fold.
3
+ *
4
+ * Pattern: Pure functions over the window (no scope, no I/O, no clock).
5
+ * Role: core/ layer. The whole safety argument of compaction lives here:
6
+ * a fold that splits an assistant's `tool_use` from its
7
+ * `tool_result` produces a request the vendor rejects, and a fold
8
+ * that swallows an unanswered question destroys the referent of the
9
+ * answer that has not arrived yet.
10
+ * Emits: N/A.
11
+ *
12
+ * Testable on its own — see `test/core/agent/compaction-turns.test.ts`.
13
+ */
14
+ import type { LLMMessage } from '../../../adapters/types.js';
15
+ import type { FoldRefusal, FoldRefusalReason } from './types.js';
16
+ /**
17
+ * One turn: a `user` / `assistant` / `system` message plus every `tool`
18
+ * message that answers it. Tool results belong to the assistant turn that
19
+ * requested them — that pairing is the thing a fold must never break.
20
+ */
21
+ export interface Turn {
22
+ /** Index of this turn in the segmentation. */
23
+ readonly index: number;
24
+ /** Index of the turn's FIRST message in the window. */
25
+ readonly start: number;
26
+ /** Number of messages in the turn. */
27
+ readonly length: number;
28
+ readonly messages: readonly LLMMessage[];
29
+ }
30
+ /**
31
+ * Segment a window into turns.
32
+ *
33
+ * A new turn starts at any non-`tool` message; `tool` messages join the turn
34
+ * in progress. A leading `tool` message (only reachable from a hand-built
35
+ * history) starts its own turn rather than being silently dropped.
36
+ */
37
+ export declare function segmentTurns(history: readonly LLMMessage[]): readonly Turn[];
38
+ /** Context a foldability decision needs beyond the turn itself. */
39
+ export interface FoldabilityContext {
40
+ /** Every `toolCallId` answered anywhere in the window. */
41
+ readonly answeredCallIds: ReadonlySet<string>;
42
+ /** The tool call this run is paused on, when it is paused. */
43
+ readonly pausedToolCallId?: string;
44
+ /** True when the pause is a check-in (human consent) rather than askHuman. */
45
+ readonly pausedCheckIn?: boolean;
46
+ }
47
+ /** Every tool_call id that has a matching `role: 'tool'` message. */
48
+ export declare function answeredCallIds(history: readonly LLMMessage[]): ReadonlySet<string>;
49
+ /**
50
+ * Why this turn may NOT fold, or `undefined` when it may.
51
+ *
52
+ * Order matters only for which reason gets reported first; every check is
53
+ * independent. `paused-tool` / `pending-check-in` are separated from
54
+ * `unresolved-tool-call` on purpose: they are the same shape but a different
55
+ * fact about the world, and "we are waiting on a human" is what the person
56
+ * reading the trace needs to see.
57
+ */
58
+ export declare function refusalFor(turn: Turn, ctx: FoldabilityContext): FoldRefusalReason | undefined;
59
+ /** The span a fold will take, plus every refusal it had to name to get there. */
60
+ export interface FoldPlan {
61
+ /** First turn index in the fold span; -1 when nothing folds. */
62
+ readonly from: number;
63
+ /** Last turn index in the fold span (inclusive); -1 when nothing folds. */
64
+ readonly to: number;
65
+ readonly refusals: readonly FoldRefusal[];
66
+ }
67
+ /**
68
+ * Choose the fold span: the LONGEST CONTIGUOUS run of foldable candidate
69
+ * turns, starting at the oldest foldable one.
70
+ *
71
+ * Contiguity is not fussiness — it is what keeps the conversation in order.
72
+ * A fold replaces its span with ONE summary message; if the span skipped over
73
+ * an unfoldable turn, that turn would end up after a summary of things that
74
+ * happened before it. So an unfoldable turn at the front is stepped over (the
75
+ * fold "takes the next oldest instead") and an unfoldable turn in the middle
76
+ * ends the span. Everything not folded keeps its position.
77
+ *
78
+ * @param turns the window's turn segmentation
79
+ * @param keepRecent how many trailing turns are off-limits
80
+ * @param ctx foldability inputs
81
+ * @param isSummaryTurn true for a turn that is a summary a prior fold wrote
82
+ */
83
+ export declare function planFold(turns: readonly Turn[], keepRecent: number, ctx: FoldabilityContext, isSummaryTurn: (turn: Turn) => boolean): FoldPlan;
84
+ /** Total characters of message content in a window. Exact; not tokens. */
85
+ export declare function windowChars(history: readonly LLMMessage[]): number;
86
+ //# sourceMappingURL=turns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turns.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/compaction/turns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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;;;;;;;;;GAeG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,kBAAkB,EACvB,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,GACrC,QAAQ,CAyCV;AAED,0EAA0E;AAC1E,wBAAgB,WAAW,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,MAAM,CAIlE"}
@@ -0,0 +1,149 @@
1
+ /**
2
+ * compaction/types — the public shape of `.compaction()` and the record it
3
+ * writes into the ledger.
4
+ *
5
+ * Pattern: Value objects (no behavior) + one resolved-config type.
6
+ * Role: core/ layer. The law this feature exists to keep is stated once,
7
+ * here, because every other file in this folder implements a piece
8
+ * of it: **compaction edits the WINDOW, never the LEDGER.**
9
+ * Emits: N/A (types only).
10
+ *
11
+ * The window is `scope.history` — the array `call-llm` hands the provider.
12
+ * The ledger is footprintjs's commit log, which is append-only: the turns a
13
+ * fold removes from the window were committed by `seed#0` / `tool-calls#N`
14
+ * BEFORE the fold and stay in those bundles byte-identical forever. A fold
15
+ * therefore cannot destroy history even in principle; it can only stop
16
+ * re-sending it. The summary is a CLAIM about the past, so it is filed as a
17
+ * claim — its own recorded step, naming every `runtimeStageId` it folded.
18
+ */
19
+ import type { LLMProvider } from '../../../adapters/types.js';
20
+ /**
21
+ * What `.compaction({...})` accepts.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const agent = Agent.create({ provider: anthropic(), model: 'claude-sonnet-4-5' })
26
+ * .compaction({
27
+ * thresholdTokens: 120_000,
28
+ * summarizer: anthropic(), // usually the cheap one
29
+ * model: 'claude-haiku-4-5',
30
+ * keepRecentTurns: 6,
31
+ * })
32
+ * .build();
33
+ * ```
34
+ */
35
+ export interface CompactionOptions {
36
+ /**
37
+ * Fold when the LAST call's adapter-reported input tokens exceed this.
38
+ *
39
+ * REQUIRED, with no default. A default budget here would be a number the
40
+ * library invented for a window whose size only the consumer's model and
41
+ * wallet know — and every run would silently inherit it.
42
+ */
43
+ readonly thresholdTokens: number;
44
+ /**
45
+ * How many of the most recent turns are never folded. Default 6.
46
+ *
47
+ * The recent turns are what the model is actually reasoning over; folding
48
+ * them is how a compacting agent loses the thread.
49
+ */
50
+ readonly keepRecentTurns?: number;
51
+ /**
52
+ * The provider that writes the summary. Explicitly chosen — the library
53
+ * never quietly bills your main model for compaction.
54
+ */
55
+ readonly summarizer: LLMProvider;
56
+ /**
57
+ * Model id for the summarizer call. Defaults to the agent's own model, so
58
+ * `summarizer: anthropic()` alone works; name a cheap model to spend less.
59
+ */
60
+ readonly model?: string;
61
+ }
62
+ /** Resolved form — defaults applied at build time, validated once. */
63
+ export interface ResolvedCompaction {
64
+ readonly thresholdTokens: number;
65
+ readonly keepRecentTurns: number;
66
+ readonly summarizer: LLMProvider;
67
+ readonly model: string | undefined;
68
+ }
69
+ /**
70
+ * Why a turn refused to fold. Every one of these is NAMED in the commit —
71
+ * a fold that took less than it could have has to say why, or the next
72
+ * person debugging an over-budget window has to guess.
73
+ */
74
+ export type FoldRefusalReason =
75
+ /** The turn holds a `role: 'system'` message. The envelope never folds. */
76
+ 'system-envelope'
77
+ /**
78
+ * An assistant `tool_use` in this turn has no matching `tool_result` in the
79
+ * window. Folding an unanswered question destroys the answer's referent —
80
+ * and the referent may still arrive (a paused run resumes).
81
+ */
82
+ | 'unresolved-tool-call'
83
+ /** The turn holds the tool call this run is currently paused on. */
84
+ | 'paused-tool'
85
+ /** The turn holds a tool call waiting on a human check-in decision. */
86
+ | 'pending-check-in'
87
+ /** Inside `keepRecentTurns` — the recent window is never a candidate. */
88
+ | 'inside-keep-window'
89
+ /**
90
+ * The only foldable candidate is a summary a previous fold wrote. Folding a
91
+ * summary of a summary with nothing new to add spends a call to lose detail.
92
+ */
93
+ | 'only-existing-summary'
94
+ /** The summarizer threw. No fold this iteration; the window stays big. */
95
+ | 'summarizer-failed'
96
+ /**
97
+ * The summary came back no smaller than the span it would replace, so the
98
+ * fold was abandoned. Measured in chars on both sides — the same unit, an
99
+ * exact comparison, not a token guess. Folding here would spend a call to
100
+ * make the window BIGGER and lose the detail as well.
101
+ */
102
+ | 'summary-not-smaller';
103
+ /** One named refusal, positioned so a reader can find the turn. */
104
+ export interface FoldRefusal {
105
+ readonly reason: FoldRefusalReason;
106
+ /** Index of the turn in this iteration's turn segmentation. */
107
+ readonly turnIndex: number;
108
+ /** Index of the turn's first message in the pre-fold window. */
109
+ readonly messageIndex: number;
110
+ }
111
+ /**
112
+ * What one visit to the compaction stage put in the ledger. Appended to
113
+ * `scope.compactions`, so the run's whole compaction story is one array in
114
+ * the commit log — including the visits that folded NOTHING, which are the
115
+ * interesting ones.
116
+ *
117
+ * On `windowChars*` vs tokens: the char counts are EXACT and measured here.
118
+ * There is deliberately no `tokensAfter` — nothing can count the tokens of a
119
+ * window that has not been sent yet, and inventing one would be exactly the
120
+ * guess this feature exists to refuse. The honest "after" is the NEXT call's
121
+ * `stream.llm_end` usage.
122
+ */
123
+ export interface CompactionRecord {
124
+ /** ReAct iteration this visit belongs to. */
125
+ readonly iteration: number;
126
+ /** Adapter-reported input tokens of the last call — what tripped the check. */
127
+ readonly measuredTokens: number;
128
+ /** The budget it was compared against. */
129
+ readonly thresholdTokens: number;
130
+ /** True when the measurement was over budget (a fold was attempted). */
131
+ readonly overBudget: boolean;
132
+ /** `runtimeStageId`s of the stages that appended the folded messages. */
133
+ readonly foldedStageIds: readonly string[];
134
+ /** How many messages left the window. */
135
+ readonly foldedMessageCount: number;
136
+ /** Window size in chars before / after this visit. Exact, and not tokens. */
137
+ readonly windowCharsBefore: number;
138
+ readonly windowCharsAfter: number;
139
+ /** Length of the summary text the summarizer produced (0 when none). */
140
+ readonly summaryChars: number;
141
+ /** What the summarizer call itself cost, when it reported usage. */
142
+ readonly summarizerTokens?: {
143
+ readonly input: number;
144
+ readonly output: number;
145
+ };
146
+ /** Every turn that refused to fold, named. */
147
+ readonly refusals: readonly FoldRefusal[];
148
+ }
149
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/compaction/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,sEAAsE;AACtE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB;AAC3B,2EAA2E;AACzE,iBAAiB;AACnB;;;;GAIG;GACD,sBAAsB;AACxB,oEAAoE;GAClE,aAAa;AACf,uEAAuE;GACrE,kBAAkB;AACpB,yEAAyE;GACvE,oBAAoB;AACtB;;;GAGG;GACD,uBAAuB;AACzB,0EAA0E;GACxE,mBAAmB;AACrB;;;;;GAKG;GACD,qBAAqB,CAAC;AAE1B,mEAAmE;AACnE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAA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