swarm-engine 1.41.0 → 1.43.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.
@@ -0,0 +1,90 @@
1
+ /**
2
+ * VerbatimCompactor — strips re-retrievable content from agent outputs and replaces
3
+ * it with compact references. This is lossless: the agent can re-read originals via
4
+ * tools. NOT summarization — purely reference replacement.
5
+ */
6
+ export interface CompactReference {
7
+ type: 'file' | 'diff' | 'test-result' | 'stack-trace' | 'command-output';
8
+ ref: string;
9
+ originalLength: number;
10
+ }
11
+ export interface CompactionResult {
12
+ compacted: string;
13
+ references: CompactReference[];
14
+ originalLength: number;
15
+ compactedLength: number;
16
+ compressionRatio: number;
17
+ }
18
+ export declare class VerbatimCompactor {
19
+ /**
20
+ * Compact an agent output by replacing retrievable content with references.
21
+ * Preserves agent reasoning — only replaces content blocks.
22
+ */
23
+ compact(output: string): CompactionResult;
24
+ /**
25
+ * Compact multiple phase outputs (Map<phaseName, outputs[]>).
26
+ * Returns a new Map with compacted outputs.
27
+ */
28
+ compactPhaseOutputs(outputs: Map<string, string[]>): Map<string, string[]>;
29
+ /**
30
+ * Detect git diffs inside fenced code blocks.
31
+ * Pattern: ```diff\ndiff --git ...\n``` or ```\ndiff --git ...\n```
32
+ */
33
+ private detectFencedDiffs;
34
+ /**
35
+ * Detect bare git diffs (not inside fenced blocks).
36
+ * Matches from "diff --git" through the last hunk line.
37
+ */
38
+ private detectBareDiffs;
39
+ /**
40
+ * Detect test results inside fenced code blocks.
41
+ */
42
+ private detectFencedTestResults;
43
+ /**
44
+ * Detect bare test result blocks (vitest/jest summaries not in fences).
45
+ */
46
+ private detectBareTestResults;
47
+ /**
48
+ * Detect stack traces — "Error: ..." followed by "at ..." frames.
49
+ */
50
+ private detectStackTraces;
51
+ /**
52
+ * Detect file contents in fenced code blocks with a file path indicator.
53
+ * Patterns:
54
+ * - ```typescript\n// src/foo.ts\n...\n```
55
+ * - ```\nsrc/foo.ts\n...\n```
56
+ * - ```ts\n// file: src/foo.ts\n...\n```
57
+ */
58
+ private detectFencedFileContents;
59
+ /**
60
+ * Detect numbered file reads (like cat -n output).
61
+ * Pattern: consecutive lines matching " N\t<content>" (number + tab).
62
+ */
63
+ private detectNumberedFileReads;
64
+ /**
65
+ * Detect command output in fenced blocks.
66
+ * Pattern: ```bash\n$ command\n<output>\n``` or ```\n$ command\n<output>\n```
67
+ * Only compact if output is >10 lines.
68
+ */
69
+ private detectFencedCommandOutput;
70
+ private parseDiffStats;
71
+ private parseTestStats;
72
+ private formatTestReplacement;
73
+ private extractFrameLocation;
74
+ /**
75
+ * Extract a file path from the first few lines of a fenced code block.
76
+ * Looks for:
77
+ * - // src/foo.ts or // file: src/foo.ts
78
+ * - # src/foo.py
79
+ * - A bare path on the first line (src/foo.ts or ./src/foo.ts)
80
+ */
81
+ private extractFilePath;
82
+ /**
83
+ * Try to find a file path in text preceding a numbered file read.
84
+ * Looks for "Reading src/foo.ts" or similar patterns.
85
+ */
86
+ private extractFilePathFromContext;
87
+ private overlapsExisting;
88
+ private resolveOverlaps;
89
+ }
90
+ //# sourceMappingURL=compactor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compactor.d.ts","sourceRoot":"","sources":["../../src/runtime/compactor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,GAAG,aAAa,GAAG,gBAAgB,CAAC;IACzE,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,gBAAgB,EAAE,CAAC;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AASD,qBAAa,iBAAiB;IAC5B;;;OAGG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB;IAgDzC;;;OAGG;IACH,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAa1E;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAoBzB;;;OAGG;IACH,OAAO,CAAC,eAAe;IAsBvB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAsB/B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAuB7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IA2BzB;;;;;;OAMG;IACH,OAAO,CAAC,wBAAwB;IAyBhC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAwB/B;;;;OAIG;IACH,OAAO,CAAC,yBAAyB;IA2BjC,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,cAAc;IAoCtB,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,oBAAoB;IAkB5B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAevB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAYlC,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,eAAe;CAoBxB"}
@@ -0,0 +1,418 @@
1
+ /**
2
+ * VerbatimCompactor — strips re-retrievable content from agent outputs and replaces
3
+ * it with compact references. This is lossless: the agent can re-read originals via
4
+ * tools. NOT summarization — purely reference replacement.
5
+ */
6
+ export class VerbatimCompactor {
7
+ /**
8
+ * Compact an agent output by replacing retrievable content with references.
9
+ * Preserves agent reasoning — only replaces content blocks.
10
+ */
11
+ compact(output) {
12
+ if (!output) {
13
+ return {
14
+ compacted: '',
15
+ references: [],
16
+ originalLength: 0,
17
+ compactedLength: 0,
18
+ compressionRatio: 1,
19
+ };
20
+ }
21
+ const replacements = [];
22
+ // Collect all replacements (order matters — collect first, apply later to
23
+ // avoid index drift). Each detector appends to the same array.
24
+ this.detectFencedDiffs(output, replacements);
25
+ this.detectBareDiffs(output, replacements);
26
+ this.detectFencedTestResults(output, replacements);
27
+ this.detectBareTestResults(output, replacements);
28
+ this.detectStackTraces(output, replacements);
29
+ this.detectFencedFileContents(output, replacements);
30
+ this.detectNumberedFileReads(output, replacements);
31
+ this.detectFencedCommandOutput(output, replacements);
32
+ // Remove overlapping replacements (keep earliest/longest)
33
+ const resolved = this.resolveOverlaps(replacements);
34
+ // Apply replacements back-to-front to preserve indices
35
+ let compacted = output;
36
+ const references = [];
37
+ for (const r of resolved.sort((a, b) => b.start - a.start)) {
38
+ compacted = compacted.slice(0, r.start) + r.replacement + compacted.slice(r.end);
39
+ references.push(r.reference);
40
+ }
41
+ // Reverse references so they're in document order
42
+ references.reverse();
43
+ return {
44
+ compacted,
45
+ references,
46
+ originalLength: output.length,
47
+ compactedLength: compacted.length,
48
+ compressionRatio: output.length > 0 ? compacted.length / output.length : 1,
49
+ };
50
+ }
51
+ /**
52
+ * Compact multiple phase outputs (Map<phaseName, outputs[]>).
53
+ * Returns a new Map with compacted outputs.
54
+ */
55
+ compactPhaseOutputs(outputs) {
56
+ const result = new Map();
57
+ for (const [phase, phaseOutputs] of outputs) {
58
+ result.set(phase, phaseOutputs.map((o) => this.compact(o).compacted));
59
+ }
60
+ return result;
61
+ }
62
+ // ─── Detectors ──────────────────────────────────────────────
63
+ /**
64
+ * Detect git diffs inside fenced code blocks.
65
+ * Pattern: ```diff\ndiff --git ...\n``` or ```\ndiff --git ...\n```
66
+ */
67
+ detectFencedDiffs(text, out) {
68
+ const pattern = /^(`{3,})(?:diff)?\s*\n(diff --git[\s\S]*?)\n\1\s*$/gm;
69
+ let m;
70
+ while ((m = pattern.exec(text)) !== null) {
71
+ const diffContent = m[2];
72
+ const stats = this.parseDiffStats(diffContent);
73
+ const replacement = `[diff: ${stats.files} file${stats.files === 1 ? '' : 's'}, +${stats.added}/-${stats.removed} lines]`;
74
+ out.push({
75
+ start: m.index,
76
+ end: m.index + m[0].length,
77
+ replacement,
78
+ reference: {
79
+ type: 'diff',
80
+ ref: `git diff (${stats.files} file${stats.files === 1 ? '' : 's'})`,
81
+ originalLength: m[0].length,
82
+ },
83
+ });
84
+ }
85
+ }
86
+ /**
87
+ * Detect bare git diffs (not inside fenced blocks).
88
+ * Matches from "diff --git" through the last hunk line.
89
+ */
90
+ detectBareDiffs(text, out) {
91
+ const pattern = /^diff --git a\/\S+ b\/\S+\n(?:(?:index |--- |\+\+\+ |@@ |[ +\-]|new file|deleted file|old mode|new mode|similarity|rename|Binary).*\n|\n)*/gm;
92
+ let m;
93
+ while ((m = pattern.exec(text)) !== null) {
94
+ // Skip if this region is already covered by a fenced diff
95
+ if (this.overlapsExisting(m.index, m.index + m[0].length, out))
96
+ continue;
97
+ const stats = this.parseDiffStats(m[0]);
98
+ const replacement = `[diff: ${stats.files} file${stats.files === 1 ? '' : 's'}, +${stats.added}/-${stats.removed} lines]`;
99
+ out.push({
100
+ start: m.index,
101
+ end: m.index + m[0].length,
102
+ replacement,
103
+ reference: {
104
+ type: 'diff',
105
+ ref: `git diff (${stats.files} file${stats.files === 1 ? '' : 's'})`,
106
+ originalLength: m[0].length,
107
+ },
108
+ });
109
+ }
110
+ }
111
+ /**
112
+ * Detect test results inside fenced code blocks.
113
+ */
114
+ detectFencedTestResults(text, out) {
115
+ const pattern = /^(`{3,})\s*\n([\s\S]*?)\n\1\s*$/gm;
116
+ let m;
117
+ while ((m = pattern.exec(text)) !== null) {
118
+ const content = m[2];
119
+ const stats = this.parseTestStats(content);
120
+ if (stats) {
121
+ const replacement = this.formatTestReplacement(stats);
122
+ out.push({
123
+ start: m.index,
124
+ end: m.index + m[0].length,
125
+ replacement,
126
+ reference: {
127
+ type: 'test-result',
128
+ ref: stats.runner || 'test run',
129
+ originalLength: m[0].length,
130
+ },
131
+ });
132
+ }
133
+ }
134
+ }
135
+ /**
136
+ * Detect bare test result blocks (vitest/jest summaries not in fences).
137
+ */
138
+ detectBareTestResults(text, out) {
139
+ // Match vitest/jest summary blocks: "Tests N passed" or "Test Suites:"
140
+ const pattern = /^(?:.*(?:✓|✗|PASS|FAIL|Tests?\s).*\n){3,}(?:.*(?:Tests?|Suites?|Snapshots?|Time).*\n)*/gm;
141
+ let m;
142
+ while ((m = pattern.exec(text)) !== null) {
143
+ if (this.overlapsExisting(m.index, m.index + m[0].length, out))
144
+ continue;
145
+ const stats = this.parseTestStats(m[0]);
146
+ if (stats) {
147
+ const replacement = this.formatTestReplacement(stats);
148
+ out.push({
149
+ start: m.index,
150
+ end: m.index + m[0].length,
151
+ replacement,
152
+ reference: {
153
+ type: 'test-result',
154
+ ref: stats.runner || 'test run',
155
+ originalLength: m[0].length,
156
+ },
157
+ });
158
+ }
159
+ }
160
+ }
161
+ /**
162
+ * Detect stack traces — "Error: ..." followed by "at ..." frames.
163
+ */
164
+ detectStackTraces(text, out) {
165
+ const pattern = /^(\w*Error: .+)\n((?:\s+at .+\n?){2,})/gm;
166
+ let m;
167
+ while ((m = pattern.exec(text)) !== null) {
168
+ if (this.overlapsExisting(m.index, m.index + m[0].length, out))
169
+ continue;
170
+ const errorMessage = m[1].trim();
171
+ const frames = m[2]
172
+ .trim()
173
+ .split('\n')
174
+ .map((l) => l.trim());
175
+ const frameCount = frames.length;
176
+ // Extract top frame file:line
177
+ const topFrame = this.extractFrameLocation(frames[0]);
178
+ const replacement = `[error: ${errorMessage}, stack: ${frameCount} frames, top: ${topFrame}]`;
179
+ out.push({
180
+ start: m.index,
181
+ end: m.index + m[0].length,
182
+ replacement,
183
+ reference: {
184
+ type: 'stack-trace',
185
+ ref: topFrame,
186
+ originalLength: m[0].length,
187
+ },
188
+ });
189
+ }
190
+ }
191
+ /**
192
+ * Detect file contents in fenced code blocks with a file path indicator.
193
+ * Patterns:
194
+ * - ```typescript\n// src/foo.ts\n...\n```
195
+ * - ```\nsrc/foo.ts\n...\n```
196
+ * - ```ts\n// file: src/foo.ts\n...\n```
197
+ */
198
+ detectFencedFileContents(text, out) {
199
+ const pattern = /^(`{3,})(\w*)\s*\n([\s\S]*?)\n\1\s*$/gm;
200
+ let m;
201
+ while ((m = pattern.exec(text)) !== null) {
202
+ if (this.overlapsExisting(m.index, m.index + m[0].length, out))
203
+ continue;
204
+ const content = m[3];
205
+ const lines = content.split('\n');
206
+ const filePath = this.extractFilePath(lines);
207
+ if (filePath) {
208
+ const lineCount = lines.length;
209
+ const replacement = `[file: ${filePath}, ~${lineCount} lines]`;
210
+ out.push({
211
+ start: m.index,
212
+ end: m.index + m[0].length,
213
+ replacement,
214
+ reference: {
215
+ type: 'file',
216
+ ref: `${filePath}:1-${lineCount}`,
217
+ originalLength: m[0].length,
218
+ },
219
+ });
220
+ }
221
+ }
222
+ }
223
+ /**
224
+ * Detect numbered file reads (like cat -n output).
225
+ * Pattern: consecutive lines matching " N\t<content>" (number + tab).
226
+ */
227
+ detectNumberedFileReads(text, out) {
228
+ const pattern = /^(?:\s*\d+\t.*\n?){5,}/gm;
229
+ let m;
230
+ while ((m = pattern.exec(text)) !== null) {
231
+ if (this.overlapsExisting(m.index, m.index + m[0].length, out))
232
+ continue;
233
+ const lines = m[0].trimEnd().split('\n');
234
+ const lineCount = lines.length;
235
+ // Try to extract a file path from surrounding context
236
+ const contextBefore = text.slice(Math.max(0, m.index - 200), m.index);
237
+ const filePath = this.extractFilePathFromContext(contextBefore) || 'unknown';
238
+ const replacement = `[file: ${filePath}, ~${lineCount} lines]`;
239
+ out.push({
240
+ start: m.index,
241
+ end: m.index + m[0].length,
242
+ replacement,
243
+ reference: {
244
+ type: 'file',
245
+ ref: `${filePath}:1-${lineCount}`,
246
+ originalLength: m[0].length,
247
+ },
248
+ });
249
+ }
250
+ }
251
+ /**
252
+ * Detect command output in fenced blocks.
253
+ * Pattern: ```bash\n$ command\n<output>\n``` or ```\n$ command\n<output>\n```
254
+ * Only compact if output is >10 lines.
255
+ */
256
+ detectFencedCommandOutput(text, out) {
257
+ const pattern = /^(`{3,})(?:bash|sh|shell|zsh|console)?\s*\n(\$ .+\n)([\s\S]*?)\n\1\s*$/gm;
258
+ let m;
259
+ while ((m = pattern.exec(text)) !== null) {
260
+ if (this.overlapsExisting(m.index, m.index + m[0].length, out))
261
+ continue;
262
+ const cmdLine = m[2].trim();
263
+ const outputContent = m[3];
264
+ const outputLines = outputContent.split('\n').length;
265
+ if (outputLines > 10) {
266
+ const cmd = cmdLine.replace(/^\$\s*/, '');
267
+ const replacement = `[command: ${cmd}, ~${outputLines} lines output]`;
268
+ out.push({
269
+ start: m.index,
270
+ end: m.index + m[0].length,
271
+ replacement,
272
+ reference: {
273
+ type: 'command-output',
274
+ ref: cmd,
275
+ originalLength: m[0].length,
276
+ },
277
+ });
278
+ }
279
+ }
280
+ }
281
+ // ─── Helpers ────────────────────────────────────────────────
282
+ parseDiffStats(diff) {
283
+ const fileHeaders = diff.match(/^diff --git/gm);
284
+ const files = fileHeaders ? fileHeaders.length : 1;
285
+ let added = 0;
286
+ let removed = 0;
287
+ for (const line of diff.split('\n')) {
288
+ if (line.startsWith('+') && !line.startsWith('+++'))
289
+ added++;
290
+ if (line.startsWith('-') && !line.startsWith('---'))
291
+ removed++;
292
+ }
293
+ return { files, added, removed };
294
+ }
295
+ parseTestStats(content) {
296
+ let passed = 0;
297
+ let failed = 0;
298
+ let skipped = 0;
299
+ let runner = '';
300
+ // Detect runner
301
+ if (/vitest|vite/i.test(content))
302
+ runner = 'vitest';
303
+ else if (/jest/i.test(content))
304
+ runner = 'jest';
305
+ // Count checkmark/cross patterns (vitest style)
306
+ const checkmarks = content.match(/[✓✔]/g);
307
+ const crosses = content.match(/[✗✘×]/g);
308
+ if (checkmarks)
309
+ passed += checkmarks.length;
310
+ if (crosses)
311
+ failed += crosses.length;
312
+ // Count PASS/FAIL patterns (jest style)
313
+ const passMatches = content.match(/\bPASS\b/g);
314
+ const failMatches = content.match(/\bFAIL\b/g);
315
+ if (passMatches)
316
+ passed += passMatches.length;
317
+ if (failMatches)
318
+ failed += failMatches.length;
319
+ // Look for summary lines: "Tests 47 passed (47)" or "N passed, M failed"
320
+ const summaryMatch = content.match(/(\d+)\s+passed.*?(?:(\d+)\s+failed)?.*?(?:(\d+)\s+(?:skipped|pending|todo))?/i);
321
+ if (summaryMatch) {
322
+ passed = parseInt(summaryMatch[1], 10);
323
+ if (summaryMatch[2])
324
+ failed = parseInt(summaryMatch[2], 10);
325
+ if (summaryMatch[3])
326
+ skipped = parseInt(summaryMatch[3], 10);
327
+ }
328
+ // Need at least some test signals to be a test result
329
+ if (passed === 0 && failed === 0)
330
+ return null;
331
+ return { passed, failed, skipped, runner };
332
+ }
333
+ formatTestReplacement(stats) {
334
+ const parts = [`${stats.passed} passed`];
335
+ if (stats.failed > 0)
336
+ parts.push(`${stats.failed} failed`);
337
+ if (stats.skipped > 0)
338
+ parts.push(`${stats.skipped} skipped`);
339
+ return `[tests: ${parts.join(', ')}]`;
340
+ }
341
+ extractFrameLocation(frame) {
342
+ // "at Function.X (/path/to/file.ts:10:5)" → "file.ts:10"
343
+ const parenMatch = frame.match(/\(([^)]+)\)/);
344
+ if (parenMatch) {
345
+ const parts = parenMatch[1].split(':');
346
+ const file = parts[0].split('/').pop();
347
+ return parts.length >= 2 ? `${file}:${parts[1]}` : file || frame;
348
+ }
349
+ // "at /path/to/file.ts:10:5" → "file.ts:10"
350
+ const bareMatch = frame.match(/at\s+(\S+)/);
351
+ if (bareMatch) {
352
+ const parts = bareMatch[1].split(':');
353
+ const file = parts[0].split('/').pop();
354
+ return parts.length >= 2 ? `${file}:${parts[1]}` : file || frame;
355
+ }
356
+ return frame;
357
+ }
358
+ /**
359
+ * Extract a file path from the first few lines of a fenced code block.
360
+ * Looks for:
361
+ * - // src/foo.ts or // file: src/foo.ts
362
+ * - # src/foo.py
363
+ * - A bare path on the first line (src/foo.ts or ./src/foo.ts)
364
+ */
365
+ extractFilePath(lines) {
366
+ if (lines.length === 0)
367
+ return null;
368
+ const first = lines[0].trim();
369
+ // "// src/foo.ts" or "// file: src/foo.ts"
370
+ const commentMatch = first.match(/^(?:\/\/|#)\s*(?:file:\s*)?(\S+\.\w+)/);
371
+ if (commentMatch)
372
+ return commentMatch[1];
373
+ // Bare file path: starts with valid path chars and has a file extension
374
+ const pathMatch = first.match(/^\.?\/?\S+\/\S+\.\w+$/);
375
+ if (pathMatch && lines.length > 1)
376
+ return first;
377
+ return null;
378
+ }
379
+ /**
380
+ * Try to find a file path in text preceding a numbered file read.
381
+ * Looks for "Reading src/foo.ts" or similar patterns.
382
+ */
383
+ extractFilePathFromContext(context) {
384
+ // "Reading src/foo.ts" or "File: src/foo.ts"
385
+ const match = context.match(/(?:reading|file[:\s])\s*(\S+\.\w+)\s*$/i);
386
+ if (match)
387
+ return match[1];
388
+ // Path on its own line near the end
389
+ const pathMatch = context.match(/(\S+\/\S+\.\w+)\s*$/);
390
+ if (pathMatch)
391
+ return pathMatch[1];
392
+ return null;
393
+ }
394
+ overlapsExisting(start, end, existing) {
395
+ return existing.some((r) => start < r.end && end > r.start);
396
+ }
397
+ resolveOverlaps(replacements) {
398
+ if (replacements.length <= 1)
399
+ return replacements;
400
+ // Sort by start position, then by length descending (prefer longer matches)
401
+ const sorted = [...replacements].sort((a, b) => {
402
+ if (a.start !== b.start)
403
+ return a.start - b.start;
404
+ return b.end - b.start - (a.end - a.start);
405
+ });
406
+ const resolved = [sorted[0]];
407
+ for (let i = 1; i < sorted.length; i++) {
408
+ const current = sorted[i];
409
+ const last = resolved[resolved.length - 1];
410
+ if (current.start >= last.end) {
411
+ resolved.push(current);
412
+ }
413
+ // Otherwise skip (overlaps with already-accepted replacement)
414
+ }
415
+ return resolved;
416
+ }
417
+ }
418
+ //# sourceMappingURL=compactor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compactor.js","sourceRoot":"","sources":["../../src/runtime/compactor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuBH,MAAM,OAAO,iBAAiB;IAC5B;;;OAGG;IACH,OAAO,CAAC,MAAc;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL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 | 1 | 2;
2
+ export interface DecayConfig {
3
+ /** Number of most recent phases to keep at full fidelity (level 0). Default: 2 */
4
+ fullFidelityCount: number;
5
+ /** Number of phases to keep at summary level (level 1). Default: 3 */
6
+ summaryCount: number;
7
+ /** Max chars for a level-1 summary. Default: 500 */
8
+ summaryMaxChars: number;
9
+ /** Max chars for a level-2 one-liner. Default: 120 */
10
+ oneLinerMaxChars: number;
11
+ }
12
+ export declare const DEFAULT_DECAY_CONFIG: DecayConfig;
13
+ export interface DecayedOutput {
14
+ phaseName: string;
15
+ level: DecayLevel;
16
+ content: string;
17
+ originalLength: number;
18
+ }
19
+ export declare class ContextDecayManager {
20
+ private config;
21
+ constructor(config?: DecayConfig);
22
+ /**
23
+ * Apply decay to ordered phase outputs.
24
+ * Phases are ordered from oldest to newest (index 0 = oldest).
25
+ *
26
+ * - Level 0 (most recent `fullFidelityCount` phases): Full output, no changes
27
+ * - Level 1 (next `summaryCount` phases): Extract key points into structured summary
28
+ * - Level 2 (everything older): Single-line reference
29
+ */
30
+ applyDecay(phaseOutputs: Map<string, string[]>): DecayedOutput[];
31
+ /** Determine what decay level a phase gets based on its position */
32
+ getDecayLevel(phaseIndex: number, totalPhases: number): DecayLevel;
33
+ /** Level 1: Extract structured summary from phase output */
34
+ summarizePhase(phaseName: string, outputs: string[]): string;
35
+ /** Level 2: Generate one-line reference from phase output */
36
+ toOneLiner(phaseName: string, outputs: string[]): string;
37
+ /** Calculate total token savings from decay */
38
+ estimateSavings(original: Map<string, string[]>, decayed: DecayedOutput[]): {
39
+ originalTokens: number;
40
+ decayedTokens: number;
41
+ savedPercent: number;
42
+ byLevel: Record<DecayLevel, number>;
43
+ };
44
+ }
45
+ //# sourceMappingURL=context-decay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-decay.d.ts","sourceRoot":"","sources":["../../src/runtime/context-decay.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,C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