UNPKG

@openguardrails/moltguard

Version:

AI agent security plugin for OpenClaw: prompt injection detection, PII sanitization, and monitoring dashboard

82 lines 2.32 kB
/** * Simple JSONL file store for analysis logging * (No dependencies - just append-only log files) */ import type { AnalysisVerdict, AnalysisLogEntry, Logger } from "../agent/types.js"; export declare class AnalysisStore { private analysisFile; private feedbackFile; private nextAnalysisId; private nextFeedbackId; private log; constructor(logPath: string, log: Logger); /** * Log an analysis result */ logAnalysis(entry: { targetType: string; contentLength: number; chunksAnalyzed: number; verdict: AnalysisVerdict; durationMs: number; blocked: boolean; }): number; /** * Get recent analysis logs */ getRecentLogs(limit?: number): AnalysisLogEntry[]; /** * Get count of blocked analyses in time window */ getBlockedCount(windowHours?: number): number; /** * Get statistics */ getStats(): { totalAnalyses: number; totalBlocked: number; blockedLast24h: number; avgDurationMs: number; }; /** * Get recent detections (only those flagged as injection) */ getRecentDetections(limit?: number): AnalysisLogEntry[]; /** * Log user feedback (false positive or missed detection) */ logFeedback(entry: { analysisId?: number; feedbackType: "false_positive" | "missed_detection"; reason?: string; }): number; /** * Get feedback statistics */ getFeedbackStats(): { falsePositives: number; missedDetections: number; }; private get toolCallFile(); /** * Log a tool call observation locally (fallback when dashboard is unreachable) */ logToolCall(entry: { agentId: string; toolName: string; params?: Record<string, unknown>; phase: "before" | "after"; result?: unknown; error?: string; durationMs?: number; blocked?: boolean; blockReason?: string; }): void; /** * Get recent tool call observations from local log */ getRecentToolCalls(limit?: number): Array<Record<string, unknown>>; close(): void; } export declare function createAnalysisStore(logPath: string, log: Logger): AnalysisStore; //# sourceMappingURL=store.d.ts.map