agentfootprint 7.15.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 (110) hide show
  1. package/dist/adapters/llm/BrowserOpenAIProvider.js +7 -3
  2. package/dist/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  3. package/dist/adapters/llm/OpenAIProvider.js +11 -3
  4. package/dist/adapters/llm/OpenAIProvider.js.map +1 -1
  5. package/dist/conventions.js +7 -0
  6. package/dist/conventions.js.map +1 -1
  7. package/dist/core/Agent.js +56 -2
  8. package/dist/core/Agent.js.map +1 -1
  9. package/dist/core/agent/AgentBuilder.js +86 -1
  10. package/dist/core/agent/AgentBuilder.js.map +1 -1
  11. package/dist/core/agent/buildAgentChart.js +12 -1
  12. package/dist/core/agent/buildAgentChart.js.map +1 -1
  13. package/dist/core/agent/buildDynamicAgentChart.js +10 -1
  14. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  15. package/dist/core/agent/compaction/errors.js +40 -0
  16. package/dist/core/agent/compaction/errors.js.map +1 -0
  17. package/dist/core/agent/compaction/index.js +24 -0
  18. package/dist/core/agent/compaction/index.js.map +1 -0
  19. package/dist/core/agent/compaction/strategy.js +152 -0
  20. package/dist/core/agent/compaction/strategy.js.map +1 -0
  21. package/dist/core/agent/compaction/summarize.js +103 -0
  22. package/dist/core/agent/compaction/summarize.js.map +1 -0
  23. package/dist/core/agent/compaction/turns.js +153 -0
  24. package/dist/core/agent/compaction/turns.js.map +1 -0
  25. package/dist/core/agent/compaction/types.js +21 -0
  26. package/dist/core/agent/compaction/types.js.map +1 -0
  27. package/dist/core/agent/stages/compact.js +130 -0
  28. package/dist/core/agent/stages/compact.js.map +1 -0
  29. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js +7 -3
  30. package/dist/esm/adapters/llm/BrowserOpenAIProvider.js.map +1 -1
  31. package/dist/esm/adapters/llm/OpenAIProvider.js +11 -3
  32. package/dist/esm/adapters/llm/OpenAIProvider.js.map +1 -1
  33. package/dist/esm/conventions.d.ts +7 -0
  34. package/dist/esm/conventions.js +7 -0
  35. package/dist/esm/conventions.js.map +1 -1
  36. package/dist/esm/core/Agent.d.ts +8 -1
  37. package/dist/esm/core/Agent.js +56 -2
  38. package/dist/esm/core/Agent.js.map +1 -1
  39. package/dist/esm/core/agent/AgentBuilder.d.ts +43 -0
  40. package/dist/esm/core/agent/AgentBuilder.js +86 -1
  41. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  42. package/dist/esm/core/agent/buildAgentChart.d.ts +13 -0
  43. package/dist/esm/core/agent/buildAgentChart.js +12 -1
  44. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  45. package/dist/esm/core/agent/buildDynamicAgentChart.js +10 -1
  46. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  47. package/dist/esm/core/agent/compaction/errors.d.ts +26 -0
  48. package/dist/esm/core/agent/compaction/errors.js +36 -0
  49. package/dist/esm/core/agent/compaction/errors.js.map +1 -0
  50. package/dist/esm/core/agent/compaction/index.d.ts +18 -0
  51. package/dist/esm/core/agent/compaction/index.js +18 -0
  52. package/dist/esm/core/agent/compaction/index.js.map +1 -0
  53. package/dist/esm/core/agent/compaction/strategy.d.ts +103 -0
  54. package/dist/esm/core/agent/compaction/strategy.js +148 -0
  55. package/dist/esm/core/agent/compaction/strategy.js.map +1 -0
  56. package/dist/esm/core/agent/compaction/summarize.d.ts +61 -0
  57. package/dist/esm/core/agent/compaction/summarize.js +96 -0
  58. package/dist/esm/core/agent/compaction/summarize.js.map +1 -0
  59. package/dist/esm/core/agent/compaction/turns.d.ts +85 -0
  60. package/dist/esm/core/agent/compaction/turns.js +145 -0
  61. package/dist/esm/core/agent/compaction/turns.js.map +1 -0
  62. package/dist/esm/core/agent/compaction/types.d.ts +148 -0
  63. package/dist/esm/core/agent/compaction/types.js +20 -0
  64. package/dist/esm/core/agent/compaction/types.js.map +1 -0
  65. package/dist/esm/core/agent/stages/compact.d.ts +59 -0
  66. package/dist/esm/core/agent/stages/compact.js +126 -0
  67. package/dist/esm/core/agent/stages/compact.js.map +1 -0
  68. package/dist/esm/core/agent/types.d.ts +11 -0
  69. package/dist/esm/index.d.ts +1 -0
  70. package/dist/esm/index.js +5 -0
  71. package/dist/esm/index.js.map +1 -1
  72. package/dist/esm/recorders/core/CompactionMeter.d.ts +78 -0
  73. package/dist/esm/recorders/core/CompactionMeter.js +101 -0
  74. package/dist/esm/recorders/core/CompactionMeter.js.map +1 -0
  75. package/dist/index.js +13 -5
  76. package/dist/index.js.map +1 -1
  77. package/dist/recorders/core/CompactionMeter.js +105 -0
  78. package/dist/recorders/core/CompactionMeter.js.map +1 -0
  79. package/dist/types/adapters/llm/BrowserOpenAIProvider.d.ts.map +1 -1
  80. package/dist/types/adapters/llm/OpenAIProvider.d.ts.map +1 -1
  81. package/dist/types/conventions.d.ts +7 -0
  82. package/dist/types/conventions.d.ts.map +1 -1
  83. package/dist/types/core/Agent.d.ts +8 -1
  84. package/dist/types/core/Agent.d.ts.map +1 -1
  85. package/dist/types/core/agent/AgentBuilder.d.ts +43 -0
  86. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  87. package/dist/types/core/agent/buildAgentChart.d.ts +13 -0
  88. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  89. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  90. package/dist/types/core/agent/compaction/errors.d.ts +27 -0
  91. package/dist/types/core/agent/compaction/errors.d.ts.map +1 -0
  92. package/dist/types/core/agent/compaction/index.d.ts +19 -0
  93. package/dist/types/core/agent/compaction/index.d.ts.map +1 -0
  94. package/dist/types/core/agent/compaction/strategy.d.ts +104 -0
  95. package/dist/types/core/agent/compaction/strategy.d.ts.map +1 -0
  96. package/dist/types/core/agent/compaction/summarize.d.ts +62 -0
  97. package/dist/types/core/agent/compaction/summarize.d.ts.map +1 -0
  98. package/dist/types/core/agent/compaction/turns.d.ts +86 -0
  99. package/dist/types/core/agent/compaction/turns.d.ts.map +1 -0
  100. package/dist/types/core/agent/compaction/types.d.ts +149 -0
  101. package/dist/types/core/agent/compaction/types.d.ts.map +1 -0
  102. package/dist/types/core/agent/stages/compact.d.ts +60 -0
  103. package/dist/types/core/agent/stages/compact.d.ts.map +1 -0
  104. package/dist/types/core/agent/types.d.ts +11 -0
  105. package/dist/types/core/agent/types.d.ts.map +1 -1
  106. package/dist/types/index.d.ts +1 -0
  107. package/dist/types/index.d.ts.map +1 -1
  108. package/dist/types/recorders/core/CompactionMeter.d.ts +79 -0
  109. package/dist/types/recorders/core/CompactionMeter.d.ts.map +1 -0
  110. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"buildAgentChart.d.ts","sourceRoot":"","sources":["../../../../src/core/agent/buildAgentChart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAc,MAAM,aAAa,CAAC;AAE5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAOxD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAUrE;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAE/C;;;8DAG0D;IAC1D,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,OAAO,yCAAyC,EAAE,WAAW,CAAC;IAEpG;uEACmE;IACnE,QAAQ,CAAC,uBAAuB,EAAE,WAAW,CAAC;IAE9C;kDAC8C;IAC9C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAG/B,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,O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,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEzD;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAE5B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAG3C;;;;0CAIsC;IACtC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,iBAAiB,EAAE,CAAC;CAC5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,CA4X/D"}
