agentfootprint 8.1.0 → 8.3.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 (136) hide show
  1. package/AGENTS.md +1 -1
  2. package/CLAUDE.md +3 -2
  3. package/ai-instructions/claude-code/SKILL.md +1 -1
  4. package/dist/core/Agent.js +44 -1
  5. package/dist/core/Agent.js.map +1 -1
  6. package/dist/core/agent/buildAgentChart.js +3 -0
  7. package/dist/core/agent/buildAgentChart.js.map +1 -1
  8. package/dist/core/agent/buildDynamicAgentChart.js +6 -0
  9. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  10. package/dist/core/agent/stages/seed.js +12 -0
  11. package/dist/core/agent/stages/seed.js.map +1 -1
  12. package/dist/core/agent/stages/toolCalls.js +21 -0
  13. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  14. package/dist/core/agent/stages/window.js +21 -0
  15. package/dist/core/agent/stages/window.js.map +1 -1
  16. package/dist/core/agent/window/folded.js +98 -0
  17. package/dist/core/agent/window/folded.js.map +1 -0
  18. package/dist/core/agent/window/index.js +9 -1
  19. package/dist/core/agent/window/index.js.map +1 -1
  20. package/dist/core/agent/window/options.js +18 -2
  21. package/dist/core/agent/window/options.js.map +1 -1
  22. package/dist/core/agent/window/strategies/summarizeOldest.js +25 -2
  23. package/dist/core/agent/window/strategies/summarizeOldest.js.map +1 -1
  24. package/dist/core/agent/window/summarize.js +27 -1
  25. package/dist/core/agent/window/summarize.js.map +1 -1
  26. package/dist/core/agent/window/types.js +6 -0
  27. package/dist/core/agent/window/types.js.map +1 -1
  28. package/dist/core/runCheckpoint.js +9 -1
  29. package/dist/core/runCheckpoint.js.map +1 -1
  30. package/dist/esm/core/Agent.d.ts +17 -0
  31. package/dist/esm/core/Agent.js +44 -1
  32. package/dist/esm/core/Agent.js.map +1 -1
  33. package/dist/esm/core/agent/buildAgentChart.js +3 -0
  34. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  35. package/dist/esm/core/agent/buildDynamicAgentChart.js +6 -0
  36. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  37. package/dist/esm/core/agent/stages/seed.d.ts +11 -0
  38. package/dist/esm/core/agent/stages/seed.js +12 -0
  39. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  40. package/dist/esm/core/agent/stages/toolCalls.js +21 -0
  41. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  42. package/dist/esm/core/agent/stages/window.d.ts +13 -0
  43. package/dist/esm/core/agent/stages/window.js +21 -0
  44. package/dist/esm/core/agent/stages/window.js.map +1 -1
  45. package/dist/esm/core/agent/types.d.ts +22 -1
  46. package/dist/esm/core/agent/window/folded.d.ts +90 -0
  47. package/dist/esm/core/agent/window/folded.js +92 -0
  48. package/dist/esm/core/agent/window/folded.js.map +1 -0
  49. package/dist/esm/core/agent/window/index.d.ts +7 -1
  50. package/dist/esm/core/agent/window/index.js +6 -0
  51. package/dist/esm/core/agent/window/index.js.map +1 -1
  52. package/dist/esm/core/agent/window/options.d.ts +7 -1
  53. package/dist/esm/core/agent/window/options.js +17 -1
  54. package/dist/esm/core/agent/window/options.js.map +1 -1
  55. package/dist/esm/core/agent/window/strategies/summarizeOldest.d.ts +4 -2
  56. package/dist/esm/core/agent/window/strategies/summarizeOldest.js +25 -2
  57. package/dist/esm/core/agent/window/strategies/summarizeOldest.js.map +1 -1
  58. package/dist/esm/core/agent/window/strategy.d.ts +26 -1
  59. package/dist/esm/core/agent/window/summarize.d.ts +11 -0
  60. package/dist/esm/core/agent/window/summarize.js +27 -1
  61. package/dist/esm/core/agent/window/summarize.js.map +1 -1
  62. package/dist/esm/core/agent/window/types.d.ts +106 -1
  63. package/dist/esm/core/agent/window/types.js +6 -0
  64. package/dist/esm/core/agent/window/types.js.map +1 -1
  65. package/dist/esm/core/runCheckpoint.d.ts +32 -1
  66. package/dist/esm/core/runCheckpoint.js +9 -1
  67. package/dist/esm/core/runCheckpoint.js.map +1 -1
  68. package/dist/esm/events/payloads.d.ts +19 -0
  69. package/dist/esm/events/registry.d.ts +3 -1
  70. package/dist/esm/events/registry.js +2 -0
  71. package/dist/esm/events/registry.js.map +1 -1
  72. package/dist/esm/index.d.ts +1 -1
  73. package/dist/esm/index.js +6 -1
  74. package/dist/esm/index.js.map +1 -1
  75. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +21 -1
  76. package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  77. package/dist/esm/lib/injection-engine/skillGraph.d.ts +19 -8
  78. package/dist/esm/lib/injection-engine/skillGraph.js +99 -29
  79. package/dist/esm/lib/injection-engine/skillGraph.js.map +1 -1
  80. package/dist/esm/lib/injection-engine/types.d.ts +14 -0
  81. package/dist/esm/lib/injection-engine/types.js.map +1 -1
  82. package/dist/esm/tool-providers/skillScopedTools.d.ts +24 -17
  83. package/dist/esm/tool-providers/skillScopedTools.js +24 -17
  84. package/dist/esm/tool-providers/skillScopedTools.js.map +1 -1
  85. package/dist/events/registry.js +2 -0
  86. package/dist/events/registry.js.map +1 -1
  87. package/dist/index.js +9 -2
  88. package/dist/index.js.map +1 -1
  89. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +21 -1
  90. package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
  91. package/dist/lib/injection-engine/skillGraph.js +99 -29
  92. package/dist/lib/injection-engine/skillGraph.js.map +1 -1
  93. package/dist/lib/injection-engine/types.js.map +1 -1
  94. package/dist/tool-providers/skillScopedTools.js +24 -17
  95. package/dist/tool-providers/skillScopedTools.js.map +1 -1
  96. package/dist/types/core/Agent.d.ts +17 -0
  97. package/dist/types/core/Agent.d.ts.map +1 -1
  98. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  99. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  100. package/dist/types/core/agent/stages/seed.d.ts +11 -0
  101. package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
  102. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  103. package/dist/types/core/agent/stages/window.d.ts +13 -0
  104. package/dist/types/core/agent/stages/window.d.ts.map +1 -1
  105. package/dist/types/core/agent/types.d.ts +22 -1
  106. package/dist/types/core/agent/types.d.ts.map +1 -1
  107. package/dist/types/core/agent/window/folded.d.ts +91 -0
  108. package/dist/types/core/agent/window/folded.d.ts.map +1 -0
  109. package/dist/types/core/agent/window/index.d.ts +7 -1
  110. package/dist/types/core/agent/window/index.d.ts.map +1 -1
  111. package/dist/types/core/agent/window/options.d.ts +7 -1
  112. package/dist/types/core/agent/window/options.d.ts.map +1 -1
  113. package/dist/types/core/agent/window/strategies/summarizeOldest.d.ts +4 -2
  114. package/dist/types/core/agent/window/strategies/summarizeOldest.d.ts.map +1 -1
  115. package/dist/types/core/agent/window/strategy.d.ts +26 -1
  116. package/dist/types/core/agent/window/strategy.d.ts.map +1 -1
  117. package/dist/types/core/agent/window/summarize.d.ts +11 -0
  118. package/dist/types/core/agent/window/summarize.d.ts.map +1 -1
  119. package/dist/types/core/agent/window/types.d.ts +106 -1
  120. package/dist/types/core/agent/window/types.d.ts.map +1 -1
  121. package/dist/types/core/runCheckpoint.d.ts +32 -1
  122. package/dist/types/core/runCheckpoint.d.ts.map +1 -1
  123. package/dist/types/events/payloads.d.ts +19 -0
  124. package/dist/types/events/payloads.d.ts.map +1 -1
  125. package/dist/types/events/registry.d.ts +3 -1
  126. package/dist/types/events/registry.d.ts.map +1 -1
  127. package/dist/types/index.d.ts +1 -1
  128. package/dist/types/index.d.ts.map +1 -1
  129. package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
  130. package/dist/types/lib/injection-engine/skillGraph.d.ts +19 -8
  131. package/dist/types/lib/injection-engine/skillGraph.d.ts.map +1 -1
  132. package/dist/types/lib/injection-engine/types.d.ts +14 -0
  133. package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
  134. package/dist/types/tool-providers/skillScopedTools.d.ts +24 -17
  135. package/dist/types/tool-providers/skillScopedTools.d.ts.map +1 -1
  136. package/package.json +1 -1
