pi-condense 2.6.0 → 2.7.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/src/types.ts CHANGED
@@ -87,6 +87,13 @@ export const CUSTOM_TYPE_CHAIN = "context-prune-chain";
87
87
  */
88
88
  export const CUSTOM_TYPE_DIAGNOSTIC = "context-prune-diagnostic";
89
89
 
90
+ /**
91
+ * Per-flush-attempt observability record. Written once per non-concurrent
92
+ * flushPending invocation, regardless of outcome (including "empty" and
93
+ * "error"). Append-only log: never in LLM context, never reconstructed.
94
+ */
95
+ export const CUSTOM_TYPE_FLUSH_METRICS = "context-prune-flush-metrics";
96
+
90
97
  export type DiagnosticKind = "unresolved-range" | "range-id-mismatch" | "orphan-sweep";
91
98
 
92
99
  export interface DiagnosticEntryData {
@@ -672,6 +679,30 @@ export interface SummaryMessageDetails {
672
679
  timestamp: number;
673
680
  }
674
681
 
682
+ /** Snapshot of what the pruner cannot (yet) reclaim. All token values are Math.round(JSON-chars / 4). */
683
+ export interface ContextMetricsSnapshot {
684
+ /** Est. tokens of thinking blocks retained in the trailing open segment. */
685
+ openCycleThinkingTokens: number;
686
+ /** max(largest closed chain, open segment) chars / total branch chars, 0-100. */
687
+ largestChainSharePct: number;
688
+ /** Est. tokens of summarization-eligible unsummarized toolResults after the frontier. */
689
+ frontierGapTokens: number;
690
+ }
691
+
692
+ export type FlushTrigger = "budget" | "delta" | "message-end" | "manual" | "rearmed";
693
+
694
+ /** Payload of CUSTOM_TYPE_FLUSH_METRICS. */
695
+ export interface FlushMetricsEntry {
696
+ ts: number;
697
+ trigger: FlushTrigger;
698
+ /** Batches after rescan+trim, before processing. */
699
+ capturedBatches: number;
700
+ processedBatches: number;
701
+ outcome: "summarized" | "skipped-oversized" | "skipped-deduped" | "skipped-trivial" | "empty" | "error";
702
+ /** Computed at flush ENTRY (pre-flush pressure). */
703
+ metrics: ContextMetricsSnapshot;
704
+ }
705
+
675
706
  // ── Summarizer stats ────────────────────────────────────────────────────────
676
707
 
677
708
  /**
@@ -794,6 +825,8 @@ export interface FlushOptions {
794
825
  * the frontier. All pending batches are restored so the next flush can retry.
795
826
  */
796
827
  signal?: AbortSignal;
828
+ /** Which trigger initiated this flush. Defaults to "manual" when absent. */
829
+ trigger?: FlushTrigger;
797
830
  /**
798
831
  * The final text-only assistant message that triggered an agent-message flush.
799
832
  * pi emits `message_end` to extensions before persisting it to the session, so it