@bonginkan/maria 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -2
- package/dist/bin/maria.js +21013 -11461
- package/dist/bin/maria.js.map +1 -1
- package/dist/cli.js +20094 -10752
- package/dist/cli.js.map +1 -1
- package/dist/index.js +131662 -0
- package/dist/index.js.map +1 -0
- package/dist/metafile-cjs.json +1 -0
- package/dist/services/linux-command-intelligence/command-knowledge-base.d.ts +96 -0
- package/dist/services/linux-command-intelligence/command-knowledge-base.js +597 -0
- package/dist/services/linux-command-intelligence/command-knowledge-base.js.map +1 -0
- package/dist/services/linux-command-intelligence/context-analyzer.d.ts +111 -0
- package/dist/services/linux-command-intelligence/context-analyzer.js +427 -0
- package/dist/services/linux-command-intelligence/context-analyzer.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/services/linux-command-intelligence/context-analyzer.ts","../../../src/services/linux-command-intelligence/command-knowledge-base.ts"],"names":["promisify","exec","EventEmitter"],"mappings":";;;;;;;;AAKkBA,eAAUC,kBAAI;;;AC8DzB,IAAM,oBAAA,GAAN,cAAmCC,mBAAA,CAAa;AAAA,EAnEvD;AAmEuD,IAAA,MAAA,CAAA,IAAA,EAAA,sBAAA,CAAA;AAAA;AAAA,EAC7C,QAAA;AAAA,EACA,SAAA;AAAA,EACA,gBAAA;AAAA,EACA,YAAA;AAAA,EAER,WAAA,GAAc;AACZ,IAAA,KAAA,EAAM;AACN,IAAA,IAAA,CAAK,QAAA,uBAAe,GAAA,EAAI;AACxB,IAAA,IAAA,CAAK,SAAA,uBAAgB,GAAA,EAAI;AACzB,IAAA,IAAA,CAAK,gBAAA,uBAAuB,GAAA,EAAI;AAChC,IAAA,IAAA,CAAK,YAAA,uBAAmB,GAAA,EAAI;AAC5B,IAAA,IAAA,CAAK,uBAAA,EAAwB;AAAA,EAC/B;AAAA,EAE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CAAK,YAAA,EAAc;AAC3C,UAAA,MAAM,YAAY,CAAA,MAAA,aAAA,KAAA,YAAA,QAAA,eAAA,MAAA,aAAA,UAAA,gBAAoF;AACtG,UAAA,MAAM,YAAA,GAAe,SAAA,CAAU,OAAA,CAAQ,IAAI,CAAA;AAC3C,UAAA,MAAM,QAAA,GAAW,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,IAAA,CAAK,IAAI,CAAA,EAAG,YAAA,GAAe,IAAA,CAAK,YAAY,CAAC,CAAA;AAC1E,UAAA,IAAA,GAAO,UAAU,QAAQ,CAAA,IAAA,MAAA;AAAA,QAC3B;AAAA,MACF;AAAA,IACF;AAEA,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,SAAS,MAAA,KAAW,CAAA;AAAA,MAC3B,IAAA;AAAA,MACA;AAAA,KACF;AAAA,EACF;AAAA,EAEO,mBAAmB,OAAA,EAAsC;AAC9D,IAAA,MAAM,GAAA,GAAM,IAAA,CAAK,YAAA,CAAa,GAAA,CAAI,OAAO,CAAA;AACzC,IAAA,OAAO,GAAA,GAAM,GAAA,CAAI,YAAA,GAAe,EAAC;AAAA,EACnC;AAAA,EAEO,eAAA,GAAqC;AAC1C,IAAA,OAAO,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAA;AAAA,EAC3C;AAAA,EAEO,eAAA,GAIL;AACA,IAAA,OAAO;AAAA,MACL,UAAU,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,QAAA,CAAS,QAAQ,CAAA;AAAA,MAC3C,WAAW,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,SAAA,CAAU,QAAQ,CAAA;AAAA,MAC7C,YAAY,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,gBAAA,CAAiB,QAAQ;AAAA,KACvD;AAAA,EACF;AACF","file":"command-knowledge-base.js","sourcesContent":["import { EventEmitter } from 'events';\nimport * as os from 'os';\nimport { exec } from 'child_process';\nimport { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\nexport enum CommandIntent {\n FILE_OPERATION = 'FILE_OPERATION',\n PROCESS_MANAGEMENT = 'PROCESS_MANAGEMENT',\n SYSTEM_INFO = 'SYSTEM_INFO',\n NETWORK_OPERATION = 'NETWORK_OPERATION',\n PACKAGE_MANAGEMENT = 'PACKAGE_MANAGEMENT',\n PERFORMANCE_OPTIMIZATION = 'PERFORMANCE_OPTIMIZATION',\n DISK_MANAGEMENT = 'DISK_MANAGEMENT',\n USER_MANAGEMENT = 'USER_MANAGEMENT',\n SERVICE_CONTROL = 'SERVICE_CONTROL',\n LOG_ANALYSIS = 'LOG_ANALYSIS',\n SECURITY_AUDIT = 'SECURITY_AUDIT',\n BACKUP_RESTORE = 'BACKUP_RESTORE',\n CONTAINER_OPERATION = 'CONTAINER_OPERATION',\n UNKNOWN = 'UNKNOWN'\n}\n\nexport interface LinuxCommand {\n command: string;\n args: string[];\n flags: string[];\n sudo: boolean;\n risk: RiskLevel;\n category: CommandCategory;\n description: string;\n alternatives?: LinuxCommand[];\n}\n\nexport enum RiskLevel {\n SAFE = 'SAFE',\n LOW = 'LOW',\n MEDIUM = 'MEDIUM',\n HIGH = 'HIGH',\n CRITICAL = 'CRITICAL'\n}\n\nexport enum CommandCategory {\n READ_ONLY = 'READ_ONLY',\n WRITE = 'WRITE',\n DELETE = 'DELETE',\n SYSTEM_MODIFY = 'SYSTEM_MODIFY',\n NETWORK = 'NETWORK',\n PROCESS = 'PROCESS',\n SECURITY = 'SECURITY'\n}\n\nexport interface SystemContext {\n os: string;\n platform: string;\n arch: string;\n hostname: string;\n uptime: number;\n loadAverage: number[];\n totalMemory: number;\n freeMemory: number;\n cpuUsage: number;\n diskUsage: DiskUsage[];\n networkInterfaces: any;\n currentUser: string;\n isRoot: boolean;\n environmentVariables: Record<string, string>;\n}\n\nexport interface DiskUsage {\n filesystem: string;\n size: string;\n used: string;\n available: string;\n usePercent: string;\n mountPoint: string;\n}\n\nexport interface SystemState {\n context: SystemContext;\n runningProcesses: number;\n activeServices: string[];\n openPorts: number[];\n recentCommands: string[];\n currentWorkingDirectory: string;\n timestamp: Date;\n}\n\nexport interface Action {\n type: ActionType;\n command: LinuxCommand;\n priority: number;\n reason: string;\n expectedOutcome: string;\n}\n\nexport enum ActionType {\n IMMEDIATE = 'IMMEDIATE',\n SCHEDULED = 'SCHEDULED',\n CONDITIONAL = 'CONDITIONAL',\n MONITORING = 'MONITORING',\n PREVENTIVE = 'PREVENTIVE'\n}\n\nexport class ContextAnalyzer extends EventEmitter {\n private intentPatterns: Map<CommandIntent, RegExp[]>;\n private systemState: SystemState | null = null;\n private updateInterval: NodeJS.Timeout | null = null;\n\n constructor() {\n super();\n this.intentPatterns = this.initializeIntentPatterns();\n this.startSystemMonitoring();\n }\n\n private initializeIntentPatterns(): Map<CommandIntent, RegExp[]> {\n const patterns = new Map<CommandIntent, RegExp[]>();\n\n patterns.set(CommandIntent.FILE_OPERATION, [\n /\\b(file|files|directory|folder|copy|move|delete|remove|create|mkdir|touch|find|search|locate)\\b/i,\n /\\b(ls|cd|pwd|cp|mv|rm|mkdir|rmdir|touch|find|grep|sed|awk)\\b/i,\n /\\b(permission|chmod|chown|access)\\b/i\n ]);\n\n patterns.set(CommandIntent.PROCESS_MANAGEMENT, [\n /\\b(process|processes|kill|stop|start|restart|pid|running|ps|top|htop)\\b/i,\n /\\b(cpu|memory|usage|performance|slow|hang|frozen|unresponsive)\\b/i,\n /\\b(service|daemon|systemctl|systemd)\\b/i\n ]);\n\n patterns.set(CommandIntent.SYSTEM_INFO, [\n /\\b(system|info|information|status|check|show|display|version|kernel)\\b/i,\n /\\b(uname|hostname|uptime|date|who|w|df|du|free)\\b/i,\n /\\b(hardware|cpu|memory|disk|network)\\b/i\n ]);\n\n patterns.set(CommandIntent.NETWORK_OPERATION, [\n /\\b(network|connection|internet|wifi|ethernet|ip|port|socket)\\b/i,\n /\\b(ping|traceroute|netstat|ss|lsof|tcpdump|curl|wget|nc)\\b/i,\n /\\b(firewall|iptables|routing|dns)\\b/i\n ]);\n\n patterns.set(CommandIntent.PACKAGE_MANAGEMENT, [\n /\\b(install|uninstall|update|upgrade|package|dependency|library)\\b/i,\n /\\b(apt|yum|dnf|snap|brew|npm|pip|gem|cargo|docker)\\b/i,\n /\\b(software|application|program)\\b/i\n ]);\n\n patterns.set(CommandIntent.PERFORMANCE_OPTIMIZATION, [\n /\\b(optimize|performance|speed|slow|fast|improve|enhance)\\b/i,\n /\\b(cache|clean|cleanup|free|space|memory|swap)\\b/i,\n /\\b(benchmark|profile|analyze)\\b/i\n ]);\n\n patterns.set(CommandIntent.DISK_MANAGEMENT, [\n /\\b(disk|storage|partition|mount|unmount|filesystem|volume)\\b/i,\n /\\b(df|du|fdisk|mkfs|fsck|mount|umount)\\b/i,\n /\\b(space|full|usage|capacity)\\b/i\n ]);\n\n patterns.set(CommandIntent.LOG_ANALYSIS, [\n /\\b(log|logs|journal|syslog|error|warning|debug|trace)\\b/i,\n /\\b(tail|head|journalctl|dmesg|last|history)\\b/i,\n /\\b(analyze|parse|filter|search)\\b/i\n ]);\n\n patterns.set(CommandIntent.SECURITY_AUDIT, [\n /\\b(security|audit|vulnerability|scan|check|permission|access)\\b/i,\n /\\b(sudo|root|privilege|authentication|password|ssh|ssl)\\b/i,\n /\\b(firewall|selinux|apparmor|encryption)\\b/i\n ]);\n\n patterns.set(CommandIntent.BACKUP_RESTORE, [\n /\\b(backup|restore|archive|compress|extract|tar|zip|rsync)\\b/i,\n /\\b(snapshot|recovery|disaster|migrate)\\b/i,\n /\\b(save|preserve|protect)\\b/i\n ]);\n\n return patterns;\n }\n\n public async analyzeUserIntent(input: string): Promise<CommandIntent> {\n const scores = new Map<CommandIntent, number>();\n\n for (const [intent, patterns] of this.intentPatterns) {\n let score = 0;\n for (const pattern of patterns) {\n const matches = input.match(pattern);\n if (matches) {\n score += matches.length;\n }\n }\n scores.set(intent, score);\n }\n\n let maxScore = 0;\n let detectedIntent = CommandIntent.UNKNOWN;\n\n for (const [intent, score] of scores) {\n if (score > maxScore) {\n maxScore = score;\n detectedIntent = intent;\n }\n }\n\n this.emit('intentAnalyzed', { input, intent: detectedIntent, confidence: maxScore });\n return detectedIntent;\n }\n\n public async determineRequiredCommands(intent: CommandIntent): Promise<LinuxCommand[]> {\n const commands: LinuxCommand[] = [];\n\n switch (intent) {\n case CommandIntent.FILE_OPERATION:\n commands.push(\n this.createCommand('ls', ['-la'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('find', ['.', '-type', 'f'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n break;\n\n case CommandIntent.PROCESS_MANAGEMENT:\n commands.push(\n this.createCommand('ps', ['aux'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('top', ['-b', '-n', '1'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n break;\n\n case CommandIntent.SYSTEM_INFO:\n commands.push(\n this.createCommand('uname', ['-a'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('df', ['-h'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('free', ['-h'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n break;\n\n case CommandIntent.NETWORK_OPERATION:\n commands.push(\n this.createCommand('netstat', ['-tuln'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('ss', ['-tuln'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n break;\n\n case CommandIntent.PERFORMANCE_OPTIMIZATION:\n commands.push(\n this.createCommand('vmstat', ['1', '5'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('iostat', ['-x', '1', '5'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n break;\n\n case CommandIntent.DISK_MANAGEMENT:\n commands.push(\n this.createCommand('df', ['-h'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('du', ['-sh', '*'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('lsblk', [], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n break;\n\n case CommandIntent.LOG_ANALYSIS:\n commands.push(\n this.createCommand('journalctl', ['-xe', '--no-pager', '-n', '50'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY),\n this.createCommand('dmesg', ['--level=err,warn', '-T'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n break;\n\n default:\n commands.push(\n this.createCommand('echo', ['Intent not recognized'], [], false, RiskLevel.SAFE, CommandCategory.READ_ONLY)\n );\n }\n\n return commands;\n }\n\n public async assessSystemState(): Promise<SystemContext> {\n const context: SystemContext = {\n os: os.type(),\n platform: os.platform(),\n arch: os.arch(),\n hostname: os.hostname(),\n uptime: os.uptime(),\n loadAverage: os.loadavg(),\n totalMemory: os.totalmem(),\n freeMemory: os.freemem(),\n cpuUsage: await this.getCPUUsage(),\n diskUsage: await this.getDiskUsage(),\n networkInterfaces: os.networkInterfaces(),\n currentUser: os.userInfo().username,\n isRoot: process.getuid ? process.getuid() === 0 : false,\n environmentVariables: process.env as Record<string, string>\n };\n\n return context;\n }\n\n public async predictNextActions(currentState: SystemState): Promise<Action[]> {\n const actions: Action[] = [];\n const context = currentState.context;\n\n // Check memory usage\n const memoryUsagePercent = ((context.totalMemory - context.freeMemory) / context.totalMemory) * 100;\n if (memoryUsagePercent > 80) {\n actions.push({\n type: ActionType.IMMEDIATE,\n command: this.createCommand(\n 'sync',\n [],\n [],\n false,\n RiskLevel.SAFE,\n CommandCategory.SYSTEM_MODIFY,\n 'Sync filesystem buffers'\n ),\n priority: 1,\n reason: 'High memory usage detected',\n expectedOutcome: 'Free up memory by syncing buffers'\n });\n\n actions.push({\n type: ActionType.CONDITIONAL,\n command: this.createCommand(\n 'echo',\n ['3'],\n [],\n true,\n RiskLevel.MEDIUM,\n CommandCategory.SYSTEM_MODIFY,\n 'Clear page cache'\n ),\n priority: 2,\n reason: 'Memory usage critical',\n expectedOutcome: 'Drop caches to free memory'\n });\n }\n\n // Check disk usage\n for (const disk of context.diskUsage) {\n const usage = parseInt(disk.usePercent);\n if (usage > 90) {\n actions.push({\n type: ActionType.IMMEDIATE,\n command: this.createCommand(\n 'find',\n [disk.mountPoint, '-type', 'f', '-size', '+100M'],\n [],\n false,\n RiskLevel.SAFE,\n CommandCategory.READ_ONLY,\n 'Find large files'\n ),\n priority: 1,\n reason: `Disk usage critical on ${disk.mountPoint}`,\n expectedOutcome: 'Identify large files for cleanup'\n });\n }\n }\n\n // Check load average\n const loadThreshold = os.cpus().length * 2;\n const loadAvg = context.loadAverage?.[0];\n if (loadAvg && loadAvg > loadThreshold) {\n actions.push({\n type: ActionType.MONITORING,\n command: this.createCommand(\n 'top',\n ['-b', '-n', '1', '-o', '%CPU'],\n [],\n false,\n RiskLevel.SAFE,\n CommandCategory.READ_ONLY,\n 'Monitor CPU usage'\n ),\n priority: 1,\n reason: 'High system load detected',\n expectedOutcome: 'Identify resource-intensive processes'\n });\n }\n\n // Preventive maintenance\n if (context.uptime > 86400 * 30) { // 30 days\n actions.push({\n type: ActionType.PREVENTIVE,\n command: this.createCommand(\n 'apt',\n ['update'],\n [],\n true,\n RiskLevel.LOW,\n CommandCategory.SYSTEM_MODIFY,\n 'Update package lists'\n ),\n priority: 3,\n reason: 'System running for over 30 days',\n expectedOutcome: 'Ensure package lists are current'\n });\n }\n\n return actions.sort((a, b) => a.priority - b.priority);\n }\n\n private createCommand(\n command: string,\n args: string[],\n flags: string[],\n sudo: boolean,\n risk: RiskLevel,\n category: CommandCategory,\n description: string = ''\n ): LinuxCommand {\n return {\n command,\n args,\n flags,\n sudo,\n risk,\n category,\n description\n };\n }\n\n private async getCPUUsage(): Promise<number> {\n try {\n const { stdout } = await execAsync(\"top -b -n 1 | grep 'Cpu(s)' | awk '{print $2}' | cut -d'%' -f1\");\n return parseFloat(stdout.trim()) || 0;\n } catch {\n return 0;\n }\n }\n\n private async getDiskUsage(): Promise<DiskUsage[]> {\n try {\n const { stdout } = await execAsync('df -h');\n const lines = stdout.trim().split('\\n').slice(1);\n \n return lines.map(line => {\n const parts = line.split(/\\s+/);\n return {\n filesystem: parts[0] || '',\n size: parts[1] || '',\n used: parts[2] || '',\n available: parts[3] || '',\n usePercent: parts[4] || '',\n mountPoint: parts[5] || ''\n };\n });\n } catch {\n return [];\n }\n }\n\n private async updateSystemState(): Promise<void> {\n const context = await this.assessSystemState();\n \n let activeServices: string[] = [];\n let openPorts: number[] = [];\n let runningProcesses = 0;\n\n try {\n const { stdout: psOutput } = await execAsync('ps aux | wc -l');\n runningProcesses = parseInt(psOutput.trim()) - 1;\n } catch {}\n\n try {\n if (process.platform === 'linux') {\n const { stdout } = await execAsync('systemctl list-units --state=running --no-pager --no-legend | head -20');\n activeServices = stdout.trim().split('\\n').map(line => line.split(/\\s+/)[0] || '').filter(s => s);\n }\n } catch {}\n\n try {\n const { stdout } = await execAsync('netstat -tuln | grep LISTEN');\n openPorts = stdout.trim().split('\\n').map(line => {\n const match = line.match(/:(\\d+)\\s/);\n return match && match[1] ? parseInt(match[1]) : 0;\n }).filter(port => port > 0);\n } catch {}\n\n this.systemState = {\n context,\n runningProcesses,\n activeServices,\n openPorts,\n recentCommands: [],\n currentWorkingDirectory: process.cwd(),\n timestamp: new Date()\n };\n\n this.emit('systemStateUpdated', this.systemState);\n }\n\n private startSystemMonitoring(): void {\n this.updateSystemState();\n this.updateInterval = setInterval(() => {\n this.updateSystemState();\n }, 30000);\n }\n\n public stopMonitoring(): void {\n if (this.updateInterval) {\n clearInterval(this.updateInterval);\n this.updateInterval = null;\n }\n }\n\n public getSystemState(): SystemState | null {\n return this.systemState;\n }\n}","import { EventEmitter } from 'events';\nimport { LinuxCommand, RiskLevel, CommandCategory } from './context-analyzer';\n\nexport interface CommandDefinition {\n name: string;\n description: string;\n category: CommandCategory;\n riskLevel: RiskLevel;\n syntax: string;\n commonFlags: FlagDefinition[];\n examples: CommandExample[];\n manPage?: string;\n requiresSudo: boolean;\n alternatives: string[];\n safetyNotes: string[];\n platform: string[];\n}\n\nexport interface FlagDefinition {\n flag: string;\n description: string;\n argument?: string;\n riskModifier?: number;\n}\n\nexport interface CommandExample {\n command: string;\n description: string;\n risk: RiskLevel;\n output?: string;\n}\n\nexport interface CommandSequence {\n name: string;\n description: string;\n steps: LinuxCommand[];\n rollback?: LinuxCommand[];\n conditions?: ExecutionCondition[];\n}\n\nexport interface ExecutionCondition {\n type: 'pre' | 'post' | 'between';\n check: string;\n onFail?: 'abort' | 'skip' | 'continue';\n}\n\nexport interface SafetyGuideline {\n command: string;\n guidelines: string[];\n forbiddenPatterns: RegExp[];\n requiresConfirmation: boolean;\n backupRequired: boolean;\n}\n\nexport interface CommandAlternative {\n original: string;\n alternatives: AlternativeOption[];\n}\n\nexport interface AlternativeOption {\n command: string;\n reason: string;\n pros: string[];\n cons: string[];\n preferredWhen: string;\n}\n\nexport class CommandKnowledgeBase extends EventEmitter {\n private commands: Map<string, CommandDefinition>;\n private workflows: Map<string, CommandSequence>;\n private safetyGuidelines: Map<string, SafetyGuideline>;\n private alternatives: Map<string, CommandAlternative>;\n\n constructor() {\n super();\n this.commands = new Map();\n this.workflows = new Map();\n this.safetyGuidelines = new Map();\n this.alternatives = new Map();\n this.initializeKnowledgeBase();\n }\n\n private initializeKnowledgeBase(): void {\n this.initializeFileCommands();\n this.initializeProcessCommands();\n this.initializeNetworkCommands();\n this.initializeSystemCommands();\n this.initializeWorkflows();\n this.initializeSafetyGuidelines();\n this.initializeAlternatives();\n }\n\n private initializeFileCommands(): void {\n // ls command\n this.commands.set('ls', {\n name: 'ls',\n description: 'List directory contents',\n category: CommandCategory.READ_ONLY,\n riskLevel: RiskLevel.SAFE,\n syntax: 'ls [OPTIONS] [FILE]...',\n commonFlags: [\n { flag: '-l', description: 'Long format listing' },\n { flag: '-a', description: 'Show all files including hidden' },\n { flag: '-h', description: 'Human readable sizes' },\n { flag: '-R', description: 'Recursive listing' },\n { flag: '-t', description: 'Sort by modification time' },\n { flag: '-S', description: 'Sort by file size' }\n ],\n examples: [\n { command: 'ls -la', description: 'List all files in long format', risk: RiskLevel.SAFE },\n { command: 'ls -lah /var/log', description: 'List log files with sizes', risk: RiskLevel.SAFE }\n ],\n requiresSudo: false,\n alternatives: ['dir', 'find', 'tree'],\n safetyNotes: ['Safe for all operations', 'No data modification'],\n platform: ['linux', 'darwin', 'unix']\n });\n\n // rm command\n this.commands.set('rm', {\n name: 'rm',\n description: 'Remove files or directories',\n category: CommandCategory.DELETE,\n riskLevel: RiskLevel.HIGH,\n syntax: 'rm [OPTIONS] FILE...',\n commonFlags: [\n { flag: '-r', description: 'Recursive removal', riskModifier: 2 },\n { flag: '-f', description: 'Force removal without prompt', riskModifier: 2 },\n { flag: '-i', description: 'Interactive mode', riskModifier: -1 },\n { flag: '-v', description: 'Verbose output' }\n ],\n examples: [\n { command: 'rm file.txt', description: 'Remove single file', risk: RiskLevel.MEDIUM },\n { command: 'rm -rf directory/', description: 'Force remove directory', risk: RiskLevel.CRITICAL }\n ],\n requiresSudo: false,\n alternatives: ['trash', 'mv to /tmp', 'unlink'],\n safetyNotes: [\n 'IRREVERSIBLE operation',\n 'Always verify path before execution',\n 'Consider using trash instead',\n 'Never use rm -rf / or rm -rf /*'\n ],\n platform: ['linux', 'darwin', 'unix']\n });\n\n // find command\n this.commands.set('find', {\n name: 'find',\n description: 'Search for files and directories',\n category: CommandCategory.READ_ONLY,\n riskLevel: RiskLevel.SAFE,\n syntax: 'find [PATH] [OPTIONS] [EXPRESSION]',\n commonFlags: [\n { flag: '-name', description: 'Search by name pattern', argument: 'pattern' },\n { flag: '-type', description: 'Search by type', argument: 'f|d|l' },\n { flag: '-size', description: 'Search by size', argument: '+/-size' },\n { flag: '-mtime', description: 'Modified time', argument: '+/-days' },\n { flag: '-exec', description: 'Execute command on results', argument: 'command', riskModifier: 3 },\n { flag: '-delete', description: 'Delete found files', riskModifier: 5 }\n ],\n examples: [\n { command: 'find . -name \"*.log\"', description: 'Find all log files', risk: RiskLevel.SAFE },\n { command: 'find /tmp -mtime +7 -delete', description: 'Delete old temp files', risk: RiskLevel.HIGH }\n ],\n requiresSudo: false,\n alternatives: ['locate', 'fd', 'grep -r'],\n safetyNotes: [\n 'Be careful with -exec and -delete flags',\n 'Test with -print first before destructive operations',\n 'Use -maxdepth to limit recursion'\n ],\n platform: ['linux', 'darwin', 'unix']\n });\n\n // chmod command\n this.commands.set('chmod', {\n name: 'chmod',\n description: 'Change file permissions',\n category: CommandCategory.WRITE,\n riskLevel: RiskLevel.MEDIUM,\n syntax: 'chmod [OPTIONS] MODE FILE...',\n commonFlags: [\n { flag: '-R', description: 'Recursive change', riskModifier: 2 },\n { flag: '-v', description: 'Verbose output' },\n { flag: '-c', description: 'Report only changes' },\n { flag: '--preserve-root', description: 'Fail on root', riskModifier: -2 }\n ],\n examples: [\n { command: 'chmod 644 file.txt', description: 'Set read/write for owner, read for others', risk: RiskLevel.LOW },\n { command: 'chmod +x script.sh', description: 'Make file executable', risk: RiskLevel.MEDIUM },\n { command: 'chmod -R 777 /', description: 'DANGEROUS: Open all permissions', risk: RiskLevel.CRITICAL }\n ],\n requiresSudo: false,\n alternatives: ['setfacl', 'chown'],\n safetyNotes: [\n 'Incorrect permissions can break system',\n 'Never use 777 on system files',\n 'Understand octal notation before use',\n 'Can affect security if misused'\n ],\n platform: ['linux', 'darwin', 'unix']\n });\n }\n\n private initializeProcessCommands(): void {\n // ps command\n this.commands.set('ps', {\n name: 'ps',\n description: 'Display process status',\n category: CommandCategory.READ_ONLY,\n riskLevel: RiskLevel.SAFE,\n syntax: 'ps [OPTIONS]',\n commonFlags: [\n { flag: 'aux', description: 'All processes with details' },\n { flag: '-ef', description: 'Full format listing' },\n { flag: '-p', description: 'Select by PID', argument: 'pid' },\n { flag: '-u', description: 'Select by user', argument: 'user' }\n ],\n examples: [\n { command: 'ps aux', description: 'Show all processes', risk: RiskLevel.SAFE },\n { command: 'ps -ef | grep nginx', description: 'Find nginx processes', risk: RiskLevel.SAFE }\n ],\n requiresSudo: false,\n alternatives: ['top', 'htop', 'pgrep'],\n safetyNotes: ['Read-only operation', 'Safe for monitoring'],\n platform: ['linux', 'darwin', 'unix']\n });\n\n // kill command\n this.commands.set('kill', {\n name: 'kill',\n description: 'Terminate processes',\n category: CommandCategory.PROCESS,\n riskLevel: RiskLevel.HIGH,\n syntax: 'kill [OPTIONS] PID...',\n commonFlags: [\n { flag: '-9', description: 'Force kill (SIGKILL)', riskModifier: 2 },\n { flag: '-15', description: 'Graceful termination (SIGTERM)' },\n { flag: '-l', description: 'List signal names' },\n { flag: '-s', description: 'Specify signal', argument: 'signal' }\n ],\n examples: [\n { command: 'kill 1234', description: 'Terminate process 1234', risk: RiskLevel.MEDIUM },\n { command: 'kill -9 1234', description: 'Force kill process 1234', risk: RiskLevel.HIGH }\n ],\n requiresSudo: false,\n alternatives: ['killall', 'pkill', 'systemctl stop'],\n safetyNotes: [\n 'Can cause data loss if process is writing',\n 'Try graceful termination first',\n 'Never kill system critical processes',\n 'Verify PID before killing'\n ],\n platform: ['linux', 'darwin', 'unix']\n });\n\n // systemctl command\n this.commands.set('systemctl', {\n name: 'systemctl',\n description: 'Control systemd services',\n category: CommandCategory.SYSTEM_MODIFY,\n riskLevel: RiskLevel.MEDIUM,\n syntax: 'systemctl [OPTIONS] COMMAND [SERVICE]',\n commonFlags: [\n { flag: 'status', description: 'Show service status' },\n { flag: 'start', description: 'Start service', riskModifier: 1 },\n { flag: 'stop', description: 'Stop service', riskModifier: 2 },\n { flag: 'restart', description: 'Restart service', riskModifier: 2 },\n { flag: 'enable', description: 'Enable at boot', riskModifier: 1 },\n { flag: 'disable', description: 'Disable at boot', riskModifier: 1 }\n ],\n examples: [\n { command: 'systemctl status nginx', description: 'Check nginx status', risk: RiskLevel.SAFE },\n { command: 'systemctl restart mysql', description: 'Restart MySQL', risk: RiskLevel.MEDIUM }\n ],\n requiresSudo: true,\n alternatives: ['service', 'init.d scripts', 'supervisorctl'],\n safetyNotes: [\n 'Can affect system availability',\n 'Check dependencies before stopping',\n 'Some services are critical for system operation'\n ],\n platform: ['linux']\n });\n }\n\n private initializeNetworkCommands(): void {\n // netstat command\n this.commands.set('netstat', {\n name: 'netstat',\n description: 'Display network connections',\n category: CommandCategory.READ_ONLY,\n riskLevel: RiskLevel.SAFE,\n syntax: 'netstat [OPTIONS]',\n commonFlags: [\n { flag: '-t', description: 'TCP connections' },\n { flag: '-u', description: 'UDP connections' },\n { flag: '-l', description: 'Listening ports' },\n { flag: '-n', description: 'Numerical addresses' },\n { flag: '-p', description: 'Show process info' },\n { flag: '-a', description: 'All connections' }\n ],\n examples: [\n { command: 'netstat -tuln', description: 'Show listening ports', risk: RiskLevel.SAFE },\n { command: 'netstat -anp | grep :80', description: 'Find process on port 80', risk: RiskLevel.SAFE }\n ],\n requiresSudo: false,\n alternatives: ['ss', 'lsof -i', 'sockstat'],\n safetyNotes: ['Read-only operation', 'May require sudo for process info'],\n platform: ['linux', 'darwin', 'unix']\n });\n\n // iptables command\n this.commands.set('iptables', {\n name: 'iptables',\n description: 'Configure Linux firewall',\n category: CommandCategory.SECURITY,\n riskLevel: RiskLevel.CRITICAL,\n syntax: 'iptables [OPTIONS] [CHAIN] [RULE]',\n commonFlags: [\n { flag: '-L', description: 'List rules' },\n { flag: '-A', description: 'Append rule', riskModifier: 3 },\n { flag: '-D', description: 'Delete rule', riskModifier: 3 },\n { flag: '-F', description: 'Flush all rules', riskModifier: 5 },\n { flag: '-P', description: 'Set default policy', riskModifier: 4 }\n ],\n examples: [\n { command: 'iptables -L', description: 'List firewall rules', risk: RiskLevel.SAFE },\n { command: 'iptables -A INPUT -p tcp --dport 22 -j ACCEPT', description: 'Allow SSH', risk: RiskLevel.HIGH }\n ],\n requiresSudo: true,\n alternatives: ['ufw', 'firewalld', 'nftables'],\n safetyNotes: [\n 'Can lock you out of system',\n 'Always have backup access',\n 'Test rules before applying permanently',\n 'Incorrect rules can break networking'\n ],\n platform: ['linux']\n });\n }\n\n private initializeSystemCommands(): void {\n // df command\n this.commands.set('df', {\n name: 'df',\n description: 'Display disk space usage',\n category: CommandCategory.READ_ONLY,\n riskLevel: RiskLevel.SAFE,\n syntax: 'df [OPTIONS] [FILE]...',\n commonFlags: [\n { flag: '-h', description: 'Human readable sizes' },\n { flag: '-T', description: 'Show filesystem type' },\n { flag: '-i', description: 'Show inode information' },\n { flag: '-a', description: 'Include all filesystems' }\n ],\n examples: [\n { command: 'df -h', description: 'Show disk usage in human format', risk: RiskLevel.SAFE },\n { command: 'df -hT /', description: 'Show root filesystem details', risk: RiskLevel.SAFE }\n ],\n requiresSudo: false,\n alternatives: ['du', 'lsblk', 'fdisk -l'],\n safetyNotes: ['Read-only operation', 'Safe for all users'],\n platform: ['linux', 'darwin', 'unix']\n });\n\n // mount command\n this.commands.set('mount', {\n name: 'mount',\n description: 'Mount filesystems',\n category: CommandCategory.SYSTEM_MODIFY,\n riskLevel: RiskLevel.HIGH,\n syntax: 'mount [OPTIONS] DEVICE MOUNTPOINT',\n commonFlags: [\n { flag: '-t', description: 'Filesystem type', argument: 'type' },\n { flag: '-o', description: 'Mount options', argument: 'options' },\n { flag: '-r', description: 'Read-only mount', riskModifier: -1 },\n { flag: '-a', description: 'Mount all in fstab', riskModifier: 2 }\n ],\n examples: [\n { command: 'mount', description: 'Show mounted filesystems', risk: RiskLevel.SAFE },\n { command: 'mount /dev/sdb1 /mnt', description: 'Mount device to /mnt', risk: RiskLevel.HIGH }\n ],\n requiresSudo: true,\n alternatives: ['umount', 'findmnt', 'lsblk'],\n safetyNotes: [\n 'Can overwrite existing mount points',\n 'Verify device before mounting',\n 'Incorrect options can corrupt data',\n 'Always unmount before removal'\n ],\n platform: ['linux', 'unix']\n });\n }\n\n private initializeWorkflows(): void {\n // System health check workflow\n this.workflows.set('system-health-check', {\n name: 'system-health-check',\n description: 'Comprehensive system health assessment',\n steps: [\n this.createCommand('uptime', [], RiskLevel.SAFE),\n this.createCommand('free', ['-h'], RiskLevel.SAFE),\n this.createCommand('df', ['-h'], RiskLevel.SAFE),\n this.createCommand('ps', ['aux', '--sort=-pcpu', '|', 'head', '-10'], RiskLevel.SAFE),\n this.createCommand('netstat', ['-tuln'], RiskLevel.SAFE),\n this.createCommand('systemctl', ['list-units', '--failed'], RiskLevel.SAFE)\n ],\n conditions: [\n {\n type: 'pre',\n check: 'command -v systemctl',\n onFail: 'skip'\n }\n ]\n });\n\n // Disk cleanup workflow\n this.workflows.set('disk-cleanup', {\n name: 'disk-cleanup',\n description: 'Free up disk space safely',\n steps: [\n this.createCommand('df', ['-h'], RiskLevel.SAFE),\n this.createCommand('du', ['-sh', '/var/log/*'], RiskLevel.SAFE),\n this.createCommand('find', ['/tmp', '-type', 'f', '-mtime', '+7', '-size', '+10M'], RiskLevel.SAFE),\n this.createCommand('journalctl', ['--vacuum-time=7d'], RiskLevel.MEDIUM),\n this.createCommand('apt', ['autoremove', '-y'], RiskLevel.MEDIUM),\n this.createCommand('apt', ['clean'], RiskLevel.LOW)\n ],\n rollback: [\n this.createCommand('echo', ['Cleanup completed, no rollback needed'], RiskLevel.SAFE)\n ],\n conditions: [\n {\n type: 'pre',\n check: 'test $(df / | awk \"NR==2 {print $5}\" | sed \"s/%//\") -gt 80',\n onFail: 'abort'\n }\n ]\n });\n\n // Security audit workflow\n this.workflows.set('security-audit', {\n name: 'security-audit',\n description: 'Basic security assessment',\n steps: [\n this.createCommand('who', [], RiskLevel.SAFE),\n this.createCommand('last', ['-10'], RiskLevel.SAFE),\n this.createCommand('netstat', ['-tuln'], RiskLevel.SAFE),\n this.createCommand('ps', ['aux', '|', 'grep', 'root'], RiskLevel.SAFE),\n this.createCommand('find', ['/', '-perm', '-4000', '-type', 'f', '2>/dev/null'], RiskLevel.SAFE),\n this.createCommand('iptables', ['-L', '-n'], RiskLevel.SAFE)\n ]\n });\n }\n\n private initializeSafetyGuidelines(): void {\n // rm safety guidelines\n this.safetyGuidelines.set('rm', {\n command: 'rm',\n guidelines: [\n 'Always use absolute paths when possible',\n 'Verify path with ls first',\n 'Use -i flag for interactive confirmation',\n 'Consider using trash-cli instead',\n 'Never use variables in rm commands without validation'\n ],\n forbiddenPatterns: [\n /rm\\s+-rf\\s+\\/$/,\n /rm\\s+-rf\\s+\\/\\*/,\n /rm\\s+-rf\\s+~$/,\n /rm\\s+-rf\\s+\\$HOME$/\n ],\n requiresConfirmation: true,\n backupRequired: true\n });\n\n // chmod safety guidelines\n this.safetyGuidelines.set('chmod', {\n command: 'chmod',\n guidelines: [\n 'Understand permission implications',\n 'Never use 777 on system files',\n 'Test on non-critical files first',\n 'Use symbolic notation when unsure'\n ],\n forbiddenPatterns: [\n /chmod\\s+777\\s+\\//,\n /chmod\\s+-R\\s+777/,\n /chmod\\s+000\\s+\\//\n ],\n requiresConfirmation: true,\n backupRequired: false\n });\n\n // dd safety guidelines \n this.safetyGuidelines.set('dd', {\n command: 'dd',\n guidelines: [\n 'Double-check input and output devices',\n 'Never confuse if= and of=',\n 'Use conv=sync,noerror for recovery',\n 'Always specify block size'\n ],\n forbiddenPatterns: [\n /dd\\s+.*of=\\/dev\\/[sh]da$/\n ],\n requiresConfirmation: true,\n backupRequired: true\n });\n }\n\n private initializeAlternatives(): void {\n // rm alternatives\n this.alternatives.set('rm', {\n original: 'rm',\n alternatives: [\n {\n command: 'trash-cli',\n reason: 'Moves files to trash instead of permanent deletion',\n pros: ['Recoverable', 'Safer', 'User-friendly'],\n cons: ['Requires installation', 'Uses more disk space temporarily'],\n preferredWhen: 'Working with important files or uncertain about deletion'\n },\n {\n command: 'mv to /tmp',\n reason: 'Move files to temp directory for later cleanup',\n pros: ['Recoverable until reboot', 'No additional tools needed'],\n cons: ['Manual cleanup needed', '/tmp has size limits'],\n preferredWhen: 'Need temporary safety net without installing tools'\n }\n ]\n });\n\n // netstat alternatives\n this.alternatives.set('netstat', {\n original: 'netstat',\n alternatives: [\n {\n command: 'ss',\n reason: 'Modern replacement for netstat with better performance',\n pros: ['Faster', 'More features', 'Better TCP state info'],\n cons: ['Different syntax', 'Not available on older systems'],\n preferredWhen: 'Working on modern Linux systems'\n },\n {\n command: 'lsof -i',\n reason: 'Shows network connections with process details',\n pros: ['Detailed process info', 'Cross-platform'],\n cons: ['Slower', 'More verbose output'],\n preferredWhen: 'Need detailed process and file descriptor info'\n }\n ]\n });\n\n // ps alternatives\n this.alternatives.set('ps', {\n original: 'ps',\n alternatives: [\n {\n command: 'top',\n reason: 'Real-time process monitoring',\n pros: ['Live updates', 'Interactive', 'CPU/Memory sorting'],\n cons: ['Not scriptable', 'Terminal-based only'],\n preferredWhen: 'Interactive monitoring and troubleshooting'\n },\n {\n command: 'htop',\n reason: 'Enhanced interactive process viewer',\n pros: ['Better UI', 'Tree view', 'Mouse support'],\n cons: ['Requires installation', 'Not scriptable'],\n preferredWhen: 'Interactive monitoring with better visualization'\n },\n {\n command: 'pgrep/pkill',\n reason: 'Process selection by pattern',\n pros: ['Simple pattern matching', 'Scriptable'],\n cons: ['Limited output format', 'Less detail'],\n preferredWhen: 'Finding or killing processes by name'\n }\n ]\n });\n }\n\n private createCommand(\n command: string,\n args: string[],\n risk: RiskLevel\n ): LinuxCommand {\n return {\n command,\n args,\n flags: [],\n sudo: false,\n risk,\n category: CommandCategory.READ_ONLY,\n description: ''\n };\n }\n\n public getCommand(name: string | undefined): CommandDefinition | undefined {\n if (!name) return undefined;\n return this.commands.get(name);\n }\n\n public getWorkflow(name: string): CommandSequence | undefined {\n return this.workflows.get(name);\n }\n\n public getSafetyGuidelines(command: string): SafetyGuideline | undefined {\n return this.safetyGuidelines.get(command);\n }\n\n public getAlternatives(command: string): CommandAlternative | undefined {\n return this.alternatives.get(command);\n }\n\n public searchCommands(query: string): CommandDefinition[] {\n const results: CommandDefinition[] = [];\n const lowerQuery = query.toLowerCase();\n\n for (const cmd of this.commands.values()) {\n if (\n cmd.name.includes(lowerQuery) ||\n cmd.description.toLowerCase().includes(lowerQuery)\n ) {\n results.push(cmd);\n }\n }\n\n return results;\n }\n\n public getCommandsByCategory(category: CommandCategory): CommandDefinition[] {\n return Array.from(this.commands.values()).filter(\n cmd => cmd.category === category\n );\n }\n\n public getCommandsByRiskLevel(maxRisk: RiskLevel): CommandDefinition[] {\n const riskOrder = {\n [RiskLevel.SAFE]: 0,\n [RiskLevel.LOW]: 1,\n [RiskLevel.MEDIUM]: 2,\n [RiskLevel.HIGH]: 3,\n [RiskLevel.CRITICAL]: 4\n };\n\n const maxRiskValue = riskOrder[maxRisk];\n\n return Array.from(this.commands.values()).filter(\n cmd => riskOrder[cmd.riskLevel] <= maxRiskValue\n );\n }\n\n public validateCommand(commandString: string): {\n valid: boolean;\n risk: RiskLevel;\n warnings: string[];\n } {\n const parts = commandString.split(/\\s+/);\n const cmdName = parts[0];\n const cmd = cmdName ? this.commands.get(cmdName) : undefined;\n\n if (!cmd) {\n return {\n valid: false,\n risk: RiskLevel.SAFE,\n warnings: [`Unknown command: ${cmdName}`]\n };\n }\n\n const warnings: string[] = [];\n const guidelines = cmdName ? this.safetyGuidelines.get(cmdName) : undefined;\n\n if (guidelines) {\n for (const pattern of guidelines.forbiddenPatterns) {\n if (pattern.test(commandString)) {\n warnings.push(`DANGEROUS: This command matches forbidden pattern: ${pattern}`);\n }\n }\n }\n\n let risk: RiskLevel = cmd ? cmd.riskLevel : RiskLevel.SAFE;\n \n // Adjust risk based on flags\n for (const part of parts.slice(1)) {\n for (const flag of (cmd ? cmd.commonFlags : [])) {\n if (part === flag.flag && flag.riskModifier) {\n const riskOrder = [RiskLevel.SAFE, RiskLevel.LOW, RiskLevel.MEDIUM, RiskLevel.HIGH, RiskLevel.CRITICAL];\n const currentIndex = riskOrder.indexOf(risk);\n const newIndex = Math.min(4, Math.max(0, currentIndex + flag.riskModifier));\n risk = riskOrder[newIndex] || RiskLevel.SAFE;\n }\n }\n }\n\n return {\n valid: warnings.length === 0,\n risk,\n warnings\n };\n }\n\n public suggestAlternative(command: string): AlternativeOption[] {\n const alt = this.alternatives.get(command);\n return alt ? alt.alternatives : [];\n }\n\n public getAllWorkflows(): CommandSequence[] {\n return Array.from(this.workflows.values());\n }\n\n public exportKnowledge(): {\n commands: CommandDefinition[];\n workflows: CommandSequence[];\n guidelines: SafetyGuideline[];\n } {\n return {\n commands: Array.from(this.commands.values()),\n workflows: Array.from(this.workflows.values()),\n guidelines: Array.from(this.safetyGuidelines.values())\n };\n }\n}"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
|
|
3
|
+
declare enum CommandIntent {
|
|
4
|
+
FILE_OPERATION = "FILE_OPERATION",
|
|
5
|
+
PROCESS_MANAGEMENT = "PROCESS_MANAGEMENT",
|
|
6
|
+
SYSTEM_INFO = "SYSTEM_INFO",
|
|
7
|
+
NETWORK_OPERATION = "NETWORK_OPERATION",
|
|
8
|
+
PACKAGE_MANAGEMENT = "PACKAGE_MANAGEMENT",
|
|
9
|
+
PERFORMANCE_OPTIMIZATION = "PERFORMANCE_OPTIMIZATION",
|
|
10
|
+
DISK_MANAGEMENT = "DISK_MANAGEMENT",
|
|
11
|
+
USER_MANAGEMENT = "USER_MANAGEMENT",
|
|
12
|
+
SERVICE_CONTROL = "SERVICE_CONTROL",
|
|
13
|
+
LOG_ANALYSIS = "LOG_ANALYSIS",
|
|
14
|
+
SECURITY_AUDIT = "SECURITY_AUDIT",
|
|
15
|
+
BACKUP_RESTORE = "BACKUP_RESTORE",
|
|
16
|
+
CONTAINER_OPERATION = "CONTAINER_OPERATION",
|
|
17
|
+
UNKNOWN = "UNKNOWN"
|
|
18
|
+
}
|
|
19
|
+
interface LinuxCommand {
|
|
20
|
+
command: string;
|
|
21
|
+
args: string[];
|
|
22
|
+
flags: string[];
|
|
23
|
+
sudo: boolean;
|
|
24
|
+
risk: RiskLevel;
|
|
25
|
+
category: CommandCategory;
|
|
26
|
+
description: string;
|
|
27
|
+
alternatives?: LinuxCommand[];
|
|
28
|
+
}
|
|
29
|
+
declare enum RiskLevel {
|
|
30
|
+
SAFE = "SAFE",
|
|
31
|
+
LOW = "LOW",
|
|
32
|
+
MEDIUM = "MEDIUM",
|
|
33
|
+
HIGH = "HIGH",
|
|
34
|
+
CRITICAL = "CRITICAL"
|
|
35
|
+
}
|
|
36
|
+
declare enum CommandCategory {
|
|
37
|
+
READ_ONLY = "READ_ONLY",
|
|
38
|
+
WRITE = "WRITE",
|
|
39
|
+
DELETE = "DELETE",
|
|
40
|
+
SYSTEM_MODIFY = "SYSTEM_MODIFY",
|
|
41
|
+
NETWORK = "NETWORK",
|
|
42
|
+
PROCESS = "PROCESS",
|
|
43
|
+
SECURITY = "SECURITY"
|
|
44
|
+
}
|
|
45
|
+
interface SystemContext {
|
|
46
|
+
os: string;
|
|
47
|
+
platform: string;
|
|
48
|
+
arch: string;
|
|
49
|
+
hostname: string;
|
|
50
|
+
uptime: number;
|
|
51
|
+
loadAverage: number[];
|
|
52
|
+
totalMemory: number;
|
|
53
|
+
freeMemory: number;
|
|
54
|
+
cpuUsage: number;
|
|
55
|
+
diskUsage: DiskUsage[];
|
|
56
|
+
networkInterfaces: any;
|
|
57
|
+
currentUser: string;
|
|
58
|
+
isRoot: boolean;
|
|
59
|
+
environmentVariables: Record<string, string>;
|
|
60
|
+
}
|
|
61
|
+
interface DiskUsage {
|
|
62
|
+
filesystem: string;
|
|
63
|
+
size: string;
|
|
64
|
+
used: string;
|
|
65
|
+
available: string;
|
|
66
|
+
usePercent: string;
|
|
67
|
+
mountPoint: string;
|
|
68
|
+
}
|
|
69
|
+
interface SystemState {
|
|
70
|
+
context: SystemContext;
|
|
71
|
+
runningProcesses: number;
|
|
72
|
+
activeServices: string[];
|
|
73
|
+
openPorts: number[];
|
|
74
|
+
recentCommands: string[];
|
|
75
|
+
currentWorkingDirectory: string;
|
|
76
|
+
timestamp: Date;
|
|
77
|
+
}
|
|
78
|
+
interface Action {
|
|
79
|
+
type: ActionType;
|
|
80
|
+
command: LinuxCommand;
|
|
81
|
+
priority: number;
|
|
82
|
+
reason: string;
|
|
83
|
+
expectedOutcome: string;
|
|
84
|
+
}
|
|
85
|
+
declare enum ActionType {
|
|
86
|
+
IMMEDIATE = "IMMEDIATE",
|
|
87
|
+
SCHEDULED = "SCHEDULED",
|
|
88
|
+
CONDITIONAL = "CONDITIONAL",
|
|
89
|
+
MONITORING = "MONITORING",
|
|
90
|
+
PREVENTIVE = "PREVENTIVE"
|
|
91
|
+
}
|
|
92
|
+
declare class ContextAnalyzer extends EventEmitter {
|
|
93
|
+
private intentPatterns;
|
|
94
|
+
private systemState;
|
|
95
|
+
private updateInterval;
|
|
96
|
+
constructor();
|
|
97
|
+
private initializeIntentPatterns;
|
|
98
|
+
analyzeUserIntent(input: string): Promise<CommandIntent>;
|
|
99
|
+
determineRequiredCommands(intent: CommandIntent): Promise<LinuxCommand[]>;
|
|
100
|
+
assessSystemState(): Promise<SystemContext>;
|
|
101
|
+
predictNextActions(currentState: SystemState): Promise<Action[]>;
|
|
102
|
+
private createCommand;
|
|
103
|
+
private getCPUUsage;
|
|
104
|
+
private getDiskUsage;
|
|
105
|
+
private updateSystemState;
|
|
106
|
+
private startSystemMonitoring;
|
|
107
|
+
stopMonitoring(): void;
|
|
108
|
+
getSystemState(): SystemState | null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export { type Action, ActionType, CommandCategory, CommandIntent, ContextAnalyzer, type DiskUsage, type LinuxCommand, RiskLevel, type SystemContext, type SystemState };
|