@@ -1 +1 @@
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,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,QAA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B;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;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sCAAsC;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,IAAI,EAAE,CAqB5E;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9C,8DAA8D;IAC9D,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,CAMnF;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,CAkB7F;AAED,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;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;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AQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;CAC3C"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * compact — the loop-head stage that keeps the window inside budget.
3
+ *
4
+ * Reads the last call's ADAPTER-REPORTED input tokens from the compaction
5
+ * meter and, when they exceed `thresholdTokens`, hands the window to a window
6
+ * strategy. Runs once per ReAct iteration boundary, as the loop target, so
7
+ * everything downstream in the turn — the injection engine's triggers, all
8
+ * three context slots, and the wire itself — sees ONE window. No component
9
+ * gets a different past than the model does.
10
+ *
11
+ * The law: **it edits the window, never the ledger.** The turns a fold removes
12
+ * were committed by `seed#0` / `tool-calls#N` before this stage ran and stay
13
+ * in those bundles byte-identical; footprintjs's commit log is append-only, so
14
+ * a fold cannot erase history even in principle. What it can do is stop
15
+ * re-sending it — and say so, in its own commit, naming every runtimeStageId
16
+ * it folded. A compacted run is still a provable run.
17
+ *
18
+ * This file is deliberately all WIRING. The decision — what the window should
19
+ * become — lives behind `WindowStrategy` (compaction/strategy.ts, internal),
20
+ * so the duty to record, emit and cost what happened stays in exactly one
21
+ * place instead of being re-implemented per strategy. `.compaction()` is the
22
+ * only strategy that ships.
23
+ *
24
+ * Emits (existing vocabulary only — no new event types):
25
+ * agentfootprint.context.evicted — one per message leaving the window
26
+ * agentfootprint.context.budget_pressure — one per over-budget visit
27
+ * agentfootprint.cost.tick — when a pricingTable is set: the
28
+ * summarizer's call is a real
29
+ * billed call and counts
30
+ *
31
+ * The summarizer call is deliberately NOT bracketed with
32
+ * `stream.llm_start` / `llm_end`: those carry an `iteration` and every
33
+ * consumer pairs them by it, so a second bracket inside one iteration would
34
+ * corrupt the pairing. Its cost rides the cost channel and its tokens are
35
+ * recorded in the commit instead.
36
+ */
37
+ import type { TypedScope } from 'footprintjs';
38
+ import type { PricingTable } from '../../../adapters/types.js';
39
+ import type { CompactionMeterHandle } from '../../../recorders/core/CompactionMeter.js';
40
+ import type { ResolvedCompaction } from '../compaction/types.js';
41
+ import type { AgentState } from '../types.js';
42
+ export interface CompactStageDeps {
43
+ /** Resolved `.compaction()` config (defaults already applied). */
44
+ readonly config: ResolvedCompaction;
45
+ /** The meter this stage reads. Attached inline by `Agent.createExecutor`. */
46
+ readonly meter: CompactionMeterHandle;
47
+ /** The agent's own model — the summarizer's default. */
48
+ readonly defaultModel: string;
49
+ /** The MAIN provider's name, for the unmeasurable refusal. */
50
+ readonly providerName: string;
51
+ /** Optional pricing adapter, so a summarizer call is costed like any other. */
52
+ readonly pricingTable?: PricingTable;
53
+ /** Optional cumulative USD cap per run. */
54
+ readonly costBudget?: number;
55
+ /** Injectable clock (tests pin survivalMs). */
56
+ readonly now?: () => number;
57
+ }
58
+ /** Build the compaction stage function. */
59
+ export declare function buildCompactStage(deps: CompactStageDeps): (scope: TypedScope<AgentState>) => Promise<void>;
60
+ //# sourceMappingURL=compact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../../../src/core/agent/stages/compact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAOxF,OAAO,KAAK,EAAoB,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,wDAAwD;IACxD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;IACrC,2CAA2C;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,GACrB,CAAC,KAAK,EAAE,UAAU,CAAC,UAAU,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CA8FlD"}
@@ -18,6 +18,7 @@ import type { CredentialProvider } from '../../identity/types.js';
18
18
  import type { ToolArgValidationMode } from './toolArgsValidation.js';
