Metadata-Version: 2.5
Name: omochi-ui
Version: 0.2.1
Summary: Declarative, transport-independent application runtime for A2UI
Project-URL: Repository, https://github.com/omochi-ui/omochi
Project-URL: Documentation, https://github.com/omochi-ui/omochi/blob/main/docs/sdk.md
Project-URL: Issues, https://github.com/omochi-ui/omochi/issues
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: typing-extensions>=4.12
Provides-Extra: test
Requires-Dist: mypy>=1.18; extra == 'test'
Requires-Dist: pyright>=1.1.400; extra == 'test'
Requires-Dist: pytest>=8; extra == 'test'
Provides-Extra: websocket
Requires-Dist: websockets>=14; extra == 'websocket'
Description-Content-Type: text/markdown

# Omochi UI for Python

Attach browser UIs to Python programs with the declarative A2UI runtime.

```sh
pip install omochi-ui
# Optional WebSocket transport:
pip install 'omochi-ui[websocket]'
```

Requires Python 3.11 or newer. The CLI is distributed separately as
`@omochi-ui/cli` on npm (Node.js 22+ launcher), or as a native archive.

See the [SDK guide](https://github.com/omochi-ui/omochi/blob/main/docs/sdk.md)
and [project README](https://github.com/omochi-ui/omochi) for examples.

```python
import asyncio
from omochi_ui import App, ui

app = App({"result": ""})


@app.action
async def run(temperature: float, context):
    async with context.update() as state:
        state["result"] = f"Ran at temperature {temperature:g}"


def main(state):
    temperature = ui.local("temperature", 50.0)
    with ui.column():
        ui.slider("Temperature", 0, 100, bind=temperature)
        ui.button("Run", on_click=run, input=temperature)
        ui.text(state["result"])


app.mount(main)
asyncio.run(app.start())
```

State is an ordinary Python object shared by the service's connected clients.
Each renderer keeps its own draft inputs. Input annotations generate validation;
actions receive concrete values when the user clicks. `app.start()` speaks JSONL
on stdio; connect it with `omochi-ui dev -- python app.py` to open a browser UI.

Stdio and Unix socket transports accept JSONL input up to 4 MiB of UTF-8 bytes
per line, excluding the LF delimiter (a preceding CR counts toward the limit).
An oversized line ends stdio reception with `ValueError`, or closes only the
offending Unix socket connection. A final line without LF is accepted at EOF
within the same limit.

Use dataclasses for structured inputs, `type=` for TypedDict/container locals,
and `with ui.scope(key):` to give repeated components stable keys. Typed field
projections and explicit schemas are available when stronger checking is needed.
Existing `(ui, state)` Surface functions and explicit schema/field APIs continue
to work. `on_click=` accepts registered Action handles rather than raw callbacks.

The next minor release introduces typed action inputs and requires migrating
action registration and local field references. See the SDK guide migration section.
Python wheels include `py.typed`; both mypy and Pyright are tested.

Licensed under Apache-2.0.
