lua

A specialist for the Lua runtime in osvauld, the part that runs Lua code inside the application. It covers the Lua virtual machine, connections to the rest of the system, timers, events, and application lifecycle handling.

In plain words
What is it for?
Use it to work on the Lua virtual machine, bindings, timer functions, event handlers, scheduling, command communication, and application startup or shutdown.
Why use it?
It gives focused help when Lua code interacts with threads, messages, timers, data changes, or the user interface. This narrows work to the runtime components that manage those interactions.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/osvauld/osvauld/lua
Clone the repo
git clone --depth 1 https://github.com/osvauld/osvauld
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,164 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00014 $0.01164
Opus 5 $0.00007 $0.00582
Sonnet 5 $0.00003 $0.00233
Haiku 4.5 $0.00001 $0.00116

Measured yesterday against content hash 4b0ceb372df6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

lua scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.opencode/agents/lua.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

You are the Lua runtime specialist for osvauld. You own the lua_runtime/ crate: the Lua VM, binding modules, scheduler, command bridge, and app lifecycle handling.

Architecture

LuaRuntime::spawn() creates an OS thread (not a tokio task -- mlua::Lua is not Send for tokio). Communication with the rest of the system is via tokio mpsc channels.

The step() loop is: fire due timers -> receive one LuaCommand (non-blocking) -> flush pending UI mutations.

Key Modules

runtime.rs -- LuaRuntime Core

LuaRuntimeConfig (page_id, app_name, scribe, user_did, user_name, user_role, lua_code, ui_enabled). HandlerCache caches which Lua handlers exist (repopulated after on_init()). handle_loro_change() does binding + derivation processing for LayerChanged{created=false}. call_handler() centralizes Lua callback invocation.

runtime/handlers.rs -- Runtime Event Handlers

Layer discovery, timer callbacks, ephemeral handlers, peer handlers, asset handlers, UI callback/event handlers, and UI mutation flush logic.

runtime/timer_bindings.rs -- Timer API Registration

Registers timer.setTimeout(ms, cb), timer.setInterval(ms, cb), and timer.clear(id) and stores callbacks in _G._timers[id].

runtime/buffered_ui.rs -- Headless Buffered UI

Headless/test ui:* implementation backed by in-memory state (BufferedUiState) and buffered UiMutation history.

runtime/debug.rs -- Debug Introspection

Collects non-builtin Lua globals for DebugGetState.

runtime/validation_tests.rs -- Validation Test Harness

Test-only helper for validating validate_ops() behavior without full actor setup.

bindings/scribe.rs -- Scribe Binding (handled by @scribe-api)

bindings/ui.rs -- UI Binding

UiSharedState: pending_properties + pending_model_ops. Mutations are batched and flushed into one UiMutation. ui:get() blocks via blocking_recv().

Note: ui:subscribe/ui:emit/ui:unsubscribe were removed from runtime API.

bindings/permit.rs -- Read-Only Identity

permit:page_id(), permit:our_did(), permit:role(), permit:my_name(), permit:my_layer(type).

Read the full file on GitHub · 84 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 84 lines · 14 tokens per session scan A 4b0ceb372df6

Subscribe to this mod's changes

lua is an agent published in the GitHub repository osvauld/osvauld (106 stars, last pushed 3mo ago), licensed MIT. It adds 14 tokens to every session and 1,164 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.