Spaces:
Sleeping
Puter Kernel Documentation
Overview
The Puter Kernel is the core runtime component of the Puter system. It provides the foundational infrastructure for:
- Initializing the runtime environment
- Managing internal and external modules (extensions)
- Setting up and booting core services
- Configuring logging and debugging utilities
- Integrating with third-party modules and performing dependency installs at runtime
This kernel is responsible for orchestrating the startup sequence and ensuring that all necessary services, modules, and environmental configurations are properly loaded before the application enters its operational state.
Features
Modular Architecture:
The Kernel supports both internal and external modules:- Internal Modules: Provided to Kernel by an initializing script, such
as
tools/run-selfhosted.js, via theadd_module()method. - External Modules: Discovered in configured module directories and installed
dynamically. This includes resolving and executing
package.jsonentries and runningnpm installas needed.
- Internal Modules: Provided to Kernel by an initializing script, such
as
Service Container & Registry:
The Kernel initializes a service container that manages a wide range of services. Services can:- Register modules
- Initialize dependencies
- Emit lifecycle events (
boot.consolidation,boot.activation,boot.ready) to orchestrate a stable and consistent environment.
Runtime Environment Setup:
The Kernel sets up aRuntimeEnvironmentto determine configuration paths and environment parameters. It also provides global helpers likekvfor key-value storage andclfor simplified console logging.Logging and Debugging:
Uses a temporaryBootLoggerfor the initialization phase until LogService is initialized, at which point it will replace the boot logger. Debugging features (ll,xtra_log) are enabled in development environments for convenience.
Initialization & Boot Process
Constructor:
When a Kernel instance is created, it sets up basic parameters, initializes an empty module list, and preparesuseapi()integration.Booting:
Theboot()method:- Parses CLI arguments using
yargs. - Calls
_runtime_init()to set up theRuntimeEnvironmentand boot logger. - Initializes global debugging/logging utilities.
- Sets up the service container (usually called
servicesc instance of Container). - Invokes module installation and service bootstrapping processes.
- Parses CLI arguments using
Module Installation:
Internal modules are registered and installed first.
External modules are discovered, packaged, installed, and their code is executed.
External modules are given a special context with access touseapi(), a dynamic import mechanism for Puter modules and extensions.Service Bootstrapping:
After modules and extensions are installed, services are initialized and activated. For more information about how this works, see boot-sequence.md.