export const EXTENSION_ID = "pi-midrun-compact"; export const COMMAND_NAME = "midrun-compact"; export const DEFAULT_COMPACTION_INSTRUCTIONS = "Preserve the active user task, completed work, decisions, changed files, failures, pending tool-loop state, and exact next steps so execution can resume immediately after compaction."; export interface MidrunCompactConfig { enabled: boolean; thresholdPercent: number; autoResume: boolean; notify: boolean; customCompactionInstructions: string; } export const DEFAULT_CONFIG: Readonly = Object.freeze({ enabled: true, thresholdPercent: 75, autoResume: true, notify: true, customCompactionInstructions: DEFAULT_COMPACTION_INSTRUCTIONS, }); export interface LoadedConfig { config: MidrunCompactConfig; valid: boolean; automaticEnabled: boolean; globalPath: string; projectPath?: string; loadedSources: string[]; errors: string[]; warnings: string[]; projectConfigSkippedAsUntrusted: boolean; } export type RuntimePhase = "idle" | "compacting" | "resume-pending" | "failed"; export type CompactionSource = "threshold" | "now" | "retry"; export interface TriggerSnapshot { tokens: number; contextWindow: number; percent: number; thresholdPercent: number; } export interface RuntimeState { phase: RuntimePhase; generation: number; triggerSessionId?: string; triggerTokens?: number; triggerPercent?: number; triggerContextWindow?: number; triggerSource?: CompactionSource; lastFailureKey?: string; lastBlockedFailureKey?: string; lastError?: string; } export interface UsableContextUsage { tokens: number; contextWindow: number; percent: number; } export interface ThresholdEvaluation { usage: UsableContextUsage; trigger: TriggerSnapshot; }