/** * dsh-auto-approval-llm ยท pure decision helpers. * * These are kept free of live Cordis/DSH objects (only plain data + callbacks) * so the fail-closed contract of the approval pipeline can be unit-tested * without a running harness. */ export interface ReviewResult { decision: 'ALLOW' | 'DENY' | 'ESCALATE'; riskLevel?: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; reason?: string; failure?: string; } /** * Strictly parse a reviewer text into a {@link ReviewResult}. Any deviation * (missing JSON, invalid decision/risk level, non-string reason) throws so the * caller's catch path fails closed; a half-parsed decision is never trusted. */ export declare function parseReview(text: string): ReviewResult; export type TimeoutAction = 'reject' | 'allow'; export interface HumanDecisionStatus { seconds: number; action: TimeoutAction; } export interface HumanDecisionOptions { status: HumanDecisionStatus; callId?: string; recordTimeout: (callId: string, text: string) => void; } export interface HumanDecision { outcome: string; timedOut: boolean; } /** * Race a delegated human answer (nextPromise) against a host-authoritative * countdown. When the timer wins the request is claimed locally with the * configured timeout action and the canonical timeout notice is recorded via * the supplied callback (never via an untrusted client text). A caller that * wanted a plain delegation (no time limit) should not use this helper. */ export declare function raceHumanDecision(next: () => Promise, opts: HumanDecisionOptions): Promise; /** * Fail-closed LOW-risk reviewer outcome policy (single source of truth; the * "never auto-allow on ESCALATE/failure" rule): * - ALLOW -> allow * - DENY -> deny (counts toward the LLM-denial breaker) * - reviewer failure -> deny (fail closed; NOT an LLM denial streak) * - genuine ESCALATE -> ask human (never auto-answer uncertainty) */ export type LowRiskOutcome = { kind: 'allow'; } | { kind: 'deny'; llmDenied: boolean; } | { kind: 'ask'; }; export declare function lowRiskReviewOutcome(review: { decision: string; failure?: string; riskLevel?: string; reason?: string; }): LowRiskOutcome; /** * Unique-terminator conflict detection: given the list of installed bundle * names, report any known approval-plugin competitors that would also try to * claim `approval/request`. Kept pure so P0.7a can assert it. */ export declare function detectConflicts(bundles: Iterable): string[]; /** * Whether a reviewer result (or its absence/rejection) may be auto-answered. * ESCALATE must always surface to a human; only ALLOW/DENY are decisive. */ export declare function reviewerDecidable(decision: string): boolean; /** * Fields that are configured host-side (via patch/YAML) and never edited by * the browser settings card. A card save must preserve whatever the current * stored value holds for these, otherwise the full `settings.replace` would * silently drop them. */ export declare const HOST_ONLY_KEYS: string[]; /** * Whether the denial breaker is tripped for a session. Either threshold, when * enabled (> 0), trips; 0 disables that rail. Pure so the contract is testable. */ export declare function breakerTripped(maxConsecutive: number, maxTotal: number, consecutive: number, total: number): boolean; export declare function preserveHostKeys(current: Record, submitted: Record): Record; /** * Normalize a persisted timeoutAction for the client editor. The legacy * "llm-low-risk-only" value (subsumed by the LOW branch) is presented as and * saved back as "reject" so a card save always persists a valid value. */ export declare function normalizeTimeoutAction(value: unknown): 'reject' | 'allow' | 'low-risk-allow'; /** * Prepare the tool-call arguments recovered from the session log (a JSON text) * for the reviewer: parse to a structure and sanitize (redact secrets, bound * bulk content); when the text is not JSON, fall back to plain-text sanitizing. */ export declare function prepareReviewerArguments(raw: string | undefined | null): unknown; /** Extract the primary path argument (file_path/path/cwd/workdir) from args. */ export declare function extractToolPath(raw: string | undefined | null): string | undefined; export interface ReviewerInput { toolName: string; description?: string | null; rawArguments?: string | null; trustedUserMessages: string[]; workspaceRoot?: string; targetRelative?: string | null; inWorkspace?: boolean | null; } /** Frame the reasoning-blind reviewer payload as one JSON text. */ export declare function frameReviewerInput(input: ReviewerInput): string;