/** * G9 — forced compression gate (RL-27..RL-32). * * The CLI 兜底 layer. Validates prompt size against the threshold * table in `threshold.ts` and returns a decision. The PreToolUse hook * layer (`peaks sub-agent-dispatch-guard`) re-runs the same logic * without `--force` (RL-30 strict). * * Decision codes: * - `OK` — under 50% * - `CONTEXT_SOFT_WARN` — 50-75%, prompt is large * - `CONTEXT_NEAR_LIMIT` — 75-80%, prompt is near the limit * - `PROMPT_TOO_LARGE` — 80-90%, hard reject (allow = false) * - `PROMPT_EMERGENCY` — ≥ 90%, hard reject + emergency * - `FORCED_OVER_THRESHOLD` — user passed --force at CLI; allow = true */ import { tierToCode, type ThresholdEvaluation } from './threshold.js'; export type ContextGuardCode = 'OK' | 'CONTEXT_SOFT_WARN' | 'CONTEXT_NEAR_LIMIT' | 'PROMPT_TOO_LARGE' | 'PROMPT_EMERGENCY' | 'FORCED_OVER_THRESHOLD'; export interface ContextGuardDecision { readonly allow: boolean; readonly code: ContextGuardCode; readonly warnings: readonly string[]; readonly suggest: string | null; readonly evaluation: ThresholdEvaluation; /** ISO8601 timestamp when --force override was applied. null otherwise. */ readonly forcedAt: string | null; } export interface ContextGuardOptions { /** Pass `true` to allow override at the ≥ 80% tier. CLI-only; hook layer MUST NOT set this. */ readonly force?: boolean; /** Override the default 256K context capacity (e.g. for tests). */ readonly capacityBytes?: number; } /** * Evaluate a prompt size against the G9.3 threshold table. * * The `force` option is the **only** path that lets a ≥ 80% prompt * through. The hook layer (PreToolUse) MUST NOT accept this option; * it is enforced by the `peaks sub-agent-dispatch-guard` atom's * command-line parser, which does not declare a `--force` flag. */ export declare function evaluatePromptSize(promptSize: number, opts?: ContextGuardOptions): ContextGuardDecision; /** * Re-export of `tierToCode` for callers that want a stable mapping * without depending on the threshold module directly. */ export { tierToCode };