@@ -10,14 +10,17 @@
10
10
  * This is what `.compaction({...})` configures, and the market's familiar
11
11
  * move (Claude Code / the Claude Agent SDK call it compaction). What is
12
12
  * different here is not the fold — it is that the fold is filed as a claim:
13
- * a summary is a claim ABOUT the past, and the past itself stays in the
14
- * commit log, byte for byte.
13
+ * a summary is a claim ABOUT the past, and the past itself stays. In the
14
+ * commit log for as long as the process lives, and — since 8.2, under
15
+ * `retain: 'conversation'` — on the conversation checkpoint for as long as
16
+ * the conversation does, which is the half a standing agent actually needs.
15
17
  *
16
18
  * Everything it decides, it explains. Every engaged path returns a record —
17
19
  * including the paths that change nothing, which are the ones a person
18
20
  * debugging an over-budget window actually needs.
19
21
  */
20
22
  import { CompactionUnmeasurableError } from '../errors.js';
23
+ import { summaryFingerprint } from '../folded.js';
21
24
  import { resolveCompactionOptions } from '../options.js';
22
25
  import { indexRange } from '../removal.js';
23
26
  import { buildSummaryMessage, isCompactedSummary, runSummarizer } from '../summarize.js';
@@ -122,6 +125,7 @@ export function summarizeOldest(options) {
122
125
  foldedMessageCount: span.length,
123
126
  iteration,
124
127
  model,
128
+ retain: config.retain,
125
129
  });
126
130
  const spend = { model, usage: summary.usage };
127
131
  // Would the fold actually help? A summary plus its authored frame can be
