Some interfaces need computation the A2UI vocabulary can’t express: a custom calculation, a live-updating value, a transformation of fetched data. For those, MeghaOS uses Just-in-Time (JIT) code: the LLM writes scripting code, the agent runs it in a sandbox, and the result is bound into the rendered UI.

How it works

compose_ui returns A2UI JSON. When custom logic is required, the LLM embeds a __jit__ key holding scripting code inside the same response (no separate code-generation call).

The sandbox

The sandbox runs generated code safely. It is a restricted environment that blocks unauthorized filesystem and network access. Code execution is designed to be fully isolated to protect the host system.

Binding output to the UI

A UI component can declare "jit_bind": "key". After the code runs and returns a dict, the value at that key is bound into the component deterministically. No guessing which output maps to which widget.

Streaming (live widgets)

For widgets that update continuously, the streaming engine runs a loop that re-executes the code on an interval and pushes updates to the shell:
  • Drift-free timer: each cycle sleeps just enough so ticks don’t drift.
  • JSON diffing: computes the delta each tick and sends only a patch, minimizing payload size.
  • Updates are broadcast straight to the shell.
A streaming app is auto-detected when its code references the injected elapsed_time value (seconds since the stream started), letting the code animate or recompute against a live clock each tick.

Reactive actions

When the user interacts with a JIT widget (e.g. changes a parameter), the system performs reactive binding: it re-substitutes dynamic values into the original template, requiring zero additional LLM calls. Fast, deterministic, cheap.

Semantic code cache

Generated code is cached semantically. The system uses text embeddings so a similar query reuses prior code instead of regenerating.