--- title: Core section: core order: 10 --- ## Response functions ### `sendResp(content)` Sets `HTTP_RESP`. ```javascript sendResp("done"); ``` ### `echo(content)` Appends text to current `HTTP_RESP`. ```javascript echo("Hello "); echo("World"); ``` ### `sendOK()` Sets response to `ok`. ```javascript sendOK(); ``` ### `sendJSONResp(objectOrJsonString)` Sets `HTTP_HEADER = application/json` and writes JSON response. ```javascript sendJSONResp({ success: true, items: [1, 2, 3] }); ``` ## Module and scheduling ### `registerModule(jsonConfigString)` Registers a module from JSON config. ```javascript registerModule(JSON.stringify({ Name: "MyApp", Desc: "Example module", Group: "Utilities", IconPath: "icon.png", Version: "1.0", StartDir: "index.html", SupportFW: true, LaunchFWDir: "index.html" })); ``` ### `addNightlyTask(scriptPath)` Adds a valid AGI script to nightly task list. ```javascript addNightlyTask("MyApp/nightly.agi"); ``` ## Utility and flow ### `includes(scriptName)` Loads and executes another script relative to current script directory. ```javascript includes("helpers.js"); ``` ### `delay(ms)` Sleeps for milliseconds. ```javascript delay(500); ``` ### `exit()` Stops script execution. ```javascript if (!userIsAdmin()) exit(); ``` ### `execd(scriptName, payload)` Executes another script asynchronously. ```javascript execd("worker.agi", JSON.stringify({ job: "thumbs" })); ``` ### Deprecated (kept for compatibility) - `requirepkg(...)` -> deprecated in AGI v3 - `execpkg(...)` -> deprecated in AGI v3 - `decodeVirtualPath(...)` -> deprecated - `decodeAbsoluteVirtualPath(...)` -> deprecated - `encodeRealPath(...)` -> deprecated