UNPKG

tlnt

Version:

TLNT - HMS-Powered Multi-Agent Platform with Government Agency Analysis, Deep Research, and Enterprise-Ready Deployment. Self-optimizing multi-domain AI agent with continuous learning and enterprise-grade performance monitoring.

224 lines 8.25 kB
/** * Tmux Configuration Manager * * Handles loading, saving, and managing tmux-style configurations * with support for themes, layouts, and user preferences */ import { homedir } from 'os'; import { join } from 'path'; import { readFileSync, writeFileSync, existsSync } from 'fs'; import { getTheme } from './tmuxThemes.js'; const defaultConfig = { theme: 'default', layout: { splitRatio: 0.7, orientation: 'horizontal', showTitles: true, showBorders: true, }, features: { hmsIntegration: true, autoRefresh: true, refreshInterval: 3, enableNotifications: true, enableSounds: false, }, keybindings: { switchPane: 'Tab', cycleMode: 'Ctrl+M', exit: 'Ctrl+C', clear: 'Ctrl+L', help: 'F1', }, display: { showTimestamp: true, timestampFormat: 'HH:mm:ss', maxHistory: 1000, wordWrap: true, }, panels: { activePanels: ['medical-standards'], // Default healthcare panel defaultIndustry: 'healthcare', panelLayout: 'tabs', maxPanels: 5, }, }; export class TmuxConfigManager { configPath; config; constructor() { this.configPath = join(homedir(), '.blax-tmux.json'); this.config = this.loadConfig(); } loadConfig() { try { if (existsSync(this.configPath)) { const configData = readFileSync(this.configPath, 'utf8'); const loadedConfig = JSON.parse(configData); // Merge with defaults to ensure all properties exist return { ...defaultConfig, ...loadedConfig, layout: { ...defaultConfig.layout, ...loadedConfig.layout }, features: { ...defaultConfig.features, ...loadedConfig.features }, keybindings: { ...defaultConfig.keybindings, ...loadedConfig.keybindings }, display: { ...defaultConfig.display, ...loadedConfig.display }, panels: { ...defaultConfig.panels, ...loadedConfig.panels }, }; } } catch (error) { console.warn('Failed to load tmux config, using defaults:', error); } return { ...defaultConfig }; } saveConfig() { try { writeFileSync(this.configPath, JSON.stringify(this.config, null, 2)); } catch (error) { console.error('Failed to save tmux config:', error); } } getConfig() { return { ...this.config }; } updateConfig(updates) { this.config = { ...this.config, ...updates, layout: { ...this.config.layout, ...updates.layout }, features: { ...this.config.features, ...updates.features }, keybindings: { ...this.config.keybindings, ...updates.keybindings }, display: { ...this.config.display, ...updates.display }, panels: { ...this.config.panels, ...updates.panels }, }; this.saveConfig(); } setTheme(themeName) { this.config.theme = themeName; this.saveConfig(); } getTheme() { return getTheme(this.config.theme); } resetToDefaults() { this.config = { ...defaultConfig }; this.saveConfig(); } // Theme-specific methods setLayout(splitRatio, orientation = 'horizontal') { this.config.layout.splitRatio = Math.max(0.1, Math.min(0.9, splitRatio)); this.config.layout.orientation = orientation; this.saveConfig(); } toggleBorders() { this.config.layout.showBorders = !this.config.layout.showBorders; this.saveConfig(); } toggleTitles() { this.config.layout.showTitles = !this.config.layout.showTitles; this.saveConfig(); } setRefreshInterval(seconds) { this.config.features.refreshInterval = Math.max(1, Math.min(60, seconds)); this.saveConfig(); } // Panel management methods addPanel(panelId) { if (!this.config.panels.activePanels.includes(panelId)) { this.config.panels.activePanels.push(panelId); this.saveConfig(); } } removePanel(panelId) { const index = this.config.panels.activePanels.indexOf(panelId); if (index > -1) { this.config.panels.activePanels.splice(index, 1); this.saveConfig(); } } setActivePanels(panelIds) { this.config.panels.activePanels = panelIds.slice(0, this.config.panels.maxPanels); this.saveConfig(); } setDefaultIndustry(industry) { this.config.panels.defaultIndustry = industry; this.saveConfig(); } // Configuration export/import exportConfig() { return JSON.stringify(this.config, null, 2); } importConfig(configJson) { try { const importedConfig = JSON.parse(configJson); this.updateConfig(importedConfig); return true; } catch (error) { console.error('Failed to import config:', error); return false; } } // Validation validateConfig(config) { const errors = []; if (config.layout?.splitRatio !== undefined) { if (config.layout.splitRatio < 0.1 || config.layout.splitRatio > 0.9) { errors.push('Split ratio must be between 0.1 and 0.9'); } } if (config.features?.refreshInterval !== undefined) { if (config.features.refreshInterval < 1 || config.features.refreshInterval > 60) { errors.push('Refresh interval must be between 1 and 60 seconds'); } } if (config.display?.maxHistory !== undefined) { if (config.display.maxHistory < 10 || config.display.maxHistory > 10000) { errors.push('Max history must be between 10 and 10000'); } } return errors; } // Presets static getPresets() { return { 'developer': { theme: 'dracula', layout: { splitRatio: 0.75, orientation: 'horizontal', showBorders: true, showTitles: true }, features: { hmsIntegration: true, autoRefresh: true, refreshInterval: 2, enableNotifications: true, enableSounds: false }, display: { showTimestamp: true, timestampFormat: 'HH:mm:ss', maxHistory: 2000, wordWrap: true }, }, 'minimal': { theme: 'minimal', layout: { splitRatio: 0.8, orientation: 'horizontal', showBorders: false, showTitles: false }, features: { hmsIntegration: true, autoRefresh: true, refreshInterval: 5, enableNotifications: false, enableSounds: false }, display: { showTimestamp: false, timestampFormat: 'HH:mm', maxHistory: 500, wordWrap: false }, }, 'cyberpunk': { theme: 'cyberpunk', layout: { splitRatio: 0.65, orientation: 'horizontal', showBorders: true, showTitles: true }, features: { hmsIntegration: true, autoRefresh: true, refreshInterval: 1, enableNotifications: true, enableSounds: false }, display: { showTimestamp: true, timestampFormat: 'HH:mm:ss', maxHistory: 1500, wordWrap: true }, }, 'professional': { theme: 'solarized-dark', layout: { splitRatio: 0.7, orientation: 'horizontal', showBorders: true, showTitles: true }, features: { hmsIntegration: true, autoRefresh: true, refreshInterval: 3, enableNotifications: true, enableSounds: false }, display: { showTimestamp: true, timestampFormat: 'HH:mm', maxHistory: 1000, wordWrap: true }, }, }; } applyPreset(presetName) { const presets = TmuxConfigManager.getPresets(); const preset = presets[presetName]; if (preset) { this.updateConfig(preset); return true; } return false; } } export default TmuxConfigManager; //# sourceMappingURL=tmuxConfig.js.map