Some interfaces need computation the A2UI (agent-to-user interface) 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 model writes a short program, the agent checks it and runs it on your machine, and the result is bound into the rendered UI.

How it works

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

Where the code runs

JIT code is not sandboxed. It runs on your machine, with the same access as the assistant itself. Before it runs, MeghaOS checks the program against an allowlist: it may import computation and data libraries (such as math, json, datetime, pandas and numpy) and web-request libraries, but not modules that reach the filesystem, other processes or the import machinery (such as os, subprocess and importlib), and it may not call open, eval or exec. A program that fails the check is refused before it runs. Because web-request libraries are allowed, a JIT program can fetch data from the internet. Kernel-enforced confinement and default-deny egress are in development.

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 (for example, changes a parameter), the system performs reactive binding: it re-substitutes the new values into the original template and re-runs it, with zero additional model calls. Fast, deterministic, cheap.

Semantic code cache

Generated code is cached semantically: the system compares text embeddings, so a similar query reuses prior code instead of generating it again.