/** * Escalation Detection Service * * Parses LLM responses for escalation signals embedded as JSON blocks. * Evaluates whether escalation should be triggered based on the signal * and configured thresholds. */ import { type EscalationConfig, type EscalationParseResult, type EscalationSignal } from '../types/escalation.types.js'; export declare class EscalationDetectionService { private readonly config; private readonly logger; constructor(config?: Partial); /** * Read-only access to the effective configuration, for callers (e.g. the self-consistency * sampler) that need to know the confidence threshold or sampling policy. */ getConfig(): Readonly; /** * Parse LLM response content for escalation signal * Returns the extracted signal and cleaned content */ parseResponse(content: string): EscalationParseResult; /** * Evaluate if escalation should be triggered based on signal and config */ shouldTriggerEscalation(signal: EscalationSignal | null): boolean; /** * Build a forced escalation signal for a stage whose response omitted or malformed * the mandatory `_escalation` block, when `requireExplicitBlock` is enabled. * Returns null when `requireExplicitBlock` is disabled — the caller should then * proceed as if no escalation was required. */ getMissingSignalEscalation(stageName: string): EscalationSignal | null; /** * A high confidence claim unaccompanied by any reasoning or proposed action is * ungrounded and should not be trusted at face value. */ private hasUnsupportedConfidenceClaim; /** * Locate the `_escalation` JSON object in content by balanced-brace scanning rather than * regex truncation. For each `"_escalation":` key occurrence (scanned from the last — the * protocol requires the block at the END of the response — since prose could mention the * phrase earlier), walks backward to the enclosing `{` and forward to its matching `}`, * skipping over string-literal contents so braces inside `reasoning`/`proposed_action` text * don't miscount depth. This is robust to nesting depth and to unrelated preamble text * appearing before the JSON inside a fenced block. */ private extractRawEscalationJson; /** Extracts and validates a balanced JSON object starting at `start`, or null if unparseable. */ private tryExtractBalancedJson; /** Finds the `{` immediately following a `"_escalation":` key with no enclosing wrapper object. */ private findValueBraceStart; /** * Parse JSON string to extract EscalationSignal */ private parseEscalationJson; /** * Parse and validate risk level */ private parseRiskLevel; /** * Check if risk level is considered high */ private isHighRisk; /** * Remove the located escalation JSON object from content by index (precise — no re-guessing * with regex), then strip any markdown fence left empty around it and collapse blank lines. */ private removeEscalationBlock; } export declare function getEscalationDetectionService(config?: Partial): EscalationDetectionService; //# sourceMappingURL=escalation-detection.service.d.ts.map