AguiStateReducer

class AguiStateReducer(val store: DataModel = DataModel())

Applies AG-UI STATE_SNAPSHOT and STATE_DELTA events to a DataModel. This is the agent-level state channel, separate from A2UI's per-surface data model — apps that use CoAgent-style shared state should instantiate one reducer per logical state store.

The reducer also exposes an outbound flow of JSON Patches generated by local UI edits (see writeLocal); callers forward these to the agent (e.g. by reusing them as the next run's state payload, or by emitting them on a custom AG-UI side channel).

Constructors

Link copied to clipboard
constructor(store: DataModel = DataModel())

Properties

Link copied to clipboard
val outbound: SharedFlow<JsonArray>

Patches emitted by local UI edits — forward these to the agent.

Link copied to clipboard
val state: StateFlow<JsonElement>

Observable snapshot of the store's root JSON element.

Link copied to clipboard
val store: DataModel

Functions

Link copied to clipboard
fun apply(event: AguiEvent)
Link copied to clipboard
fun writeLocal(pointer: String, value: JsonElement)

Write value locally at pointer and emit an RFC 6902 replace patch on outbound. Used by rememberCoAgentState to flush UI-driven mutations back toward the agent.