19
19
  import type { ThinkingBlock } from '../../thinking/types.js';
20
20
  import type { ReliabilityScope } from '../../reliability/types.js';
21
+ import type { CompactionRecord } from './compaction/types.js';
21
22
  /**
22
23
  * Dials for the deferred observer queue (RFC-001) — only meaningful with
23
24
  * `observerDelivery: 'deferred'` (passing them without it throws at
@@ -407,6 +408,16 @@ export interface AgentState {
407
408
  /** The base system prompt `.configure()` resolved for THIS run, replacing
408
409
  * `.system(...)`. Same rule: absent unless a resolver returned one. */
409
410
  resolvedInstructions?: string;
411
+ /** One record per OVER-BUDGET visit to the compaction stage — including the
412
+ * visits that folded nothing, which are the interesting ones. Written only
413
+ * by an agent built with `.compaction()`; absent otherwise, so an agent
414
+ * without it commits exactly the keys it always did.
415
+ *
416
+ * This array is the fold's half of the law: the window shrank, and the
417
+ * ledger says which stages' messages left it, how many, and what the last
418
+ * call actually measured. The messages themselves are untouched in the
419
+ * commit bundles that wrote them. */
420
+ compactions?: readonly CompactionRecord[];
410
421
  /** Set when a `PermissionChecker` returns `{ result: 'halt', ... }`.
411
422
  * `Agent.run()` reads these at the API boundary and throws a typed
412
423
  * `PolicyHaltError` carrying the same context — the chart $break's
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["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AAC,CAAC,CAAC;IACnD,yCAAyC;IACzC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,kEAAkE;IAClE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAG7B;;;6EAGyE;IACzE,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;0CAIsC;IACtC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;IAGzC;;;;;;iFAM6E;IAC7E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,gBAAgB,CAAC,aAAa,CAAC,CAAC;IACzD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;kEAC8D;IAC9D,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC"}
@@ -27,6 +27,7 @@ export { LLMCall, LLMCallBuilder, type LLMCallInput, type LLMCallOptions, type L
27
27
  export { type MessageApiChartDeps } from './core/agent/buildMessageApiChart.js';
28
28
  export { buildAgentMessageApiChart, type AgentMessageApiChartDeps, } from './core/agent/buildAgentMessageApiChart.js';
29
29
  export { Agent, AgentBuilder, type AgentInput, type AgentOptions, type AgentOutput, type ObserverDeliveryOptions, } from './core/Agent.js';
30
+ export { CompactionUnmeasurableError, COMPACTED_FRAME_PREFIX, isCompactedSummary, type CompactionOptions, type CompactionRecord, type FoldRefusal, type FoldRefusalReason, } from './core/agent/compaction/index.js';
30
31
  export type { SelfExplainOptions } from './lib/trace-toolpack/selfExplain.js';
31
32
  export type { ObserverDrainResult, ObserverStats } from 'footprintjs';
32
33
  export type { ToolArgValidationMode } from './core/agent/toolArgsValidation.js';