pi-condense 2.9.2 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/PRUNING.md +10 -2
- package/README.md +1 -0
- package/index.ts +24 -28
- package/package.json +1 -1
- package/src/batch-capture.test.ts +116 -1
- package/src/batch-capture.ts +47 -16
- package/src/budget.test.ts +21 -1
- package/src/budget.ts +10 -0
- package/src/chain-compressor.test.ts +17 -0
- package/src/chain-detector.test.ts +77 -1
- package/src/chain-detector.ts +26 -7
- package/src/chain-range-prune.test.ts +83 -0
- package/src/chain-range-prune.ts +7 -5
- package/src/config.test.ts +22 -0
- package/src/config.ts +6 -0
- package/src/context-metrics.test.ts +35 -5
- package/src/context-metrics.ts +5 -2
- package/src/reload-rearm.integration.test.ts +356 -18
- package/src/types.ts +17 -3
package/src/types.ts
CHANGED
|
@@ -414,6 +414,12 @@ export interface ContextPruneConfig {
|
|
|
414
414
|
* null (default) = disabled. Out-of-range (<= 0 or > 1) normalizes to null.
|
|
415
415
|
*/
|
|
416
416
|
budgetTurnDelta: number | null;
|
|
417
|
+
/**
|
|
418
|
+
* Opt-in flush trigger: when the un-pruned tail past the frontier
|
|
419
|
+
* (frontierGapTokens) reaches this many tokens, flush at turn_end.
|
|
420
|
+
* null (default) disables. Config-file-only — no settings overlay row.
|
|
421
|
+
*/
|
|
422
|
+
frontierGapThresholdTokens: number | null;
|
|
417
423
|
}
|
|
418
424
|
|
|
419
425
|
/**
|
|
@@ -426,7 +432,10 @@ export interface ContextPruneConfig {
|
|
|
426
432
|
* into a ChainCompressionEntry by adding blockId, toolRefs, and compressedAt.
|
|
427
433
|
*/
|
|
428
434
|
export interface ChainRange {
|
|
429
|
-
/**
|
|
435
|
+
/**
|
|
436
|
+
* Start anchor timestamp — a user message or an eligible (non-pruner)
|
|
437
|
+
* custom message. Field name kept for persisted-entry compatibility.
|
|
438
|
+
*/
|
|
430
439
|
startUserTimestamp: number;
|
|
431
440
|
/**
|
|
432
441
|
* All toolCallIds in the chain's middle (deduplicated). Collected from both
|
|
@@ -463,7 +472,11 @@ export interface ChainRange {
|
|
|
463
472
|
export interface ChainCompressionEntry {
|
|
464
473
|
/** Stable block ID, monotonic per session: "b1", "b2", ... */
|
|
465
474
|
blockId: string;
|
|
466
|
-
/**
|
|
475
|
+
/**
|
|
476
|
+
* Start anchor timestamp — a user message or an eligible (non-pruner)
|
|
477
|
+
* custom message. Field name kept for persisted-entry compatibility.
|
|
478
|
+
* Keep raw; synthetic inserted after.
|
|
479
|
+
*/
|
|
467
480
|
startUserTimestamp: number;
|
|
468
481
|
/**
|
|
469
482
|
* All toolCallIds in the chain's middle. **Diagnostic only** since the
|
|
@@ -566,6 +579,7 @@ export const DEFAULT_CONFIG: ContextPruneConfig = {
|
|
|
566
579
|
spillThreshold: 65536,
|
|
567
580
|
spillPreviewBytes: 2048,
|
|
568
581
|
budgetTurnDelta: null,
|
|
582
|
+
frontierGapThresholdTokens: null,
|
|
569
583
|
};
|
|
570
584
|
|
|
571
585
|
// ── Captured batch ─────────────────────────────────────────────────────────
|
|
@@ -708,7 +722,7 @@ export interface ContextMetricsSnapshot {
|
|
|
708
722
|
frontierGapTokens: number;
|
|
709
723
|
}
|
|
710
724
|
|
|
711
|
-
export type FlushTrigger = "budget" | "delta" | "message-end" | "manual" | "rearmed";
|
|
725
|
+
export type FlushTrigger = "budget" | "delta" | "frontier-gap" | "message-end" | "manual" | "rearmed";
|
|
712
726
|
|
|
713
727
|
/** Payload of CUSTOM_TYPE_FLUSH_METRICS. */
|
|
714
728
|
export interface FlushMetricsEntry {
|