Skip to content

OuroSelf-hosted Luau in pure Luau.

Parse. Compile. Execute.

Ouro

Execute in a sandbox ​

Run untrusted scripts safely in one call with Ouro.run, or build a reusable policy with Ouro.sandbox. Built-in "strict", "balanced", and "trusted" presets configure library allowlists, instruction/call/time limits, memory and pattern caps, and compiler directive clamping explicitly. See Sandboxed VM and Security & Sandbox.

luau
--!strict
local Ouro = require("./ouro")

local ok, result = Ouro.run("local x = ...; return x * 2 + 2", {
	preset = "strict",
}, 20)
assert(ok and result == 42)

local base = Ouro.sandbox({
	preset = "strict",
	globals = { clamp = math.clamp },
})
local playerEnv = base:fork()
local runOk, clamped = playerEnv:run("return clamp(150, 0, 100)")
assert(runOk and clamped == 100)

Parse without loss ​

Ouro.parse lowers Luau syntax, type annotations, and .d.luau declarations into flat numeric arenas with zero-based byte offsets. Slice node source with parsed:text(nodeId), format caret diagnostics with parsed:formatDiagnostics(), enable lossless = true for exact reconstruct() output, or walk nodes without allocating nested tables. See Parsing & AST.

luau
--!strict
local Ouro = require("./ouro")

local source = "-- keep comments\nlocal x: number = 20 + 22\nreturn x"
local parsed = Ouro.parse(source, { profile = "studio", lossless = true })

if parsed.status == "ok" then
	assert(parsed:kindName(parsed.root) == "AstStatBlock")
	assert(parsed:reconstruct() == source)
else
	print(parsed:formatDiagnostics())
end

Compile to Luau bytecode ​

Ouro.compile emits binary Luau bytecode (v14 default, v100 for classes) across optimization levels 0, 1, and 2 with constant folding, builtin fastcalls, inlining, and loop specialization. Ouro.Bytecode includes serialize, deserialize, verify (v3–v14), and disassemble. See Compiling & Bytecode.

luau
--!strict
local Ouro = require("./ouro")

local bytecode = assert(Ouro.compile("local a, b = ...\nreturn a * b + 2", {
	optimizationLevel = 2,
}))

local listing = assert(Ouro.Bytecode.disassemble(bytecode))
assert(#listing > 0)

Run fast in pure Luau ​

Dual @native fast and guarded dispatch loops keep unguarded execution at full speed while enforcing budgets and debug hooks only when configured, paired with lazy submodule loading on startup. See Benchmarks for --codegen -O2 and -O2 breakdowns against Fiu and LuauCeption.

Ouro vs Fiu vs LuauCeption comparison benchmark