@@ -140,6 +144,24 @@ export function summarizeOldest(options) {
140
144
  const foldedAtMs = input.now();
141
145
  const facts = input.removalFacts(indexRange(spanStart, spanEnd), foldedAtMs);
142
146
  const window = [...head, summaryMessage, ...tail];
147
+ // The durable half. It rides the SAME result the window change rides,
148
+ // so the stage commits both together — there is no ordering in which
149
+ // the messages leave and the record of what they were does not follow.
150
+ // Under 'discard' the span is still filed: a discard is an absence, and
151
+ // this family files absences the same way it files claims.
152
+ const foldedSpan = {
153
+ summaryFingerprint: summaryFingerprint(summaryMessage.content),
154
+ runId: input.runId,
155
+ iteration,
156
+ foldedAtMs,
157
+ model,
158
+ messageCount: span.length,
159
+ removedStageIds: facts.removedStageIds,
160
+ retained: config.retain,
161
+ // Detached before it is handed on: `history` came off a live scope and
162
+ // a stored conversation must never hold a reference into the heap.
163
+ ...(config.retain === 'conversation' && { messages: span.map((m) => ({ ...m })) }),
164
+ };
143
165
  const record = {
144
166
  ...base,
145
167
  removedStageIds: facts.removedStageIds,
@@ -161,6 +183,7 @@ export function summarizeOldest(options) {
161
183
  },
162
184
  record,
163
185
  evictions: facts.evictions,
186
+ folded: [foldedSpan],
164
187
  budgetPressure: {
165
188
  capTokens: config.thresholdTokens,
166
189
  projectedTokens: measured.input,
@@ -1 +1 @@
1
- {"version":3,"file":"summarizeOldest.js","sourceRoot":"","sources":["../../../../../../src/core/agent/window/strategies/summarizeOldest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,eAAe,CAAC,OAA0B;IACxD,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;IAEpE,OAAO;QACL,IAAI,EAAE,gBAAgB;QAEtB,KAAK,CAAC,IAAI,CAAC,KAA0B;YACnC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;YAEtD,qEAAqE;YACrE,+CAA+C;YAC/C,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,S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AE,KAAK,CAAC,eAAe;gBACtC,mBAAmB,EAAE,IAAI,CAAC,MAAM;gBAChC,gEAAgE;gBAChE,cAAc,EAAE,KAAK,CAAC,eAAe;gBACrC,kBAAkB,EAAE,IAAI,CAAC,MAAM;gBAC/B,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC;gBACrC,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,MAAM;gBAC3C,gBAAgB,EAAE,OAAO,CAAC,KAAK;gBAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC;YAEF,OAAO;gBACL,MAAM;gBACN,MAAM,EAAE;oBACN,SAAS,EAAE,IAAI,CAAC,MAAM;oBACtB,aAAa,EAAE,IAAI,CAAC,MAAM;oBAC1B,YAAY,EAAE,UAAU;iBACzB;gBACD,MAAM;gBACN,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,cAAc,EAAE;oBACd,SAAS,EAAE,MAAM,CAAC,eAAe;oBACjC,eAAe,EAAE,QAAQ,CAAC,KAAK;oBAC/B,UAAU,EAAE,WAAW;iBACxB;gBACD,KAAK;aACN,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"summarizeOldest.js","sourceRoot":"","sources":["../../../../../../src/core/agent/window/strategies/summarizeOldest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,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,EAAE,cAAc,CAAC,OAAO,CAAC,MAAM;gBAC3C,gBAAgB,EAAE,OAAO,CAAC,KAAK;gBAC/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;aACxB,CAAC;YAEF,OAAO;gBACL,MAAM;gBACN,MAAM,EAAE;oBACN,SAAS,EAAE,IAAI,CAAC,MAAM;oBACtB,aAAa,EAAE,IAAI,CAAC,MAAM;oBAC1B,YAAY,EAAE,UAAU;iBACzB;gBACD,MAAM;gBACN,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,MAAM,EAAE,CAAC,UAAU,CAAC;gBACpB,cAAc,EAAE;oBACd,SAAS,EAAE,MAAM,CAAC,eAAe;oBACjC,eAAe,EAAE,QAAQ,CAAC,KAAK;oBAC/B,UAAU,EAAE,WAAW;iBACxB;gBACD,KAAK;aACN,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -39,7 +39,7 @@
39
39
  */
40
40
  import type { LLMMessage } from '../../../adapters/types.js';
41
41
  import type { Turn, RemovalPlan } from './turns.js';
42
- import type { WindowRecord } from './types.js';
42
+ import type { FoldedSpan, WindowRecord } from './types.js';
43
43
  /** One message leaving the window, with the facts an eviction event needs. */
44
44
  export interface WindowEviction {
45
45
  /** Index in the PRE-change window — the index the content hash was built on. */
@@ -76,6 +76,16 @@ export interface WindowStrategyInput {
76
76
  } | undefined;
77
77
  /** The ReAct iteration this decision belongs to. */
78
78
  readonly iteration: number;
79
+ /**
80
+ * The run this decision belongs to.
81
+ *
82
+ * A strategy that retains what it removed has to name the run whose commit
83
+ * log held it — that is the honest answer to "where else could I have found
84
+ * this?", and the answer is "nowhere, once that process ended", which is the
85
+ * whole reason retention exists. `'unknown'` when the runtime could not name
86
+ * the run, never a fabricated id.
87
+ */
88
+ readonly runId: string;
79
89
  /** The agent's own model — the sensible default for a strategy that bills. */
80
90
  readonly agentModel: string;
81
91
  /** `provider.name` of the MAIN provider, for a refusal that names it. */
@@ -128,6 +138,21 @@ export interface WindowStrategyResult {
128
138
  readonly record: WindowRecord;
129
139
  /** Messages that left the window, for `context.evicted`. */
130
140
  readonly evictions: readonly WindowEviction[];
141
+ /**
142
+ * Spans this visit removed, in the form that OUTLIVES the process: appended
143
+ * to the conversation checkpoint, so a restart can still say what a summary
144
+ * stands for — and, under `retain: 'conversation'`, produce it verbatim.
145
+ *
146
+ * OMIT IT unless your strategy replaced messages with something that stands
147
+ * for them. `summarizeOldest` fills it because a summary is a claim that
148
+ * needs its evidence; the drop strategies do not, because a drop replaces
149
+ * nothing and its authored notice claims nothing.
150
+ *
151
+ * The stage writes these in the SAME commit as the window change, so there
152
+ * is no state in which messages left the window and the record of what they
153
+ * were did not follow them.
154
+ */
155
+ readonly folded?: readonly FoldedSpan[];
131
156
  /**
132
157
  * The budget reading to report on `agentfootprint.context.budget_pressure`.
133
158
  *
@@ -17,9 +17,15 @@
17
17
  *
18
18
  * The frame is authored. The summary is data. Neither can become
19
19
  * the other.
20
+ *
21
+ * A third rule joined them in 8.2: the frame may only claim what is
22
+ * true. It names where the folded messages went, and it reads that
23
+ * from the resolved retention policy rather than asserting a
24
+ * constant — see {@link retentionSentence}.
20
25
  * Emits: N/A (the stage emits; this file only builds and calls).
21
26
  */
22
27
  import type { LLMMessage, LLMProvider, LLMResponse } from '../../../adapters/types.js';
28
+ import type { CompactionRetention } from './types.js';
23
29
  /** Opening of the authored label. Stable — tests and readers match on it. */
24
30
  export declare const COMPACTED_FRAME_PREFIX = "[compacted history";
25
31
  /**
@@ -39,11 +45,16 @@ export declare function renderTranscript(messages: readonly LLMMessage[]): strin
39
45
  * The label is written by this function and always comes first. `summary` is
40
46
  * appended to it verbatim: the library never edits model output, and it never
41
47
  * lets model output speak in the library's voice either.
48
+ *
49
+ * The label states the retention policy, and states it truthfully — see
50
+ * {@link retentionSentence}. `COMPACTED_FRAME_PREFIX` is unchanged: it is what
51
+ * every reader and every test matches on, and it stays put.
42
52
  */
43
53
  export declare function buildSummaryMessage(summary: string, facts: {
44
54
  readonly foldedMessageCount: number;
45
55
  readonly iteration: number;
46
56
  readonly model: string;
57
+ readonly retain: CompactionRetention;
47
58
  }): LLMMessage;
48
59
  /** True when this message is a frame a previous fold wrote. */
49
60
  export declare function isCompactedSummary(msg: LLMMessage | undefined): boolean;
@@ -17,6 +17,11 @@
17
17
  *
18
18
  * The frame is authored. The summary is data. Neither can become
19
19
  * the other.
20
+ *
21
+ * A third rule joined them in 8.2: the frame may only claim what is
22
+ * true. It names where the folded messages went, and it reads that
23
+ * from the resolved retention policy rather than asserting a
24
+ * constant — see {@link retentionSentence}.
20
25
  * Emits: N/A (the stage emits; this file only builds and calls).
21
26
  */
22
27
  /** Opening of the authored label. Stable — tests and readers match on it. */
@@ -56,6 +61,23 @@ function renderMessage(msg) {
56
61
  export function renderTranscript(messages) {
57
62
  return [TRANSCRIPT_OPEN, ...messages.map(renderMessage), TRANSCRIPT_CLOSE].join('\n');
58
63
  }
64
+ /**
65
+ * Where the folded messages went, said in the frame itself.
66
+ *
67
+ * Through 8.1 this sentence was a constant: *"The folded messages are retained
68
+ * verbatim in this run's commit log."* True inside the process, and false the
69
+ * moment the run ended — which is exactly when a standing agent reads it back
70
+ * out of storage. A library asserting something false inside the model's own
71
+ * context is worse than saying nothing, so the sentence is now written FROM
72
+ * the resolved retention policy and can only say what actually happened.
73
+ */
74
+ function retentionSentence(retain) {
75
+ return retain === 'conversation'
76
+ ? `The folded messages are retained verbatim with this conversation and can be produced ` +
77
+ `on request.`
78
+ : `The folded messages were not retained beyond the run that folded them; only this ` +
79
+ `summary carries them forward.`;
80
+ }
59
81
  /**
60
82
  * Build the message that replaces the folded span IN THE WINDOW.
61
83
  *
@@ -65,12 +87,16 @@ export function renderTranscript(messages) {
65
87
  * The label is written by this function and always comes first. `summary` is
66
88
  * appended to it verbatim: the library never edits model output, and it never
67
89
  * lets model output speak in the library's voice either.
90
+ *
91
+ * The label states the retention policy, and states it truthfully — see
92
+ * {@link retentionSentence}. `COMPACTED_FRAME_PREFIX` is unchanged: it is what
93
+ * every reader and every test matches on, and it stays put.
68
94
  */
69
95
  export function buildSummaryMessage(summary, facts) {
70
96
  const label = `${COMPACTED_FRAME_PREFIX} — ${facts.foldedMessageCount} earlier message(s) were folded ` +
71
97
  `out of this window at iteration ${facts.iteration}. The text after this line is a SUMMARY ` +
72
98
  `written by ${facts.model}; it is a claim about the conversation, not the conversation. ` +
73
- `The folded messages are retained verbatim in this run's commit log.]`;
99
+ `${retentionSentence(facts.retain)}]`;
74
100
  return { role: 'user', content: `${label}\n\n${summary}` };
75
101
  }
76
102
  /** True when this message is a frame a previous fold wrote. */
@@ -1 +1 @@
1
- {"version":3,"file":"summarize.js","sourceRoot":"","sources":["../../../../../src/core/agent/window/summarize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAE3D,kFAAkF;AAClF,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,wFAAwF;IACxF,kCAAkC;IAClC,EAAE;IACF,kCAAkC,eAAe,QAAQ,gBAAgB,sBAAsB;IAC/F,8FAA8F;IAC9F,6FAA6F;IAC7F,EAAE;IACF,4FAA4F;IAC5F,6FAA6F;IAC7F,gGAAgG;IAChG,yEAAyE;CAC1E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,+EAA+E;AAC/E,SAAS,aAAa,CAAC,GAAe;IACpC,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,MAAM,IAAI,GAC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AC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;AACpG,CAAC;AAOD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAqB,EACrB,KAAa,EACb,IAA2B,EAC3B,MAA+B;IAE/B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC;QACvC,YAAY,EAAE,wBAAwB;QACtC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC7D,KAAK;QACL,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;KACxC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC3D,CAAC"}
@@ -17,8 +17,14 @@
17
17
  * filed as a claim — its own recorded step, naming every `runtimeStageId` it
18
18
  * folded. A drop is an ABSENCE, and it is filed the same way: the record and
19
19
  * the eviction events name what left, by id.
20
+ *
21
+ * That law holds for as long as the PROCESS holds — a commit log is memory.
22
+ * A conversation outlives its process, so the durable half of the same law
23
+ * lives on the conversation checkpoint: `.compaction({ retain })` carries the
24
+ * folded originals there, beside the summary that stands for them. See
25
+ * {@link CompactionRetention} and {@link FoldedSpan}.
20
26
  */
21
- import type { LLMProvider } from '../../../adapters/types.js';
27
+ import type { LLMMessage, LLMProvider } from '../../../adapters/types.js';
22
28
  /**
23
29
  * Why a turn refused to leave the window. Every one of these is NAMED in the
24
30
  * commit — a removal that took less than it could have has to say why, or the
@@ -169,6 +175,87 @@ export interface TokenBudgetRecord extends WindowRecord {
169
175
  /** How many recent turns were off-limits to this visit. */
170
176
  readonly keepRecentTurns: number;
171
177
  }
178
+ /**
179
+ * What becomes of the messages a fold removes from the window.
180
+ *
181
+ * The commit log keeps them for as long as the PROCESS keeps them, and that
182
+ * is the whole of what 8.1 offered. A standing agent outlives its process, so
183
+ * "the folded turns are still in the commit log" stops being true the moment
184
+ * the run ends — and the summary sitting in the restored conversation went on
185
+ * claiming otherwise. Retention is the fix: the originals ride with the
186
+ * CONVERSATION, which is the thing that actually survives.
187
+ *
188
+ * The trade is stated rather than hidden: **compaction shrinks the wire, not
189
+ * the record.** A stored session grows as it folds. That is the right way
190
+ * round — the model's context window is scarce and a session row is not.
191
+ */
192
+ export type CompactionRetention =
193
+ /**
194
+ * The folded messages ride with the conversation checkpoint, so a restart —
195
+ * a new process, a new machine, a deploy — can still produce them verbatim.
196
+ * The default: originals are never destroyed unless you say so.
197
+ */
198
+ 'conversation'
199
+ /**
200
+ * The folded messages are NOT carried forward. The span is still recorded,
201
+ * naming what left and how much of it, because a discard is an absence and
202
+ * this family files absences the same way it files claims. Choose it when
203
+ * the conversation is the only thing you want to keep and the storage cost
204
+ * of the transcript is not worth paying.
205
+ */
206
+ | 'discard';
207
+ /**
208
+ * One fold, as it survives the process: the summary's fingerprint, what it
209
+ * stands for, and — under `retain: 'conversation'` — the messages themselves.
210
+ *
211
+ * These accumulate on the conversation checkpoint across every turn and every
212
+ * restart, so a standing agent that folded week one in April can still produce
213
+ * week one in July.
214
+ *
215
+ * ## Joining a span to its summary
216
+ *
217
+ * By CONTENT FINGERPRINT, never by index: a later fold can swallow an earlier
218
+ * summary, and every index in the window moves when it does. {@link
219
+ * foldedSpanFor} does the join for you.
220
+ */
221
+ export interface FoldedSpan {
222
+ /**
223
+ * Fingerprint of the summary message this span was folded into — the join
224
+ * key back to the message sitting in `history`.
225
+ *
226
+ * It is a hash of the message's full content (authored frame included), so
227
+ * it costs no extra bytes on the wire and cannot be forged by a summary that
228
+ * merely copies the frame's opening words: different content, different
229
+ * fingerprint, no match.
230
+ */
231
+ readonly summaryFingerprint: string;
232
+ /**
233
+ * The run whose commit log held these messages. Diagnostic, and the honest
234
+ * answer to "where else could I have found this?" — that log is gone with
235
+ * the process, which is why the messages are here.
236
+ */
237
+ readonly runId: string;
238
+ /** ReAct iteration the fold happened at, in that run. */
239
+ readonly iteration: number;
240
+ /** Wall clock of the fold. */
241
+ readonly foldedAtMs: number;
242
+ /** The model that wrote the summary — a claim's author is part of the claim. */
243
+ readonly model: string;
244
+ /** How many messages the summary stands for. Always recorded, both policies. */
245
+ readonly messageCount: number;
246
+ /** `runtimeStageId`s of the stages that appended those messages. */
247
+ readonly removedStageIds: readonly string[];
248
+ /** Which policy this fold ran under. */
249
+ readonly retained: CompactionRetention;
250
+ /**
251
+ * The folded messages, verbatim and in order. Present exactly when
252
+ * `retained` is `'conversation'`.
253
+ *
254
+ * Absent under `'discard'` — and absent is the honest shape there, rather
255
+ * than an empty array that reads like "there were none".
256
+ */
257
+ readonly messages?: readonly LLMMessage[];
258
+ }
172
259
  /**
173
260
  * What `.compaction({...})` — and `summarizeOldest({...})` — accepts.
174
261
  *
@@ -210,6 +297,23 @@ export interface CompactionOptions {
210
297
  * `summarizer: anthropic()` alone works; name a cheap model to spend less.
211
298
  */
212
299
  readonly model?: string;
300
+ /**
301
+ * What happens to the messages a fold removes. Default `'conversation'` —
302
+ * they ride with the conversation checkpoint and survive the process.
303
+ *
304
+ * Pass `'discard'` to opt out. Nothing is ever destroyed silently: the only
305
+ * way to lose the originals is to name this.
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * .compaction({
310
+ * thresholdTokens: 120_000,
311
+ * summarizer: anthropic(),
312
+ * retain: 'conversation', // the default, spelled out
313
+ * })
314
+ * ```
315
+ */
316
+ readonly retain?: CompactionRetention;
213
317
  }
214
318
  /** Resolved form — defaults applied at build time, validated once. */
215
319
  export interface ResolvedCompaction {
@@ -217,6 +321,7 @@ export interface ResolvedCompaction {
217
321
  readonly keepRecentTurns: number;
218
322
  readonly summarizer: LLMProvider;
219
323
  readonly model: string | undefined;
324
+ readonly retain: CompactionRetention;
220
325
  }
221
326
  /**
222
327
  * What `slidingWindow({...})` accepts.
@@ -17,6 +17,12 @@
17
17
  * filed as a claim — its own recorded step, naming every `runtimeStageId` it
18
18
  * folded. A drop is an ABSENCE, and it is filed the same way: the record and
19
19
  * the eviction events name what left, by id.
20
+ *
21
+ * That law holds for as long as the PROCESS holds — a commit log is memory.
22
+ * A conversation outlives its process, so the durable half of the same law
23
+ * lives on the conversation checkpoint: `.compaction({ retain })` carries the
24
+ * folded originals there, beside the summary that stands for them. See
25
+ * {@link CompactionRetention} and {@link FoldedSpan}.
20
26
  */
21
27
  export {};
22
28
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/core/agent/window/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/core/agent/window/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG"}
@@ -54,6 +54,7 @@
54
54
  * DFS stage).
55
55
  */
56
56
  import type { LLMMessage } from '../adapters/types.js';
57
+ import type { FoldedSpan } from './agent/window/types.js';
57
58
  /**
58
59
  * JSON-serializable checkpoint of an in-progress agent run. Persist
59
60
  * to ANY durable store (Redis / Postgres / S3 / disk / queue) and
@@ -85,6 +86,29 @@ export interface AgentRunCheckpoint {
85
86
  };
86
87
  /** Wall-clock when the checkpoint was captured. Diagnostic only. */
87
88
  readonly checkpointedAt: number;
89
+ /**
90
+ * Every span this conversation folded into a summary, oldest first — what
91
+ * makes a compacted conversation still a provable one after the process
92
+ * that compacted it is gone.
93
+ *
94
+ * Written by `.compaction()`; absent on a conversation that never folded,
95
+ * and absent on one stored by a runtime older than 8.2. Under the default
96
+ * `retain: 'conversation'` each span carries the folded messages verbatim;
97
+ * under `retain: 'discard'` the span is still here, naming what left, and
98
+ * only `messages` is absent.
99
+ *
100
+ * Join a summary in {@link history} to its span with `foldedSpanFor(...)` —
101
+ * by content fingerprint, never by index, because a later fold moves every
102
+ * index after it.
103
+ *
104
+ * **Version 1 still, deliberately.** An optional field is not a format
105
+ * change: a runtime that has never heard of `folded` reads this checkpoint,
106
+ * ignores it, and continues the conversation correctly — the summary is an
107
+ * ordinary message in `history` either way. Bumping the version would make
108
+ * an older deployment REFUSE a session it can serve perfectly well, which is
109
+ * the opposite of what the version field is for.
110
+ */
111
+ readonly folded?: readonly FoldedSpan[];
88
112
  /** Where the failure happened. Diagnostic — surfaces in oncall
89
113
  * triage so you can tell "LLM 500 mid-iteration" from "tool
90
114
  * threw" from "validation kept failing". */
@@ -159,7 +183,14 @@ export declare function buildCheckpoint(tracker: RunCheckpointTracker, failurePo
159
183
  phase: AgentRunCheckpoint['failurePoint'] extends infer F ? F extends {
160
184
  phase: infer P;
161
185
  } ? P : never : never;
162
- }): AgentRunCheckpoint;
186
+ },
187
+ /**
188
+ * Spans this run folded, read from committed state by the caller. Passed in
189
+ * rather than tracked, because the tracker follows `history` through events
190
+ * and a fold's span is committed state — and because the same reader then
191
+ * serves both checkpoint carriers, so neither can lose what the other keeps.
192
+ */
193
+ folded?: readonly FoldedSpan[]): AgentRunCheckpoint;
163
194
  /**
164
195
  * Validate a checkpoint at deserialization time. Catches forward-
165
196
  * incompatible payloads (someone tries to resume a v3 checkpoint on
@@ -103,7 +103,14 @@ export class RunCheckpointError extends Error {
103
103
  *
104
104
  * @internal
105
105
  */
106
- export function buildCheckpoint(tracker, failurePoint) {
106
+ export function buildCheckpoint(tracker, failurePoint,
107
+ /**
108
+ * Spans this run folded, read from committed state by the caller. Passed in
109
+ * rather than tracked, because the tracker follows `history` through events
110
+ * and a fold's span is committed state — and because the same reader then
111
+ * serves both checkpoint carriers, so neither can lose what the other keeps.
112
+ */
113
+ folded) {
107
114
  return {
108
115
  version: 1,
109
116
  runId: tracker.runId,
@@ -112,6 +119,7 @@ export function buildCheckpoint(tracker, failurePoint) {
112
119
  originalInput: tracker.originalInput,
113
120
  checkpointedAt: Date.now(),
114
121
  ...(failurePoint && { failurePoint }),
122
+ ...(folded !== undefined && folded.length > 0 && { folded }),
115
123
  };
116
124
  }
117
125
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"runCheckpoint.js","sourceRoot":"","sources":["../../../src/core/runCheckpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AA4CH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,IAAI,GAAG,oBAA6B,CAAC;IAC9C;;6BAEyB;IACP,KAAK,CAAQ;IAC/B;mEAC+D;IACtD,UAAU,CAAqB;IAExC,YAAY,KAAY,EAAE,UAA8B;QACtD,MAAM,KAAK,GAAG,UAAU,CAAC,YAAY,EAAE,KAAK,IAAI,SAAS,CAAC;QAC1D,KAAK,CACH,mCAAmC,UAAU,CAAC,YAAY,EAAE,SAAS,IAAI,GAAG,KAAK,KAAK,KAAK;YACzF,8CAA8C,UAAU,CAAC,sBAAsB,IAAI;YACnF,uDAAuD;YACvD,qBAAqB,KAAK,CAAC,OAAO,EAAE,CACvC,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAuBD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA6B,EAC7B,YAOC;IAED,OAAO;QACL,OAAO,EAAE,CAAC;QACV,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;QACtD,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,cAAc,EAAE,IAAI,CAAC,GAAG,EAAE;QAC1B,GAAG,CAAC,YAAY,IAAI,EAAE,YAAY,EAAE,CAAC;KACtC,CAAC;AACJ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QAAQ,EAAE,CAAC;QACpE,MAAM,IAAI,SAAS,CACjB,2EAA2E,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,CAAuB,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAU;IAC7C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACtB,MAAM,IAAI,GAAI,GAAyB,CAAC,IAAI,IAAI,EAAE,CAAC;IACnD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;IAC9B,sDAAsD;IACtD,IACE,IAAI,KAAK,kBAAkB,IAAI,0BAA0B;QACzD,IAAI,KAAK,gBAAgB;QACzB,IAAI,KAAK,aAAa;QACtB,IAAI,KAAK,cAAc;QACvB,8CAA8C,CAAC,IAAI,CAAC,GAAG,CAAC,EACxD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,WAAW,CAAC;IAC/C,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -483,6 +483,25 @@ export interface SkillDeactivatedPayload {
483
483
  * (cursor/activations unchanged); the model gets a synthetic re-prompt naming
484
484
  * `allowed`. Powers the lens / Why-panel "it tried to leave the graph here".
485
485
  */
486
+ /**
487
+ * Fired when a `read_skill` pick the gate ACCEPTED did not end up active — the
488
+ * model was told "Skill 'X' activated for the next iteration" and something else
489
+ * won. There is exactly one way to get here: a declared route edge fired on the
490
+ * same turn (the model emitted a domain tool AND `read_skill` in one message, and
491
+ * the tool's result matched the edge). The author's declared edge wins by design
492
+ * (`D1 > D2`), so the pick is superseded — and reported here rather than silently
493
+ * dropped. The next iteration shows the model where it actually is.
494
+ */
495
+ export interface SkillRerouteSupersededPayload {
496
+ /** The skill the model picked with `read_skill` (accepted, then superseded). */
497
+ readonly volunteeredId: string;
498
+ /** The skill the declared edge routed to instead (the cursor that won). */
499
+ readonly wonId?: string;
500
+ /** The cursor the hop started from. */
501
+ readonly fromSkillId?: string;
502
+ /** The ReAct iteration whose evaluation dropped the pick. */
503
+ readonly iteration: number;
504
+ }
486
505
  export interface SkillRejectedPayload {
487
506
  /** The skill id the model requested via `read_skill`. */
488
507
  readonly requestedId: string;
@@ -16,7 +16,7 @@
16
16
  * major bump. See agentfootprint_v2_detailed_design.md for rules.
17
17
  */
18
18
  import type { AgentfootprintEventEnvelope } from './types.js';
19
- import type { AgentHandoffPayload, AgentIterationEndPayload, AgentIterationStartPayload, AgentRouteDecidedPayload, AgentTurnEndPayload, AgentTurnStartPayload, CompositionEnterPayload, CompositionExitPayload, ConditionalRouteDecidedPayload, ContextBudgetPressurePayload, ContextEvaluatedPayload, ContextEvictedPayload, ContextInjectedPayload, ContextSlotComposedPayload, CostLimitHitPayload, CostTickPayload, EmbeddingGeneratedPayload, ErrorFatalPayload, ErrorRecoveredPayload, ErrorRetriedPayload, EvalScorePayload, EvalThresholdCrossedPayload, AgentOutputSchemaValidationFailedPayload, AgentOutputSchemaRetryPayload, AgentThinkingParseFailedPayload, StreamThinkingDeltaPayload, StreamThinkingEndPayload, FallbackTriggeredPayload, LLMEndPayload, LLMStartPayload, LLMTokenPayload, LoopIterationExitPayload, LoopIterationStartPayload, MemoryAttachedPayload, MemoryDetachedPayload, MemoryStrategyAppliedPayload, MemoryWrittenPayload, ParallelBranchCompletePayload, ParallelForkStartPayload, ParallelMergeEndPayload, PauseRequestPayload, PauseResumePayload, CheckInRequestPayload, CheckInDecisionPayload, PermissionCheckPayload, PermissionGateClosedPayload, PermissionHaltPayload, PermissionGateOpenedPayload, CredentialRequestedPayload, CredentialAcquiredPayload, CredentialAuthorizationRequiredPayload, CredentialFailedPayload, ReliabilityFailFastPayload, ReliabilityRetriedPayload, ReliabilityRecoveredPayload, RiskFlaggedPayload, SkillActivatedPayload, SkillDeactivatedPayload, SkillRejectedPayload, ToolEndPayload, ToolsActivatedPayload, ToolsDeactivatedPayload, ToolsDiscoveryStartedPayload, ToolsDiscoveryCompletedPayload, ToolsDiscoveryFailedPayload, ToolsOfferedPayload, ToolStartPayload, ValidationArgsInvalidPayload, MiddlewareDecisionPayload } from './payloads.js';
19
+ import type { AgentHandoffPayload, AgentIterationEndPayload, AgentIterationStartPayload, AgentRouteDecidedPayload, AgentTurnEndPayload, AgentTurnStartPayload, CompositionEnterPayload, CompositionExitPayload, ConditionalRouteDecidedPayload, ContextBudgetPressurePayload, ContextEvaluatedPayload, ContextEvictedPayload, ContextInjectedPayload, ContextSlotComposedPayload, CostLimitHitPayload, CostTickPayload, EmbeddingGeneratedPayload, ErrorFatalPayload, ErrorRecoveredPayload, ErrorRetriedPayload, EvalScorePayload, EvalThresholdCrossedPayload, AgentOutputSchemaValidationFailedPayload, AgentOutputSchemaRetryPayload, AgentThinkingParseFailedPayload, StreamThinkingDeltaPayload, StreamThinkingEndPayload, FallbackTriggeredPayload, LLMEndPayload, LLMStartPayload, LLMTokenPayload, LoopIterationExitPayload, LoopIterationStartPayload, MemoryAttachedPayload, MemoryDetachedPayload, MemoryStrategyAppliedPayload, MemoryWrittenPayload, ParallelBranchCompletePayload, ParallelForkStartPayload, ParallelMergeEndPayload, PauseRequestPayload, PauseResumePayload, CheckInRequestPayload, CheckInDecisionPayload, PermissionCheckPayload, PermissionGateClosedPayload, PermissionHaltPayload, PermissionGateOpenedPayload, CredentialRequestedPayload, CredentialAcquiredPayload, CredentialAuthorizationRequiredPayload, CredentialFailedPayload, ReliabilityFailFastPayload, ReliabilityRetriedPayload, ReliabilityRecoveredPayload, RiskFlaggedPayload, SkillActivatedPayload, SkillDeactivatedPayload, SkillRejectedPayload, SkillRerouteSupersededPayload, ToolEndPayload, ToolsActivatedPayload, ToolsDeactivatedPayload, ToolsDiscoveryStartedPayload, ToolsDiscoveryCompletedPayload, ToolsDiscoveryFailedPayload, ToolsOfferedPayload, ToolStartPayload, ValidationArgsInvalidPayload, MiddlewareDecisionPayload } from './payloads.js';
20
20
  export declare const EVENT_NAMES: {
21
21
  readonly composition: {
22
22
  readonly enter: "agentfootprint.composition.enter";
@@ -73,6 +73,7 @@ export declare const EVENT_NAMES: {
73
73
  readonly activated: "agentfootprint.skill.activated";
74
74
  readonly deactivated: "agentfootprint.skill.deactivated";
75
75
  readonly rejected: "agentfootprint.skill.rejected";
76
+ readonly rerouteSuperseded: "agentfootprint.skill.reroute_superseded";
76
77
  };
77
78
  readonly validation: {
78
79
  readonly argsInvalid: "agentfootprint.validation.args_invalid";
@@ -171,6 +172,7 @@ export interface AgentfootprintEventMap {
171
172
  'agentfootprint.skill.activated': AgentfootprintEventEnvelope<'agentfootprint.skill.activated', SkillActivatedPayload>;
172
173
  'agentfootprint.skill.deactivated': AgentfootprintEventEnvelope<'agentfootprint.skill.deactivated', SkillDeactivatedPayload>;
173
174
  'agentfootprint.skill.rejected': AgentfootprintEventEnvelope<'agentfootprint.skill.rejected', SkillRejectedPayload>;
175
+ 'agentfootprint.skill.reroute_superseded': AgentfootprintEventEnvelope<'agentfootprint.skill.reroute_superseded', SkillRerouteSupersededPayload>;
174
176
  'agentfootprint.validation.args_invalid': AgentfootprintEventEnvelope<'agentfootprint.validation.args_invalid', ValidationArgsInvalidPayload>;
175
177
  'agentfootprint.permission.check': AgentfootprintEventEnvelope<'agentfootprint.permission.check', PermissionCheckPayload>;
176
178
  'agentfootprint.permission.gate_opened': AgentfootprintEventEnvelope<'agentfootprint.permission.gate_opened', PermissionGateOpenedPayload>;
@@ -74,6 +74,7 @@ export const EVENT_NAMES = {
74
74
  activated: 'agentfootprint.skill.activated',
75
75
  deactivated: 'agentfootprint.skill.deactivated',
76
76
  rejected: 'agentfootprint.skill.rejected',
77
+ rerouteSuperseded: 'agentfootprint.skill.reroute_superseded',
77
78
  },
78
79
  validation: {
79
80
  argsInvalid: 'agentfootprint.validation.args_invalid',
@@ -177,6 +178,7 @@ export const ALL_EVENT_TYPES = [
177
178
  'agentfootprint.skill.activated',
178
179
  'agentfootprint.skill.deactivated',
179
180
  'agentfootprint.skill.rejected',
181
+ 'agentfootprint.skill.reroute_superseded',
180
182
  'agentfootprint.permission.check',
181
183
  'agentfootprint.permission.gate_opened',
182
184
  'agentfootprint.permission.gate_closed',
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/events/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA2EH,yEAAyE;AACzE,gEAAgE;AAChE,wEAAwE;AACxE,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,WAAW,EAAE;QACX,KAAK,EAAE,kCAAkC;QACzC,IAAI,EAAE,iCAAiC;QACvC,SAAS,EAAE,uCAAuC;QAClD,cAAc,EAAE,4CAA4C;QAC5D,QAAQ,EAAE,sCAAsC;QAChD,YAAY,EAAE,0CAA0C;QACxD,cAAc,EAAE,4CAA4C;QAC5D,aAAa,EAAE,2CAA2C;KAC3D;IACD,KAAK,EAAE;QACL,SAAS,EAAE,iCAAiC;QAC5C,OAAO,EAAE,+BAA+B;QACxC,cAAc,EAAE,sCAAsC;QACtD,YAAY,EAAE,oCAAoC;QAClD,YAAY,EAAE,oCAAoC;QAClD,OAAO,EAAE,8BAA8B;QACvC,4BAA4B,EAAE,sDAAsD;QACpF,iBAAiB,EAAE,0CAA0C;QAC7D,mBAAmB,EAAE,4CAA4C;KAClE;IACD,MAAM,EAAE;QACN,QAAQ,EAAE,iCAAiC;QAC3C,MAAM,EAAE,+BAA+B;QACvC,KAAK,EAAE,6BAA6B;QACpC,SAAS,EAAE,kCAAkC;QAC7C,OAAO,EAAE,gCAAgC;QACzC,aAAa,EAAE,sCAAsC;QACrD,WAAW,EAAE,oCAAoC;KAClD;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,iCAAiC;QAC3C,OAAO,EAAE,g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AsC;IACtC,oCAAoC;IACpC,sCAAsC;IACtC,8BAA8B;IAC9B,6BAA6B;IAC7B,gCAAgC;IAChC,iCAAiC;IACjC,oCAAoC;IACpC,oCAAoC;CAC5B,CAAC"}
@@ -31,7 +31,7 @@ export { LLMCall, LLMCallBuilder, type LLMCallInput, type LLMCallOptions, type L
31
31
  export { type MessageApiChartDeps } from './core/agent/buildMessageApiChart.js';
32
32
  export { buildAgentMessageApiChart, type AgentMessageApiChartDeps, } from './core/agent/buildAgentMessageApiChart.js';
33
33
  export { Agent, AgentBuilder, type AgentInput, type AgentOptions, type AgentOutput, type ObserverDeliveryOptions, } from './core/Agent.js';
34
- export { CompactionUnmeasurableError, COMPACTED_FRAME_PREFIX, DROP_NOTICE_PREFIX, isCompactedSummary, isDropNotice, slidingWindow, summarizeOldest, tokenBudget, type CompactionOptions, type CompactionRecord, type FoldRefusal, type FoldRefusalReason, type RemovalFacts, type RemovalPlan, type SlidingWindowOptions, type SlidingWindowRecord, type TokenBudgetOptions, type TokenBudgetRecord, type Turn, type WindowEviction, type WindowRecord, type WindowRefusal, type WindowRefusalReason, type WindowStrategy, type WindowStrategyInput, type WindowStrategyResult, } from './core/agent/window/index.js';
34
+ export { CompactionUnmeasurableError, COMPACTED_FRAME_PREFIX, DROP_NOTICE_PREFIX, foldedMessages, foldedSpanFor, isCompactedSummary, isDropNotice, slidingWindow, summarizeOldest, tokenBudget, type CompactionOptions, type CompactionRecord, type CompactionRetention, type FoldedConversation, type FoldedSpan, type FoldRefusal, type FoldRefusalReason, type RemovalFacts, type RemovalPlan, type SlidingWindowOptions, type SlidingWindowRecord, type TokenBudgetOptions, type TokenBudgetRecord, type Turn, type WindowEviction, type WindowRecord, type WindowRefusal, type WindowRefusalReason, type WindowStrategy, type WindowStrategyInput, type WindowStrategyResult, } from './core/agent/window/index.js';
35
35
  export type { SelfExplainOptions } from './lib/trace-toolpack/selfExplain.js';
36
36
  export type { ObserverDrainResult, ObserverStats } from 'footprintjs';
37
37
  export type { ToolArgValidationMode } from './core/agent/toolArgsValidation.js';
package/dist/esm/index.js CHANGED
@@ -112,7 +112,12 @@ export { Agent, AgentBuilder, } from './core/Agent.js';
112
112
  // summarizeOldest fold the oldest span into a summary (what `.compaction()` is)
113
113
  // slidingWindow keep the last N turns, drop older ones
114
114
  // tokenBudget counted-token trigger, drop instead of summarize
115
- export { CompactionUnmeasurableError, COMPACTED_FRAME_PREFIX, DROP_NOTICE_PREFIX, isCompactedSummary, isDropNotice, slidingWindow, summarizeOldest, tokenBudget, } from './core/agent/window/index.js';
115
+ //
116
+ // A commit log lives as long as the process; a conversation lives longer. So
117
+ // `.compaction({ retain })` carries the folded originals on the conversation
118
+ // checkpoint too, and `foldedSpanFor(conversation, message)` is the door back
119
+ // to them after a restart.
120
+ export { CompactionUnmeasurableError, COMPACTED_FRAME_PREFIX, DROP_NOTICE_PREFIX, foldedMessages, foldedSpanFor, isCompactedSummary, isDropNotice, slidingWindow, summarizeOldest, tokenBudget, } from './core/agent/window/index.js';
116
121
  export { OutputSchemaError, applyOutputSchema, } from './core/outputSchema.js';
117
122
  // 7.26 — the loop's side of the output contract. `OutputAttempt` is the row
118
123
  // shape `snapshot.sharedState.outputAttempts` carries; the frame prefix and
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oEAAoE;AACpE,8DAA8D;AAC9D,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,sDAAsD;AACtD,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,4CAA4C,CAAC;AAsCpD,6BAA6B;AAC7B,cAAc,qBAAqB,CAAC;AAEpC,yEAAyE;AACzE,uDAAuD;AACvD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc;AAEd,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,gBAAgB;AAChB,SAAS;AAET,2EAA2E;AAC3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ACtE,sEAAsE;AACtE,OAAO,EACL,SAAS,EAET,cAAc,GAGf,MAAM,oBAAoB,CAAC;AAE5B,qEAAqE;AACrE,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,8DAA8D;AAC9D,wEAAwE;AACxE,gDAAgD;AAChD,wEAAwE;AACxE,gEAAgE;AAEhE,wEAAwE;AACxE,wEAAwE;AACxE,uDAAuD;AAEvD,mEAAmE;AACnE,oEAAoE;AACpE,sDAAsD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oEAAoE;AACpE,8DAA8D;AAC9D,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,sDAAsD;AACtD,OAAO,8CAA8C,CAAC;AACtD,OAAO,2CAA2C,CAAC;AACnD,OAAO,4CAA4C,CAAC;AAsCpD,6BAA6B;AAC7B,cAAc,qBAAqB,CAAC;AAEpC,yEAAyE;AACzE,uDAAuD;AACvD,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc;AAEd,yEAAyE;AACzE,wEAAwE;AACxE,yEAAyE;AACzE,gBAAgB;AAChB,SAAS;AAET,2EAA2E;AAC3E,6EAA6E;AAC7E,6EAA6E;AAC7E,6DAA6D;AAC7D,YAAY,GAGb,MAAM,kBAAkB,CAAC;AAC1B,oEAAoE;AACpE,yEAAyE;AACzE,wEAAwE;AACxE,qEAAqE;AACrE,kDAAkD;AAClD,OAAO,EACL,gBAAgB,GAMjB,MAAM,2BAA2B,CAAC;AAKnC,yCAAyC;AACzC,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,oEAAoE;AACpE,qEAAqE;AACrE,2EAA2E;AAC3E,8EAA8E;AAC9E,0DAA0D;AAC1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GAKjB,MAAM,wCAAwC,CAAC;AAIhD,OAAO,EAAE,UAAU,E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