The Kernel class manages the core system components: the virtual filesystem (VFS), persistence layer, and virtual port registry for network requests. Itβs responsible for booting the system and initializing the standard directory structure.
Registry mapping virtual ports to request handlers for network operations.
portRegistry: Map<number, VirtualRequestHandler>
Example:
// Register a virtual HTTP server on port 3000kernel.portRegistry.set(3000, (req, res) => { res.statusCode = 200; res.headers['content-type'] = 'application/json'; res.body = JSON.stringify({ message: 'Hello from virtual server!' });});// Now commands like `curl http://localhost:3000` will hit this handler
Initialize standard Unix-like directory structure and system files. Called automatically by boot().
initFilesystem(): void
Creates the following directories:
/bin - System binaries
/etc - Configuration files
/home - User home directories
/home/user - Default user home
/tmp - Temporary files
/var - Variable data
/var/log - Log files
/usr - User programs
/usr/bin - User binaries
/usr/share - Shared data
/usr/share/pkg - Package data
/usr/share/pkg/node_modules - Node.js packages
Writes system files:
/etc/motd - Message of the day (shown on shell startup)
/etc/hostname - System hostname (lifo)
/etc/profile - System-wide environment setup
/home/user/.liforc - User shell configuration (aliases, environment)
Example:
const kernel = new Kernel();kernel.initFilesystem();// Standard directories now existconsole.log(kernel.vfs.exists('/home/user')); // trueconsole.log(kernel.vfs.exists('/tmp')); // true