import type { ParsedFrame, ResolvedFrame, ValidationReport, InterceptorDecision, PolicyOverlay, ConfidenceThresholds, ExecuteRequest, ExecuteResult, ExecutionControlConfig } from '../types/index.js'; import { HoldManager } from './hold-manager.js'; export interface AgentEvictionConfig { /** Maximum number of agents to track (default: 1000) */ maxAgents: number; /** Maximum executions to keep per agent (default: 1000) */ maxExecutionsPerAgent: number; /** Time in ms after which inactive agents are eligible for eviction (default: 30 minutes) */ inactivityThresholdMs: number; /** Enable periodic cleanup (default: true) */ enablePeriodicCleanup: boolean; /** Cleanup interval in ms (default: 5 minutes) */ cleanupIntervalMs: number; /** Log eviction events (default: true) */ logEvictions: boolean; } export declare class Gatekeeper { private resolver; private validator; private interceptor; private coverageCalculator; private holdManager; private activeFrames; private executionHistory; private agentLastActivity; private evictionConfig; private cleanupTimer; private evictionStats; constructor(evictionConfig?: Partial); /** * Update eviction configuration. */ setEvictionConfig(config: Partial): void; /** * Get current eviction configuration. */ getEvictionConfig(): AgentEvictionConfig; /** * Get eviction statistics. */ getEvictionStats(): typeof this.evictionStats & { activeAgents: number; }; /** * Start periodic cleanup timer. */ private startPeriodicCleanup; /** * Stop periodic cleanup timer. */ stopPeriodicCleanup(): void; /** * Touch agent activity timestamp (called on every operation). */ private touchAgent; /** * Evict the least recently used agent. */ private evictLeastRecentlyUsed; /** * Evict inactive agents (called periodically or on demand). */ evictInactiveAgents(): number; /** * Evict a specific agent and clean up all its data. */ private evictAgent; /** * Manually evict an agent (for testing or admin purposes). */ forceEvictAgent(agentId: string): boolean; /** * Get list of all tracked agent IDs. */ getTrackedAgents(): Array<{ agentId: string; lastActivity: number; }>; /** * Get the drift detection engine for external access. */ getDriftEngine(): import("../index.js").DriftDetectionEngine; /** * Get the hold manager for external access. */ getHoldManager(): HoldManager; /** * Set the active policy overlay. */ setOverlay(overlay: PolicyOverlay | null): void; /** * Update confidence thresholds. */ setThresholds(thresholds: ConfidenceThresholds): void; /** * Get current thresholds. */ getThresholds(): ConfidenceThresholds; /** * Set execution control configuration (human-in-the-loop, pre-flight checks). */ setExecutionControlConfig(config: Partial): void; /** * Get execution control configuration. */ getExecutionControlConfig(): ExecutionControlConfig; /** * Parse a raw frame string. * Returns an empty frame structure if parsing fails. */ parseFrame(rawFrame: string): ParsedFrame; /** * Resolve a frame with operator overrides. */ resolveFrame(frame: ParsedFrame | string): ResolvedFrame; /** * Validate a frame. */ validateFrame(frame: ParsedFrame | string, parentFrame?: ParsedFrame | string): ValidationReport; /** * Full validation pipeline: parse, resolve, validate. */ processFrame(rawFrame: string, parentFrame?: string): { parsed: ParsedFrame; resolved: ResolvedFrame; validation: ValidationReport; }; /** * Execute an action through the gatekeeper. * This is the main entry point for all agent actions. * * EXECUTION ORDER (for deterministic pre-execution blocking): * 1. CIRCUIT BREAKER CHECK - Block halted agents immediately * 2. FRAME VALIDATION - Structural/semantic validation * 3. PRE-FLIGHT DRIFT PREDICTION - Predict if this action will cause drift * 4. HOLD CHECK - Determine if human approval needed * 5. INTERCEPTOR - Final frame-based permission check * 6. TOOL EXECUTION - Only if all checks pass * 7. POST-AUDIT - Confirm behavior matches prediction * 8. IMMEDIATE ACTION - Halt agent if critical drift detected */ execute(request: ExecuteRequest): ExecuteResult; /** * Log circuit breaker block to audit trail. */ private logCircuitBreakerBlock; /** * Simulate tool execution (placeholder for actual implementation). */ private simulateToolExecution; /** * Perform post-execution audit. */ private performPostAudit; /** * Extract action names from a result object. */ private extractActionsFromResult; /** * Calculate how well actual actions matched expected. */ private calculateActionMatch; /** * Record an execution in history. */ private recordExecution; /** * Get the active frame for an agent. */ getActiveFrame(agentId: string): ResolvedFrame | undefined; /** * Clear the active frame for an agent. */ clearActiveFrame(agentId: string): void; /** * Get execution history for an agent. */ getExecutionHistory(agentId: string, limit?: number): typeof this.executionHistory extends Map ? V : never; /** * Check if an action would be allowed without executing. */ precheck(frame: string, tool: string, args: Record, parentFrame?: string): InterceptorDecision & { validationReport?: ValidationReport; coverageConfidence?: number; uncoveredAspects?: string[]; }; /** * Get agent state for ps_state tool. */ getAgentState(agentId: string): { activeFrame: string | null; lastAction: string | null; lastActionTime: number | null; delegationsAsParent: number; delegationsAsChild: number; } | null; /** * Get operation statistics. */ getOperationStats(): { total: number; successful: number; blocked: number; failed: number; }; /** * Get operation statistics for a specific agent. */ getAgentOperationStats(agentId: string): { total: number; successful: number; blocked: number; failed: number; } | null; /** * Alias for resolveFrame - resolve a frame with operator overrides. */ resolve(frame: ParsedFrame | string): ResolvedFrame; /** * Alias for validateFrame - validate a frame. */ validate(frame: ParsedFrame | string, parentFrame?: ParsedFrame | string): ValidationReport; /** * Alias for execute that returns just the interceptor decision. * Wraps execute() to provide a simpler API for action interception. */ intercept(action: string, frame: string, agentId: string): InterceptorDecision; /** * Get audit log. */ getAuditLog(limit?: number): import("../index.js").AuditLogEntry[]; /** * Get audit log for a specific agent. */ getAgentAuditLog(agentId: string, limit?: number): import("../index.js").AuditLogEntry[]; } export declare const gatekeeper: Gatekeeper; export { DynamicResolver } from './resolver.js'; export { FrameValidator } from './validator.js'; export { ActionInterceptor } from './interceptor.js'; export { CoverageCalculator } from './coverage.js'; export { HoldManager, holdManager } from './hold-manager.js'; export { driftEngine } from '../drift/index.js'; //# sourceMappingURL=index.d.ts.map