Runtime Manager
Overview
brookesia_runtime_manager is the host-side framework for loading runtime app manifests, native bridges, and app lifecycle callbacks.
Core Responsibilities
Defines runtime backend registration and app context ownership.
Provides native host bridge functions such as context attach, detach, finish, and print.
Connects System Core runtime packages to concrete backends.
Integration Position
This component is an independent ESP-Brookesia release component. It can be integrated through ESP-IDF component dependencies and combined with peer framework components as needed.
API Reference
Header File
Classes
-
class Runtime
High-level runtime manager that loads applications through the selected backend.
Runtime owns backend application records and uses the host bridge to expose native services, functions, and values to JavaScript, Lua, WASM, ELF, or other registered backends.
Public Functions
Create a runtime manager.
- Parameters
host_bridge -- Bridge used by runtime backends to call host-provided functions.
-
std::expected<void, std::string> init()
Initialize the runtime manager and prepare registered backends.
- Returns
Empty result on success, or an error string.
-
void deinit()
Deinitialize the runtime manager and unload managed backend state.
-
std::expected<AppId, std::string> load_app(const AppConfig &config)
Load an application from runtime configuration.
- Parameters
config -- Application configuration including backend type and entry resources.
- Returns
Runtime application id on success, or an error string.
-
std::expected<void, std::string> unload_app(AppId id)
Unload a previously loaded application.
- Parameters
id -- Runtime application id returned by load_app().
- Returns
Empty result on success, or an error string.
-
std::expected<void, std::string> start_app(AppId id)
Start a loaded application.
- Parameters
id -- Runtime application id returned by load_app().
- Returns
Empty result on success, or an error string.
-
std::expected<void, std::string> stop_app(AppId id)
Stop a running application.
- Parameters
id -- Runtime application id returned by load_app().
- Returns
Empty result on success, or an error string.
-
std::expected<NativeValue, std::string> call_function(AppId id, std::string_view module_name, std::string_view function_name, const NativeArgs &args = {})
Invoke a function exported by a loaded runtime application.
- Parameters
id -- Runtime application id returned by load_app().
module_name -- Module namespace that owns the function.
function_name -- Function name to call.
args -- Native argument list passed to the function.
- Returns
Function result value on success, or an error string.
-
std::optional<RuntimeApp> get_app(AppId id) const
Get a loaded application record by id.
- Parameters
id -- Runtime application id returned by load_app().
- Returns
Runtime application record when found.
-
std::vector<RuntimeApp> list_apps() const
List all applications currently known to the runtime manager.
- Returns
Snapshot of runtime application records.