llmverify
Version:
AI Output Verification Toolkit — Local-first LLM safety, hallucination detection, PII redaction, prompt injection defense, and runtime monitoring. Zero telemetry. OWASP LLM Top 10 aligned.
126 lines (125 loc) • 3.03 kB
TypeScript
/**
* Audit Logger
*
* Local-only audit logging for verification results.
* Supports file output and optional GitHub export.
* No external API calls - all processing is local.
*
* @module audit
* @author llmverify
* @license MIT
*/
export interface AuditEntry {
id: string;
timestamp: string;
action: 'verify' | 'classify' | 'check_pii' | 'check_injection' | 'run';
input: {
contentLength: number;
contentHash: string;
preset?: string;
};
output: {
riskLevel: string;
riskScore: number;
action: string;
findingsCount: number;
};
performance: {
latencyMs: number;
enginesUsed: string[];
};
metadata?: Record<string, unknown>;
}
export interface AuditConfig {
enabled: boolean;
outputPath?: string;
maxEntries?: number;
rotateDaily?: boolean;
includeContentHash?: boolean;
}
/**
* Audit Logger class
*/
export declare class AuditLogger {
private config;
private entries;
private currentDate;
constructor(config?: Partial<AuditConfig>);
/**
* Log a verification action
*/
log(entry: Omit<AuditEntry, 'id' | 'timestamp'>): AuditEntry;
/**
* Create audit entry from verification result
*/
createEntry(action: AuditEntry['action'], content: string, result: {
risk?: {
level: string;
overall: number;
action: string;
};
findings?: unknown[];
meta?: {
latency_ms?: number;
enginesUsed?: string[];
};
}, preset?: string): Omit<AuditEntry, 'id' | 'timestamp'>;
/**
* Write entry to file (JSONL format)
*/
private writeToFile;
/**
* Get recent entries
*/
getRecent(count?: number): AuditEntry[];
/**
* Get entries by risk level
*/
getByRiskLevel(level: string): AuditEntry[];
/**
* Get summary statistics
*/
getSummary(): {
totalEntries: number;
byRiskLevel: Record<string, number>;
byAction: Record<string, number>;
avgLatencyMs: number;
blockedCount: number;
};
/**
* Export to JSON file
*/
exportToFile(filePath: string): void;
/**
* Export for GitHub (creates markdown report)
*/
exportForGitHub(filePath: string): void;
/**
* Clear all entries
*/
clear(): void;
/**
* Enable/disable logging
*/
setEnabled(enabled: boolean): void;
}
/**
* Get or create default audit logger
*/
export declare function getAuditLogger(config?: Partial<AuditConfig>): AuditLogger;
/**
* Quick log function
*/
export declare function auditLog(action: AuditEntry['action'], content: string, result: {
risk?: {
level: string;
overall: number;
action: string;
};
findings?: unknown[];
meta?: {
latency_ms?: number;
enginesUsed?: string[];
};
}, preset?: string): AuditEntry | null;
export default AuditLogger;