#pragma once #include namespace kvida { // Mounts storage and loads the script from there (see // components/drivers/include/storage.h), falling back to the compiled-in // default (src/default_script.h) if none is stored yet. The script only // *defines* the on_tick() function -- call lua_runtime_tick() to actually // run it. Call once at boot. void lua_runtime_init(); // Calls the script's on_tick() global function -- one "wake, execute // Lua, publish changes, sleep" cycle, per AGENTS.md's power philosophy. // A Lua runtime error is logged, not fatal: a script bug shouldn't take // down the device. void lua_runtime_tick(); // Persists `script` to storage and hot-reloads it into a fresh Lua // state, replacing whatever's currently running -- no reboot needed. // Wired to transport::set_script_change_handler() by main.cpp. void lua_runtime_reload(const char *script, size_t len); // Copies the currently-running script into buf (capacity cap), returns // the number of bytes written. Wired to transport::set_script_provider() // by main.cpp. size_t lua_runtime_current_script(char *buf, size_t cap); } // namespace kvida