import type { ContextPercentProbe } from './auto-compact-types.js'; import { type HarnessWindowLocation, type HarnessWindowReadResult, type HarnessWindowSyncResult } from './harness-window-config.js'; import type { ReadContextPercentInput } from './auto-compact-reader-input.js'; export type { ReadContextPercentInput }; /** * Resolve WHERE the harness auto-compact window lives, for the IDE the * current env selects. Returns `null` when either half is undeclared: * - the adapter exposes no `compact` profile, or * - the adapter's `compact` profile declares no * `autoCompactWindowEnvVar` (the IDE has no such knob), or * - the adapter declares no machine-local settings layer. * * Both the path and the key name come from the adapter's OWN declarations, * so this module names no IDE and no settings literal — the vendor-neutrality * guard's shape-3 rule applies to every registry consumer, and this is one. * */ export declare function resolveHarnessWindowLocation(input: { readonly projectRoot: string; readonly env?: NodeJS.ProcessEnv | undefined; }): HarnessWindowLocation | null; /** * Read the window peaks-loop last configured for the harness, plus whether * the user has opted out of peaks-loop managing it. Returns `null` when the * active adapter exposes no window knob at all. */ export declare function readHarnessWindowState(input: { readonly projectRoot: string; readonly env?: NodeJS.ProcessEnv | undefined; }): HarnessWindowReadResult | null; /** * The RAW window peaks-loop's context ratio must divide by — T1's number. * * The SETTINGS FILE is the source of truth, so its value wins whenever it has * one; the env-first read is consulted only when the file is silent (no key * yet, or the IDE injects the value from an outer layer). * * Why not "whatever the read returned" (the round-2 shape): the process env is * a snapshot the harness froze at session start, so it is stale by exactly one * write. Trusting it over the file is what let a stale env revert a human's * hand-edited window (B1) and downgrade a 1M file to a 200K one (a second * session's frozen env), and it is also what made T1's consistency depend on * *rewriting the file* — the same unconditional write that destroyed the human's * value. Dividing by the file instead makes peaks-loop's ratio and the harness's * configured window one number BY CONSTRUCTION, with no write required. The * write is then free to be gated on provenance (see `syncHarnessWindow`). * * Falls back to `undefined` (no harness layer at all) when the adapter * declares no knob or neither side carries the key — the adapter then resolves * its own window exactly as it did before this slice. */ export declare function resolveHarnessRatioWindow(state: HarnessWindowReadResult | null): unknown; /** * Materialize a window into the harness's own settings, so the number * peaks-loop divides by and the number the harness compacts against are one * value rather than two resolutions (slice * * The caller passes the denominator it JUST USED (`probe.capacityTokens`), not * a re-derived one — that is what makes the two sides structurally identical. * `tokens: null` (a percent-only probe carries no token window) is a * deliberate no-op: peaks-loop never invents a window it did not measure. * * Returns `null` when the active adapter declares no window knob at all. */ export declare function syncHarnessWindowForProject(input: { readonly projectRoot: string; readonly env?: NodeJS.ProcessEnv | undefined; readonly tokens: number | null; }): HarnessWindowSyncResult | null; /** * Read env-var-based context percentage. Returns `null` when the env * is absent or unparseable. Adapter-driven: the caller passes the * env-var name from `IdeAdapter.compact.envVarForContextPercent`, * so the function itself has no hard-coded IDE names. */ declare function readEnvPercent(env: NodeJS.ProcessEnv, varName: string): number | null; /** * Probe the current AI CLI's context-fill ratio. Adapter-driven: * looks up the registered `IdeAdapter.compact` profile via * `getAdapter(detectIdeFromEnv(env))` and reads the * adapter-declared env-var. When that misses, delegates to the * adapter's optional `readContextPercentFallback` (which owns any * vendor-specific statusline / transcript probe). Adapters without a * fallback (or a fallback that returns null) yield * `source: 'conservative-fallback'` with `ratio: 0` so the * orchestrator never auto-fires on a missing signal. */ export declare function readContextPercent(input: ReadContextPercentInput): ContextPercentProbe; /** Re-export the env-var probe for unit tests. */ export declare const _internal: { readEnvPercent: typeof readEnvPercent; };