/** * v2.11.0 Group F (Tier 9) — D6: main-session context window monitor. * * Per `.peaks/memory/2026-06-26-v2-11-main-session-context-monitor.md`: * * D6.a — IDE detection (`peaks ide detect --json`); env-var fallback. * D6.b — Main-session thresholds (50% warn / 75% user red line / 90% emergency) * D6.c — IDE-dependent trigger (claude-code → /compact; else LLM self-compress) * D6.d — Always log; never silently skip * D6.e — Do NOT auto-compact mid-tool-call-batch (in-flight deferral) * D6.f — Complements Step N periodic checkpoint (soft signal vs hard signal) * * Distinct from G7-G9 (sub-agent dispatch prompt governance). Same * numbers, different scope. Extends `src/services/context/threshold.ts` * rather than duplicating (D6.h). * * Karpathy §2: this module is the only place that decides * "main-session context threshold" — the LLM-side caller probes via * `evaluateMainSessionThreshold()` and `pickMainSessionTrigger()`. * No inline `promptSize / 256K > 0.75` checks scattered across * SKILL.md or other services. */ export type MainSessionTier = 'ok' | 'soft-warn' | 'near-limit' | 'emergency'; export declare const MAIN_SESSION_THRESHOLD_RATIOS: { readonly [K in MainSessionTier]: number; }; export type IdeKind = 'claude-code' | 'trae' | 'opencode' | 'unknown'; export declare const IDE_KINDS: readonly IdeKind[]; export type MainSessionTrigger = { readonly kind: 'none'; } | { readonly kind: 'soft-warn'; readonly promptSize: number; readonly ratio: number; } | { readonly kind: 'compact'; readonly ide: IdeKind; readonly path: 'ide-native' | 'llm-self-compress'; readonly promptSize: number; readonly ratio: number; readonly code: 'CONTEXT_NEAR_LIMIT' | 'PROMPT_EMERGENCY'; } | { readonly kind: 'defer'; readonly reason: 'in-flight-batch' | 'unsupported-ide'; }; export interface MainSessionEvaluation { readonly tier: MainSessionTier; readonly ratio: number; readonly bytesUsed: number; readonly capacityBytes: number; readonly warnings: readonly string[]; } export declare function isIdeKind(value: string): value is IdeKind; export declare function detectIdeFromEnv(env?: NodeJS.ProcessEnv): IdeKind; /** * Threshold check. Pure function (no IO). `capacityBytes` is injectable * for tests and future per-IDE capacity overrides. Defaults to the * G9 256K proxy (matches G9 for cognitive continuity). */ export declare function evaluateMainSessionThreshold(promptSize: number, capacityBytes?: number): MainSessionEvaluation; export interface InFlightBatchProbe { readonly hasInFlightBatch: boolean; readonly sharedChannelEntries: number; } export declare function pickMainSessionTrigger(opts: { promptSize: number; ide?: IdeKind | undefined; capacityBytes?: number | undefined; inFlightBatch?: InFlightBatchProbe | undefined; /** Injectable env for IDE detection (test seam). */ env?: NodeJS.ProcessEnv | undefined; }): MainSessionTrigger; /** * One-line audit log entry. Pure formatter; the LLM / CLI appends to * `.peaks/_runtime//txt/auto-decisions.md`. Matches D6.d. */ export declare function formatMainSessionTriggerLogLine(trigger: MainSessionTrigger, contextId: string): string;