/** * Leaper Agent – Approval Manager (tools/approval.ts) * * Full approval manager translating Python tools/approval.py. * Distinct from src/security/approval.ts which is a simpler guard. * Supports hardline blocks, dangerous-pattern detection, and * session/permanent approval caching. */ export type ApprovalPolicy = 'always' | 'destructive' | 'never'; export type ApprovalChoice = 'once' | 'session' | 'always' | 'deny'; export interface ApprovalRequest { command: string; description: string; patternKey: string; } export interface ApprovalResult { approved: boolean; hardline?: boolean; choice?: ApprovalChoice; message?: string; description?: string; } /** * Strip ANSI escape sequences and null bytes, then lowercase the command. */ export declare function normalizeCommand(command: string): string; /** * Test a command against HARDLINE_PATTERNS. * * Returns [true, description] when matched, [false, null] otherwise. */ export declare function detectHardlineCommand(command: string): [boolean, string | null]; /** * Test a command against DANGEROUS_PATTERNS. * * Returns [true, patternKey, description] when matched, [false, null, null] otherwise. */ export declare function detectDangerousCommand(command: string): [boolean, string | null, string | null]; export declare class ApprovalManager { private policy; private sessionApproved; private permanentApproved; private sessionKey; constructor(policy?: ApprovalPolicy, sessionKey?: string); setPolicy(policy: ApprovalPolicy): void; getPolicy(): ApprovalPolicy; getSessionKey(): string; /** * Main entry point. Evaluate whether a command is allowed to run. * * Decision order: * 1. Hardline block – always deny regardless of policy * 2. policy='never' → always allow (skip all safety checks) * 3. Not dangerous → allow * 4. Already approved (session or permanent) → allow * 5. policy='always' → deny (requires interactive approval caller cannot provide) * 6. policy='destructive' → deny with details for the caller to surface */ checkCommand(command: string): ApprovalResult; /** * Return true when the patternKey has been approved for this session or permanently. */ isApproved(patternKey: string): boolean; /** * Grant approval for the current session only. */ approveSession(patternKey: string): void; /** * Grant permanent (cross-session) approval for this pattern key. */ approvePermanent(patternKey: string): void; /** * Clear all session-level approvals (permanent approvals are retained). */ clearSession(): void; /** * Return a snapshot of currently-approved pattern keys (session + permanent). */ approvedKeys(): { session: string[]; permanent: string[]; }; } //# sourceMappingURL=approval.d.ts.map