- Added agents overview documentation outlining the project structure and roles. - Implemented `useSessionState` for managing terminal sessions and workspaces. - Developed `useSettingsState` for handling user settings and theme management. - Created `useVaultState` for managing hosts, SSH keys, snippets, and custom groups. - Introduced domain logic for host normalization and sanitization. - Defined models for Host, SSHKey, Snippet, TerminalSession, and Workspace. - Implemented workspace management functions including creation, insertion, and pruning. - Established local storage adapter for persistent data management. - Integrated Gemini AI service for terminal simulation and command generation. - Developed sync service for backing up and restoring configuration to/from GitHub Gists.
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import { Host } from './models';
|
|
|
|
export const normalizeDistroId = (value?: string) => {
|
|
const v = (value || '').toLowerCase().trim();
|
|
if (!v) return '';
|
|
if (v.includes('ubuntu')) return 'ubuntu';
|
|
if (v.includes('debian')) return 'debian';
|
|
if (v.includes('centos')) return 'centos';
|
|
if (v.includes('rocky')) return 'rocky';
|
|
if (v.includes('fedora')) return 'fedora';
|
|
if (v.includes('arch') || v.includes('manjaro')) return 'arch';
|
|
if (v.includes('alpine')) return 'alpine';
|
|
if (v.includes('amzn') || v.includes('amazon') || v.includes('aws')) return 'amazon';
|
|
if (v.includes('opensuse') || v.includes('suse') || v.includes('sles')) return 'opensuse';
|
|
if (v.includes('red hat') || v.includes('rhel')) return 'redhat';
|
|
if (v.includes('oracle')) return 'oracle';
|
|
if (v.includes('kali')) return 'kali';
|
|
return '';
|
|
};
|
|
|
|
export const sanitizeHost = (host: Host): Host => {
|
|
const cleanHostname = (host.hostname || '').split(/\s+/)[0];
|
|
const cleanDistro = normalizeDistroId(host.distro);
|
|
return { ...host, hostname: cleanHostname, distro: cleanDistro };
|
|
};
|