/** * Headroom preferences resolver (slice 2026-06-14-fzf-headroom-rollout). * * Pure functions that turn `ProjectPreferences.headroom.*` + CLI * overrides into a single decision the dispatch path can act on. * No IO. No side effects. Easy to test in isolation. * * Two distinct decisions: * 1. `resolveHeadroomOptions` — should we compress the dispatch prompt? * Used by `peaks sub-agent dispatch`. Returns one of: * - `{ mode: , blocked: null }` → compress with mode * - `{ mode: null, blocked: null }` → skip compression (no --use-headroom) * - `{ mode: null, blocked: 'HEADROOM_DISABLED_BY_PREFERENCE' }` → hard fail * 2. `shouldCompressResults` — should we compress search-result text? * Used by `peaks memory search` / `peaks retrospective search`. * Non-blocking: returns a `reason` instead of a `blocked` code. * * Precedence (dispatch): * 1. `headroom.enabled = false` → hard block (regardless of --use-headroom) * 2. `headroom.enabled = true` + `--headroom-mode ` → use * 3. `headroom.enabled = true` + `--use-headroom` (no --headroom-mode) → * use `perTouchpoint.subAgentDispatch` (preferred) else `defaultMode` * 4. no `--use-headroom` → mode = null (compression skipped) */ import type { HeadroomMode, ProjectPreferences } from '../preferences/preferences-types.js'; export type HeadroomTouchpoint = keyof ProjectPreferences['headroom']['perTouchpoint']; export type HeadroomBlockCode = 'HEADROOM_DISABLED_BY_PREFERENCE'; export interface ResolvedHeadroomOptions { /** The mode to use for compression, or null if not compressing. */ readonly mode: HeadroomMode | null; /** Hard-block reason; null when compression is allowed (or simply not requested). */ readonly blocked: HeadroomBlockCode | null; } export interface ResolveCliOverrides { readonly useHeadroom: boolean; readonly headroomMode?: string; } export declare function isHeadroomMode(value: string | undefined): value is HeadroomMode; export declare function resolveHeadroomOptions(prefs: ProjectPreferences['headroom'], cliOverrides: ResolveCliOverrides): ResolvedHeadroomOptions; export interface ShouldCompressDecision { readonly compress: boolean; readonly mode: HeadroomMode; /** Non-null reason if not compressing. */ readonly reason: 'DISABLED' | 'BELOW_THRESHOLD' | null; } export declare function shouldCompressResults(prefs: ProjectPreferences['headroom'], joinedBytes: number, touchpoint: HeadroomTouchpoint): ShouldCompressDecision;