Skip to content

Getting Started ​

Install Ouro in Roblox or standalone Luau and run your first sandboxed script in a few lines.

Installation ​

Add Ouro to [dependencies] in wally.toml and run wally install:

toml
[dependencies]
Ouro = "kohltastrophe/[email protected]"

Ouro installs as a shared dependency in Packages, available on both the Roblox server and client.

pesde ​

Install Ouro with the pesde CLI:

sh
pesde add kohltastrophe/ouro

Or add it directly to [dependencies] in pesde.toml and run pesde install:

toml
[dependencies]
ouro = { name = "kohltastrophe/ouro", version = "^0.1.0" }

Ouro publishes both roblox and luau targets under the same version, so pesde add picks the matching build automatically.

GitHub Releases (.rbxm) ​

  1. Download Ouro.rbxm or Ouro-<version>-package.zip (with SHA256SUMS) from GitHub Releases.
  2. Drag Ouro.rbxm into Roblox Studio and place the Ouro module inside ReplicatedStorage.

Rojo, Standalone & dist Branch ​

Sync src/ directly into your Rojo tree, require the repository root directly in standalone Luau (local Ouro = require("./ouro")), or vendor the runtime-only dist branch:

sh
git subtree add --prefix=Packages/Ouro https://github.com/kohltastrophe/ouro.git dist --squash

You can also build an .rbxm locally with Rojo (rojo build default.project.json --output build/Ouro.rbxm).

Run an Untrusted Script Safely ​

Start with Ouro.run. It executes Luau source in an isolated environment under the "balanced" safety preset by default (inheritHost = false, mode = "text" for strings, clamped directives, instruction/call/timeout caps, and allocation/pattern limits) and returns a pcall-style (ok, ...resultsOrErr) tuple:

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

local ok, answer = Ouro.run("local n = ...; return n * 2 + 2", {
	preset = "strict",
}, 20)

if ok then
	assert(answer == 42)
else
	print("Guest failed:", answer)
end

Build a Reusable Sandbox Policy ​

Create a Sandbox once when running multiple scripts under the same host APIs and budgets. Call :fork() to isolate each script or player:

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

local policy = Ouro.sandbox({
	preset = "strict",
	globals = {
		answer = 40,
		round = math.round,
	},
	getGlobal = function(name, env)
		if name == "bonus" then
			return 2
		end
		return env[name]
	end,
	safeEnv = true,
})

-- Each fork has independent globals and its own PCG32 math.random state
local scriptA = policy:fork()
local scriptB = policy:fork()

local okA, valA = scriptA:run("shared = 99; return answer + bonus")
local okB, seenA, rounded = scriptB:run("return shared, round(3.6)")

assert(okA and valA == 42)
assert(okB and seenA == nil and rounded == 4)

Calling policy:reset() resets instruction, memory, and timeout budgets on closures loaded through that sandbox handle so you can reuse compiled functions across frames or rounds.

Low-Level Fast Loading ​

When you want direct control over compiled closures without preset overhead, call Ouro.load. It still isolates the global environment (inheritHost = false), and runs on the unguarded @native dispatch loop unless you opt into budgets or hooks:

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

local fn, err = Ouro.load("local a, b = ...; return a + b")
assert(fn ~= nil, err)
assert(fn(20, 22) == 42)

Parsing & Compiling Directly ​

You can run the parser, compiler, and bytecode toolkit on their own without loading the VM:

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

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

if parsed.status == "ok" then
	assert(parsed:reconstruct() == source)

	local bytecode = assert(Ouro.compile(parsed, { optimizationLevel = 2 }))
	local listing = assert(Ouro.Bytecode.disassemble(bytecode))
	assert(#listing > 0)
else
	print(parsed:formatDiagnostics())
end

Passing an existing ParseResult to Ouro.compile skips re-lexing and reparsing the source string.

Error Contract Summary ​

Every public entrypoint follows one consistent contract:

  • Invalid caller arguments (wrong types, unknown option keys, invalid preset names, out-of-range numbers): always throw immediately.
  • High-level execution (Ouro.run, sandbox:run): returns (ok, ...resultsOrErr) so guest syntax, compile, runtime, or budget failures never crash the host.
  • Compiler, loader, and bytecode APIs (Ouro.compile, Ouro.Compiler.compileProto, Ouro.load, VM.loadBytecode, VM.loadProto, Bytecode.verify, serialize, deserialize, disassemble): return (value?, err?) (or (ok, err?) for verify).
  • Diagnostic operations (Ouro.parse, parseExpression, parseType, compileResult): return structured result objects with status and diagnostics.

Next Steps ​

Start with the Cookbook for copy-paste recipes covering Roblox user scripts, precompiled bytecode, linters, and debuggers. Dive into the pipeline guides for Parsing & AST, Compiling & Bytecode, Sandboxed VM, and Security & Sandbox. For numbers and full --!strict signatures, check Benchmarks and the API Reference.