/** * Playbook Registry Module * * Centralized registry for managing, discovering, and validating audit playbooks. * Provides functionality to: * - Register playbooks from various sources (file, string, remote) * - Search and filter playbooks by tags, author, version * - Validate playbook integrity and compatibility * - Cache parsed playbooks for performance * - Track playbook metadata and usage statistics */ import type { ParsedPlaybook, PlaybookMeta } from "./types.js"; /** * Represents a registered playbook entry with metadata */ export interface RegisteredPlaybook { id: string; source: PlaybookSource; meta: PlaybookMeta; parsedPlaybook?: ParsedPlaybook; registeredAt: Date; lastUsed?: Date; usageCount: number; validated: boolean; validationErrors?: string[]; } /** * Source information for a playbook */ export interface PlaybookSource { type: "file" | "string" | "remote" | "builtin" | "lighthouse"; location: string; hash?: string; cid?: string; } /** * Search criteria for finding playbooks */ export interface PlaybookSearchCriteria { tags?: string[]; author?: string; name?: string; minVersion?: string; severity?: string[]; aiEnabled?: boolean; } /** * Statistics about playbook usage */ export interface PlaybookStats { totalPlaybooks: number; bySource: Record; byAuthor: Record; byTags: Record; mostUsed: RegisteredPlaybook[]; recentlyAdded: RegisteredPlaybook[]; } /** * Playbook Registry Class * * Singleton registry for managing all playbooks in the system */ export declare class PlaybookRegistry { private static instance; private playbooks; private tagIndex; private authorIndex; private constructor(); /** * Get the singleton instance */ static getInstance(): PlaybookRegistry; /** * Get the lighthouse storage instance */ getLighthouseStorage(): Promise; /** * Check if content is encrypted by looking for non-printable characters */ private isEncryptedContent; /** * Register a playbook from a file */ registerFromFile(filePath: string, id?: string): Promise; /** * Register a playbook from YAML string */ registerFromString(yamlContent: string, id: string, location?: string): Promise; /** * Register all playbooks from a directory */ registerFromDirectory(dirPath: string, recursive?: boolean): Promise; /** * Register a built-in playbook */ registerBuiltin(id: string, yamlContent: string, meta?: Partial): Promise; /** * Upload and register a playbook to Lighthouse (IPFS) */ uploadAndRegisterToLighthouse(filePath: string, id?: string, progressCallback?: (progress: any) => void): Promise; /** * Register a playbook from Lighthouse by CID */ registerFromLighthouse(cid: string, id?: string): Promise; /** * Sync and register playbooks from Lighthouse uploads */ syncFromLighthouse(): Promise; /** * Get a registered playbook by ID */ get(id: string): RegisteredPlaybook | undefined; /** * Get a playbook and mark it as used */ getAndUse(id: string): RegisteredPlaybook | undefined; /** * Check if a playbook is registered */ has(id: string): boolean; /** * Unregister a playbook */ unregister(id: string): boolean; /** * Get all registered playbooks */ getAll(): RegisteredPlaybook[]; /** * Search for playbooks matching criteria */ search(criteria: PlaybookSearchCriteria): RegisteredPlaybook[]; /** * Get playbooks by tag */ getByTag(tag: string): RegisteredPlaybook[]; /** * Get playbooks by author */ getByAuthor(author: string): RegisteredPlaybook[]; /** * Get all unique tags */ getAllTags(): string[]; /** * Get all unique authors */ getAllAuthors(): string[]; /** * Get registry statistics */ getStats(): PlaybookStats; /** * Validate a playbook */ validate(id: string): { valid: boolean; errors: string[]; }; /** * Clear all registered playbooks */ clear(): void; /** * Export registry state (for persistence) */ export(): any; /** * Import registry state (for loading) */ import(data: any): void; private addToRegistry; private generateIdFromPath; private generateIdFromName; private isPlaybookFile; } /** * Convenience function to get the singleton registry instance */ export declare function getPlaybookRegistry(): PlaybookRegistry; /** * Initialize registry with default/builtin playbooks */ export declare function initializeRegistry(builtinPlaybooks?: Record): Promise; //# sourceMappingURL=registry.d.ts.map