title: Introduction group: Getting started order: 10
AGI (the ArOZ Online JavaScript Gateway Interface) is the server-side
JavaScript runtime used by ArozOS for module scripts (.agi / .js).
Scripts run in an Otto VM with
sandboxed access to ArozOS functions. Every request or script gets a fresh VM,
and every call into the file system, the database or another user's data is
checked against the permissions of the user the script runs for.
{{agiVersion}} (AgiVersion in src/mod/agi/agi.go)init.agi: a WebApp's startup script, run once at boot from
./web/<App>/init.agi with system scope only. It registers the app with
registerModule(...) and must not call user or file functions.ao_module_agirun(...) (/system/ajgi/interface). The script runs with the
permissions of the signed-in user, and the request's form fields become
global variables.addNightlyTask) and user-approved scheduled tasks (scheduler).Otto implements ECMAScript 5. Declare variables with var and write
functions with function: let, const, class, arrow functions and
template literals are syntax errors. Regular expressions use Go's RE2 syntax,
so lookahead and backreferences are not available.
// Basic response
sendResp("Hello from AGI");
// JSON response
sendJSONResp({ ok: true, time: Date.now() });
// Load a library
if (requirelib("filelib")) {
var files = filelib.glob("user:/Desktop/*");
sendJSONResp(files);
}
Every code sample in this reference has a Run button that opens it in the Playground, which runs the same Otto interpreter in your browser against a small virtual file system.