Metadata-Version: 2.5
Name: statepatch
Version: 0.2.2
Summary: Immer-style ops over a plain JSON tree: observables that emit every mutation as an op
Project-URL: Repository, https://github.com/assistant-ui/harness-sdk
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# statepatch

Immer-style ops over a plain JSON tree: `observable(initial)` wraps one value, `.value` reads it, and every mutation emits the matching `replace` / `add` / `remove` op to subscribers. Observables compose: one stored inside another mounts its op stream at that path. Part of [harness-sdk](https://github.com/assistant-ui/harness-sdk), under `statewire` and `pinned`.

## Install

```sh
uv add statepatch
```

## Use

```python
from statepatch import observable

state = observable({"runs": []})
state.subscribe(print)

run = observable({"runId": "r1", "queue": []})
state["runs"].append(run)          # add op at ["runs", 0]
run["queue"].append({"id": "q1"})  # forwarded as add at ["runs", 0, "queue", 0]
state["runs"].pop(0)               # remove op; run is detached and reusable
```

## Docs

- Reference: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/reference/packages/page.mdx
- Guide: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/guides/statewire/host/page.mdx
- Spec: https://github.com/assistant-ui/harness-sdk/blob/main/apps/docs/app/docs/spec/statewire-protocol/statepatch/page.mdx
